【问题标题】:How do I make my command not mention the user?如何让我的命令不提及用户?
【发布时间】:2021-08-05 14:25:59
【问题描述】:

我刚开始编写我的 Discord 机器人,我做了一个命令来回复不是由机器人发送的每条消息。当我在 DM 中尝试它时,它工作正常,但是当我在我的服务器中尝试它时,它会在命令之前提到用户。在 DM 中它只会说“测试”,但在服务器中会说类似“@ExampleUser, test”。

有什么办法可以解决这个问题吗?这是我的代码:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on("message", (message) => {
  if (message.author.bot) return; 
  return message.reply("test") 
});

【问题讨论】:

    标签: javascript node.js discord discord.js bots


    【解决方案1】:

    使用message.channel.send('test') 代替message.reply('test') 将消息发送到原始消息发送到的通道。

    【讨论】:

      【解决方案2】:

      解决方案

      使用message.channel.send('string'); 代替.reply()

      【讨论】:

      • 第一个是正确的,但您的方法二与问题无关,因为如果 OP 使用 reply() 方法,使用选项 disableMentions: "all" 仍将显示“@ExampleUser, test”。
      • 别担心,@EJBEAN ;)
      【解决方案3】:

      这很容易:)

      不用说message.reply('message'),你只需说message.channel.send('message')

      【讨论】:

        猜你喜欢
        • 2021-12-07
        • 2021-04-13
        • 1970-01-01
        • 2019-04-16
        • 2021-05-25
        • 2019-11-19
        • 2019-12-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多