How do I create a case statement in discord.js

时间:2018-01-17 12:53:44

标签: javascript discord.js

This code is what i am using now to have a rough idea of what to do

bot.on('message', (message) => {
    if (messege.content.includes) {
        int (num = 0);
        switch(num) {
            case 1:
                System.out.println('The IP of the server is .');
            case 2:
                System.out.println('The Store is');
            case 3:
                System.out.println('Disord instant link : ');
            default:
                System.out.println('Sorry ');
        }
    }
});
bot.on('message', (message) => {
   if(message.content == (prefix + 'help')) {
        message.channel.sendMessage('With what may you like help?');
        message.reply('Enter 1, ...');
        message.reply('Enter 2, Stores link!');
        message.reply('Enter 3, discord instant link');
    }
});

How would i create a case statement based on what was given in the input and how to return the outcome?

1 个答案:

答案 0 :(得分:0)

您将不得不查看async / await函数,以便在消息上运行某个函数。 Tutorial on async/await

基本上你发送提示:

message.channel.send('With what may you like help?');

然后await等待响应,您可以在switch语句中使用结果。

修改:您不必考虑async/await使用此解决方案:Waiting for reply with discord.js

相关问题