renesansz / discord-greeter-bot

My greeter bot for Discord
MIT License
49 stars 38 forks source link

More commands #198

Closed blockyTj995 closed 5 years ago

blockyTj995 commented 5 years ago

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];

    args = args.splice(1);
    switch(cmd) {
        // ~yeet
        case 'Ping':
            bot.sendMessage({
                to: channelID,
                message: Pong'
            });
        break;            break;
     }
 }

});

pongored81 commented 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;
     });
deadpoolex commented 5 years ago

@pongored81 I tried this and it gives me and error about the break

stale[bot] commented 5 years ago

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.