使用JDA制作的Discord机器人正在删除错误消息。

huangapple go评论63阅读模式
英文:

Discord bot made using JDA is deleting incorrect messages

问题

我制作了一个 Discord 机器人,它会读取特定的频道,并检查用户是否使用特定的语法进行输入。如果用户未按照正确的语法输入,机器人将会删除该消息。

以下是代码部分:

# 代码部分不翻译

机器人不应删除以“!”,“-”和“~”为前缀的消息,也不应删除来自机器人的消息。

机器人成功地删除了不正确的消息,但也删除了正确的消息。我该如何修复这个问题?

英文:

I made a discord bot that reads a specific channel and checks if the users are typing in a specific sintax. If the user doesn’t type using the proper syntax the bot is supposed to delete the message.

Here is the code: 使用JDA制作的Discord机器人正在删除错误消息。

The bot is not supposed to delete messages that start with the prefixes “!,- and ~” or messages from bots.

The bot successfully deletes the improper messages but also deletes the proper messages. How can I fix this?

答案1

得分: 2

将你的 || 替换为 &&。应该是

if (!content.startsWith("!") && !content.startsWith("-") && !content.startsWith("~")) { ... }
英文:

Replace your || with &&. It should be

if (!content.startsWith("!") && !content.startsWith("-") && !content.startsWith("~")) { ... }

huangapple
  • 本文由 发表于 2020年8月17日 04:52:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63441828.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定