Closed blockyTj995 closed 5 years ago
You would just need to add another switch statement if you wanted to make simple commands where the bot responded.
switch(cmd) {
case 'Ping':
bot.sendMessage({
to: channelID,
message: Pong'
});
break;
case 'Hello':
bot.sendMessage({
to: channelID,
message: 'Goodbye'
break;
});
@pongored81 I tried this and it gives me and error about the break
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Im not good at js or nodejs. and i want to know how to put in more commands in the bot. heres my code ,
var Discord = require('discord.io'); var logger = require('winston'); var auth = require('./auth.json'); // Configure logger settings logger.remove(logger.transports.Console); logger.add(new logger.transports.Console, { colorize: true }); logger.level = 'debug'; // Initialize Discord Bot var bot = new Discord.Client({ token: auth.token, autorun: true }); bot.on('ready', function (evt) { logger.info('Connected'); logger.info('Logged in as: '); logger.info(bot.username + ' - (' + bot.id + ')'); }); bot.on('message', function (user, userID, channelID, message, evt) { // Our bot needs to know if it will execute a command // It will listen for messages that will start with
!
if (message.substring(0, 1) == '~') { var args = message.substring(1).split(' '); var cmd = args[0];});