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



我有这样的代码,当有人在服务器上标记一个重要用户(不应该标记的用户(时,它会向服务器管理员和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}`);
}
});

首先需要获取通道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}`)
}
});```

最新更新