그래서 저는 botting과 js를 혼란에 빠뜨리므로 내 자신의 봇과 놀고 있습니다. 나는 타이핑 미니 게임을 만들고 싶다. 채팅에 ?type
을 입력하면 봇에서 채팅 내용을 말하고 카운트 다운하는 동안 해당 메시지를 편집합니다. 카운트 다운이 끝나면 임의로 생성 된 단어가 표시됩니다. 플레이어는 채팅에서 정확한 임의의 단어를 입력해야하며 봇은 총 소요 시간을 표시합니다. 이 아래로 0 내가 message.channel.send(randomWord)
작동하지 않는 이유를 이해 해달라고을 계산 한 후 현재 코드가 중지setTimeout()의 두 번째 함수가 실행되지 않습니다.
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를 사용하기 위해이 코드를 변경하도록 도와 줄 수 있다면 그것이 좋을 것이다.