簡體   English   中英

我如何在discord.js中創建一個case語句

[英]How do I create a case statement in discord.js

這段代碼是我現在用來大致了解要做什么的代碼

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');
    }
});

我將如何基於輸入中給出的內容以及如何返回結果來創建案例陳述?

您將不得不研究async / await功能,以便在消息上可以運行某個功能。 異步/等待教程

本質上,您發送提示:

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

然后await響應,然后可以在switch語句中使用結果。

編輯:您不必研究async/await考慮使用此解決方案: 等待與discord.js的答復

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM