Discord Mod Logging (MemberBanRemove)

cant seem to get this to work
client.on("guildBanRemove", async (guild, user) => {
const entry = await guild.fetchAuditLogs().then(audit => audit.entries.first());

let embed = new EmbedBuilder()
.setThumbnail(entry.executor.avatarURL({ dynamic: true }))
.setDescription(
`**${user.username}**(\`${user.id}\`) has been unbanned.\n\n Unbanned by : **<@${entry.executor.id}>**(\`${entry.executor.id}\`)`
)
.setColor("#E70000")
.setTimestamp();

client.channels.cache.get(MOD_CHANNEL).send({ embeds: [embed] });
});
client.on("guildBanRemove", async (guild, user) => {
const entry = await guild.fetchAuditLogs().then(audit => audit.entries.first());

let embed = new EmbedBuilder()
.setThumbnail(entry.executor.avatarURL({ dynamic: true }))
.setDescription(
`**${user.username}**(\`${user.id}\`) has been unbanned.\n\n Unbanned by : **<@${entry.executor.id}>**(\`${entry.executor.id}\`)`
)
.setColor("#E70000")
.setTimestamp();

client.channels.cache.get(MOD_CHANNEL).send({ embeds: [embed] });
});
ive also tried adding type/actiontype 23 to the fetchAuditLogs, tried adding catch for errors and to log them in the console, havent gotten anywhere tho unfortunatly
5 Replies
d.js toolkit
d.js toolkit2w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Mark
Mark2w ago
why not use the guildAuditLogEntryCreate event instead?
ItzYaBoiRampage
ItzYaBoiRampageOP2w ago
iirc I tried that as well and wasn’t able to get anything either
Mark
Mark2w ago
tried it how? show your intents and the code you tried
ItzYaBoiRampage
ItzYaBoiRampageOP2w ago
sorry for the late response i had work this morning, heres what i got to work for now
client.on(Events.GuildBanRemove, async (ban) => {
const { guild, user } = ban;

const entry = await guild.fetchAuditLogs({
limit: 1,
type: AuditLogEvent.MemberBanRemove,
}).then(audit => audit.entries.first());

if (!entry || !entry.executor) return;

let embed = new EmbedBuilder()
.setDescription(
`**${user.username}** (\`${user.id}\`) has been unbanned.\n\nUnbanned by **<@${entry.executor.id}>** (\`${entry.executor.id}\`)`
)
.setThumbnail(entry.executor.displayAvatarURL({ dynamic: true }))
.setColor("#E70000")
.setTimestamp();

const modChannel = client.channels.cache.get(MOD_CHANNEL);
if (modChannel) {
modChannel.send({ embeds: [embed] });
}
});
client.on(Events.GuildBanRemove, async (ban) => {
const { guild, user } = ban;

const entry = await guild.fetchAuditLogs({
limit: 1,
type: AuditLogEvent.MemberBanRemove,
}).then(audit => audit.entries.first());

if (!entry || !entry.executor) return;

let embed = new EmbedBuilder()
.setDescription(
`**${user.username}** (\`${user.id}\`) has been unbanned.\n\nUnbanned by **<@${entry.executor.id}>** (\`${entry.executor.id}\`)`
)
.setThumbnail(entry.executor.displayAvatarURL({ dynamic: true }))
.setColor("#E70000")
.setTimestamp();

const modChannel = client.channels.cache.get(MOD_CHANNEL);
if (modChannel) {
modChannel.send({ embeds: [embed] });
}
});
going to try some other ways tho but atleast it works if you could could you create an example of this, i cant find the bit i used but im pretty sure i remember trying that last night
Want results from more Discord servers?
Add your server