【问题标题】:Discord.js V12 how to remove mentions from a messageDiscord.js V12 如何从消息中删除提及
【发布时间】:2021-07-26 23:36:23
【问题描述】:

我有一个用discord.js 制作的不和谐机器人,我想制作一个*say 命令。 但是,当我写 @everyone 或角色 ID (<@&542542636743557>) 时,机器人也会提到它。 有没有办法用@no 或其他东西代替这些提及? 这是我的代码:

if (!args[1]) return msg.channel.send("I can't send an empty message!");
args.shift();
msg.channel.send(args.join(' '));

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    您可以使用Util.cleanContent()

    const { Util } = require('discord.js')
    
    message.channel.send(Util.cleanContent(message.content, message))
    
    message: 'Hello @everyone and @Anunay!'
    cleanMessage: 'Hello @everyone and @Anunay!' // looks the same, but doesn't ping
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      • 2021-05-12
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 2020-12-27
      • 2021-09-14
      相关资源
      最近更新 更多