提前2条用户消息后删除bot消息

时间:2019-11-29 02:48:14

标签: discord.js

JavaScript对我来说仍然是模糊的,在我编写的以下代码中,我无法精确地确定其敏感性。我正在编程一个不和谐的bot,该机器人将消息分类为各种渠道,这个问题使我想到了如何通过在bot消息之后随后发送2条用户消息后删除后续的bot消息来对bot进行编程。

if (bot.on(client, user.msg = '2'));{
    msg.channel('message' = msg.delete)
}

需要帮助,我希望我所暗示的情况下我的查询有意义,致谢,编码器

P.S:我还如何更改漫游器消息文本的颜色?

1 个答案:

答案 0 :(得分:0)

没有冒犯,但是您的代码是完全错误的,所以我刚刚编写了一些新代码。

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(更改文本颜色):您可以使用these(用消息替换“ NoKeyWordsHere”)。我不建议这样做,因为将其添加到发送的每条消息中都需要花费很长时间。 (您也可以在邮件中使用它们)