discord.js - 在 2 条用户消息之前删除机器人消息
问题描述
就我所知,javascript 仍然含糊不清,我无法准确说明我制作的以下代码的敏感性。我正在编写一个不和谐的机器人,它将消息分类为各种渠道,这个问题让我想到了如何通过在机器人消息之后发送 2 条用户消息后删除后续机器人消息来对机器人进行编程。
if (bot.on(client, user.msg = '2'));{
msg.channel('message' = msg.delete)
}
需要帮助,我希望我的查询在我所暗示的上下文中是有意义的,问候,编码器
PS:如何更改机器人消息文本颜色?
解决方案
无意冒犯,但您的代码完全错误,所以我只是编写了一些新代码。
bot.on('message', aysnc message => {
var messagenumber = 0; //Makes variable for the number of messages sent
if(message.member.user.username === bot.user.username) return; //If the person who posts a message is the bot, it doesn't the code below.
if(messagenumber = 1) return bulkDelete(100), messagenumber = 0 //Checks if the variable is 1, and if it is, this means it's the second time a message posted, so it deletes messages (Limit is 100) then resets variable.
messagenumber = 1; //Makes variable 1 (This is to make it know it is the the second time a message is posted for the next time).
});
我没有测试此代码,因此它可能无法正常工作,但如果它确实有效,我希望它对您的机器人有所帮助。
对于 PS(更改文本颜色):您可以使用这些(将“NoKeyWordsHere”替换为您的消息)。我不建议这样做,因为将其添加到发送的每条消息中都需要很长时间。(你也可以在你的消息中使用这些)
推荐阅读
- android - 在 Android Studio 中构建一开始不起作用
- python - OSError: [Errno 27] 文件太大 idk 为什么
- graphviz - 为 Dot 中的子图强制不同等级(graphviz)
- debezium - 如何使用 debezium 捕获 postgresql 新表数据更改事件?
- javascript - 如何在 Ember.js 中执行顺序 for 循环?
- ios - 在 Grid Swift 中打开图像的 OnClick/OnTap 视图
- python - IDA Pro 如何将地址与符号相关联
- python - 如何动态更新 PyQt 条形图?
- mysql - 根据另一个表中的状态更新 MYSQL 表列
- php - 我想在我的 css 文件中添加一个带有 laravel URL 的背景图像。我可以通过仅包含路径来做到这一点?