如何将此消息发送到另一个特定频道?

Posted

技术标签:

【中文标题】如何将此消息发送到另一个特定频道?【英文标题】:How do I send this message to another specific channel? 【发布时间】:2021-12-31 04:41:31 【问题描述】:

我有这段代码,当有人在服务器上标记一个重要用户(不应该被标记的用户)时,它会向服务器管理员和 mods 做广告。

这是代码。

client.on('messageCreate', message => 
    if(message.author.bot || message.channel.type === `DM`) return;

    if(message.mentions.members.get(`332599069027598336`))
        message.reply(`The user $message.author has mentioned $message.mentions.members.get(`332599069027598336`).user.tag`);
    
);

【问题讨论】:

这个问题有帮助吗:***.com/questions/52258064/…? 【参考方案1】:

首先您需要获取频道 ID。 client.channels.cache.get('YOUR_CHANNEL_ID')

然后您将其发送到特定频道。 .send(`The user $message.author has mentioned $message.mentions.members.get(`332599069027598336`).user.tag`)

你的代码应该是这样的:

client.on('messageCreate', message => 
    if(message.author.bot || message.channel.type === `DM`) return;

    if(message.mentions.members.get(`332599069027598336`)) 
        client.channels.cache.get('YOUR_CHANNEL_ID').send(`The user $message.author has mentioned $message.mentions.members.get(`332599069027598336`).user.tag`)
    
);```

【讨论】:

以上是关于如何将此消息发送到另一个特定频道?的主要内容,如果未能解决你的问题,请参考以下文章