[英]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.