【问题标题】:How to make my bot not say @everyone, @here or @mention如何让我的机器人不说@everyone、@here 或@mention
【发布时间】:2020-12-10 11:24:21
【问题描述】:

我正在为我的机器人发出一个说命令,但我如何让它不说@everyone、@here 或@提及

例如: !说@每个人 机器人会说 @everyone which ping 我如何让它不 ping?

代码:

var arg= message.content.split(" ").slice(1).join(" ")
if(!arg){
message.channel.send('What do you want me to say?')
} else
message.channel.send (arg)

【问题讨论】:

    标签: discord bots discord.js


    【解决方案1】:

    找到一个更简单的方法:

    const Util = require('./node_modules/discord.js/src/util/Util.js');
    const msg = Util.removeMentions(arg);
    message.channel.send(msg);
    

    参考:here

    【讨论】:

      【解决方案2】:

      试试这个:

      const newMessage = arg.replace(/<@[!&]?\d+>/, '[mention]');
      

      【讨论】:

      • 好的,适用于@提及但不适用于@所有人,@这里请帮助谢谢@Lioness100
      【解决方案3】:

      var arg= message.content.split(" ").slice(1).join(" ") 替换为var arg= message.cleanContent.split(" ").slice(1).join(" ")

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-10-15
        • 1970-01-01
        • 2020-09-12
        • 2021-06-08
        • 2019-10-03
        • 2020-06-20
        • 1970-01-01
        相关资源
        最近更新 更多