私はbottingとjsを戸惑わせるのが初めてです。私は自分のbotで遊んでいます。私はタイピングのミニゲームをしたい。チャットで?type
と入力すると、ボットはチャットで何かを発言し、カウントダウン中にそのメッセージを編集します。カウントダウンが終了すると、ランダムに生成された単語が表示されます。プレイヤーはチャットに正確なランダムな単語を入力する必要があり、ボットには合計時間が表示されます。それはまで0 私はmessage.channel.send(randomWord)
が動作しない理由を理解しないを数えた後、現在のコードが停止しsetTimeout()の2番目の関数が実行されません
case "type":
let randomWord = Math.random().toString(36).replace(/[^a-z]+/g, '');
let timer = 3;
message.channel.send("Generating a new word..")
.then((msg)=> {
var interval = setInterval(function() {
msg.edit(`Starting in **${timer--}**..`)
}, 1000)
});
setTimeout(function() {
clearInterval(interval);
message.channel.send(randomWord)
.then(() => {
message.channel.awaitMessages(response => response.content == randomWord, {
max: 1,
time: 10000,
errors: ['time'],
})
.then(() => {
message.channel.send(`Your time was ${(msg.createdTimestamp - message.createdTimestamp)/1000} seconds.`);
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
});
}, 5000);
break;
:
は、ここに私のコードです。また、誰かが私にこのコードを変更してasynchを使うのを手伝ってもらえれば、それが大好きです。