admin管理员组文章数量:1432178
I want my bot to respond once to a mand such as .on
. However, it responds multiple times per input:
The code is:
client.on('message', message =>{
if(message.content === '.on'){
message.channel.sendMessage('Testing Bot is now Online, Greetings, ' + message.author.username);
}
If anyone could point me in the right direction to make the bot respond once that would be great.
I want my bot to respond once to a mand such as .on
. However, it responds multiple times per input:
The code is:
client.on('message', message =>{
if(message.content === '.on'){
message.channel.sendMessage('Testing Bot is now Online, Greetings, ' + message.author.username);
}
If anyone could point me in the right direction to make the bot respond once that would be great.
Share Improve this question edited Mar 28, 2018 at 17:10 cxw 17.1k2 gold badges48 silver badges84 bronze badges asked May 4, 2017 at 1:12 AaronAaron 431 gold badge3 silver badges10 bronze badges 3- Here is the answer on Duplicated question - https://stackoverflow./questions/51064042/discord-bot-still-answering-multiple-times-on-one-event – Oysho Boy Commented Jun 27, 2018 at 13:37
- 1 Extra points for Trump bot – Blairg23 Commented Apr 8, 2019 at 3:21
- This question is similar to: Discord bot still answering multiple times on one event. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – tevemadar Commented Jan 19 at 0:17
3 Answers
Reset to default 0sendMessage
is deprecated. Try using send
instead.
client.on('message', message => {
if(message.content === '.on') {
message.channel.send('Testing Bot is now Online, Greetings, ' + message.author.username);
}
}
Also, if this still causes issues consider checking the id/content of the message event as well as the returned promise to make sure you didn't make a mistake elsewhere. It'll be obvious very quickly what's going on. That'd be:
client.on('message', message => {
if(message.content === '.on') {
console.log('Received #' + message.id + ': ' + message.content);
message.channel.send('Testing Bot is now Online, Greetings, ' + message.author.username)
.then(message => console.log('Sent #' + message.id + ': ' + message.content))
.catch(console.error);
}
}
I'm late, but I think you had multiple instances of your bot running at the same time.
Try to change the token, so all bots will stop working and then make sure, you just starting one instance.
本文标签: javascriptDiscord bot responds multiple times for one eventStack Overflow
版权声明:本文标题:javascript - Discord bot responds multiple times for one event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745589445a2665109.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论