禁用自动调节时机器人没有响应
Posted
技术标签:
【中文标题】禁用自动调节时机器人没有响应【英文标题】:Bot not responding when automoderation is disabled 【发布时间】:2021-05-15 21:56:27 【问题描述】:在我的 Discord 机器人上,如果用户希望机器人删除消息、踢出用户、禁止用户或软禁用户,用户可以选择不和谐邀请检测 automod,所有这些都存储在 MongoDB 上。但是当用户在他们的公会上禁用 automod 时,它会停止响应所有命令,直到通过编辑 MongoDB 文件手动重新打开它
这是我的 message.js 代码:
https://haste.pancake.gg/ludiritaga.js
【问题讨论】:
【参考方案1】:这实际上是一个相对简单的错误,信不信由你。我以前犯过很多次这个错误,所以你并不孤单! 您的命令检测语句包含在 if(linkDetect === `on`) ... 语句中。
) //Add a closing bracket here. This will exclude the portion of code that operates command detection from the else-if statement that checks if invite detection is on, allowing commands to be used while the feature is disabled.
if (!message.content.toLowerCase().startsWith(prefix)) return;
const args = message.content.substring(prefix.length).split(' ');
const command =
client.commands.get(args[0].toLowerCase()) ||
client.commands.find(
(cmd) => cmd.aliases && cmd.aliases.includes(args[0].toLowerCase())
);
if (!command) return;
try
command.execute(message, args, client);
catch(err)
console.log(err)
const errorEmbed = new MessageEmbed()
.setColor('RED')
.setDescription('**<:xmark:763662710130737152> There was an error, please report it in my [support server](https://discord.gg/q4dunRn).**\n\n' + `\`$err\``)
message.channel.send(errorEmbed)
//Remove this bracket, as it is unnecessary once you add an additional closing bracket as suggested above. This bracket originally closed the else-if statement that only ran when invite detection was enabled
另外,为避免将来出现这种情况(如果您还没有这样做),您可以使用 IDE 来查看代码块的两个括号的位置,这样您就可以更轻松地解决此类问题未来。
希望我能帮上忙!
【讨论】:
以上是关于禁用自动调节时机器人没有响应的主要内容,如果未能解决你的问题,请参考以下文章
打开子窗口,想让父窗口蒙上一层半透明灰色的层,这个怎么做? 相当于窗口禁用或者没有响应的那种效果。
在没有UrlScan的情况下删除/隐藏/禁用Azure / IIS7中过多的HTTP响应标头