discord.js bot回复自己 [英] discord.js bot replies to itself

查看:167
本文介绍了discord.js bot回复自己的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写我的第一个discord bot,它已经可以播放YouTube音乐。

I am currently coding my first discord bot, it can already play YouTube music.

if (message.content.includes("Good Job") || 
    message.content.includes("good job")) {
    message.channel.sendMessage("Good Job everyone :smirk:");
}

如你所见,如果有人输入好工作(这只是一个例子)然后机器人将回复好工作每个人:smirk :),但随后垃圾邮件将开始:机器人读取他自己的消息并回复它。

As you see, if someone types "good job" (this is just an example) then the bot will reply with "good job everyone :smirk:), but then the spam will begin: the bot reads his own message and replies to it.

如何防止机器人自行回答?

How can I prevent the bot from answering itself?

推荐答案

在消息事件中使用此项:

Use this in the on message event:

if (message.author.bot) return;

了解更多信息:
https://anidiotsguide.gitbooks.io/discord-js-bot-guide/coding-guides/a-basic-command-handler.html

这篇关于discord.js bot回复自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆