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}>` },
question from:
https://stackoverflow.com/questions/66052814/discord-js-bot-wont-specify-mention-the-channel-in-logs 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…