1 回答

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超6個(gè)贊
你可以把它放在一個(gè)函數(shù)中,然后一遍又一遍地重復(fù)這個(gè)函數(shù)。
message.author.send(
'Lets get to work!\nPlease enter the title of your event. (Must be shorter than 200 characters)'
);
const collecter = () => {
message.channel
.awaitMessages(
(response) => response.author.id === message.author.id, // remove requirement from function
{
max: 1,
time: 10000,
errors: ['time'],
}
)
.then((collected) => {
if (collected.first().content.length < 200) {
// add it in the callback
message.channel.send('bla bla bla went wrong! Please try again');
collector(); // repeat the function
}
message.author.send(
`I collected the message : ${collected.first().content}`
);
let title = collected.first().content;
})
.catch(() => {
message.author.send('No message collected after 10 seconds.');
});
};
collector();
添加回答
舉報(bào)