[英]Discord.js - Bot won't specify/mention the channel in logs
When attempting to create a "purge" command, I wish to make it delete messages, as well as log the action within a specified log channel.尝试创建“清除”命令时,我希望使其删除消息,并在指定的日志通道中记录该操作。 However, the log won't specify the channel the command was executed within, and I am unsure how to make it mention the channel.
但是,日志不会指定执行命令的通道,我不确定如何让它提及通道。
This is what I have:这就是我所拥有的:
if (command === 'purge') {
if (
!message.member.roles.cache.some((r) => ['Indian Mod'].includes(r.name))
)
return message.reply('not high enough perms ``(MOD PERMS)``');
let member = message.mentions.members.first();
const channel11 = client.channels.cache.find(
(channel) => channel.id === 'id',
);
const deleteCount = parseInt(args[0], 10);
if (!deleteCount || deleteCount < 2 || deleteCount > 100)
return message.reply(
'Please provide a number between 2 and 100 for the number of messages to delete',
);
channel = message.guild.channels.cache.get('channelID');
const fetched = await message.channel.messages.fetch({
limit: deleteCount,
});
message.channel
.bulkDelete(fetched)
.catch((error) =>
message.reply(`Couldn't delete messages because of: ${error}`),
);
const embedmessagep = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('Purge Command Executed')
.setTimestamp()
.setFooter('DM me with any inquiries regarding bot API')
.addFields(
{ name: `Channel:`, value: `<\#${message.guild.id}>` },
{ name: `Moderator:`, value: `${message.author.tag}` },
{ name: `Number Deleted:`, value: `${deleteCount}` },
);
channel11.send(embedmessagep);
}
The line in which the issue occurs is within the embed:发生问题的行在嵌入中:
{ name: `Channel:`, value: `<\#${message.guild.id}>` },
message.guild.id
is the server ID, not the channel ID. message.guild.id
是服务器 ID,而不是频道 ID。 Did you mean message.channel.id
?你的意思是
message.channel.id
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.