How Can I make something like this?

As above
No description
4 Replies
d.js toolkit
d.js toolkit14mo 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!
kamulek
kamulekOP14mo ago
And is this correct?
client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
const channel = await client.channels.fetch(logsChannel);
if (!channel) return;

const createOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteCreate});
const updateOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteUpdate});
const deleteOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteDelete});

const createEntry = createOverwriteChannelAuditLog.entries.first();
const updateEntry = updateOverwriteChannelAuditLog.entries.first();
const deleteEntry = deleteOverwriteChannelAuditLog.entries.first();
});
client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
const channel = await client.channels.fetch(logsChannel);
if (!channel) return;

const createOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteCreate});
const updateOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteUpdate});
const deleteOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteDelete});

const createEntry = createOverwriteChannelAuditLog.entries.first();
const updateEntry = updateOverwriteChannelAuditLog.entries.first();
const deleteEntry = deleteOverwriteChannelAuditLog.entries.first();
});
ShompiFlen
ShompiFlen14mo ago
that just looks like a regular embed you shouldn't need to do this client.channels.fetch(logsChannel); if (!channel) return; since channels are cached on start if you have the guilds intent It depends on which information you want to show on the embed, can't help further since i can't see the relation between fetching audit logs and channel / role permissions (which are the ones showing on the image)
kamulek
kamulekOP14mo ago
Hey! So i like do something like this:
client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
const channel = client.channels.cache.get(logsChannel);
if (!channel) return;

const createOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteCreate });
const updateOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteUpdate });
const deleteOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteDelete });

const createEntry = createOverwriteChannelAuditLog.entries.first();
const updateEntry = updateOverwriteChannelAuditLog.entries.first();
const deleteEntry = deleteOverwriteChannelAuditLog.entries.first();

const message = new EmbedBuilder()
.setTitle('Channel Update')
.setDescription(`**Channel name changed from ${oldChannel.name} to ${newChannel.name}`)
.setColor('Green')
if (createEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override created')
.setDescription(`**Event Type:** ${createEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${createEntry.target} **New permissions:** ${PermissionsBitField.Flags.createEntry.overwrite.permissions} **Moderator:** ${createEntry.executor.toString()}`)
.setColor('Green');
channel.send(message);
}

if (updateEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override updated')
.setDescription(`**Event Type:** ${updateEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${updateEntry.target} **Old permissions:** ${Permissions.FLAGS[updateEntry.overwrite.old_permissions]} **New permissions:** ${Permissions.FLAGS[updateEntry.overwrite.permissions]} **Moderator:** ${updateEntry.executor.toString()}`)
.setColor('Yellow');
channel.send(message);
}

if (deleteEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override removed')
.setDescription(`**Event Type:** ${deleteEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${deleteEntry.target} **Moderator:** ${deleteEntry.executor.toString()}`)
.setColor('Red');
channel.send(message);
}
});
client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
const channel = client.channels.cache.get(logsChannel);
if (!channel) return;

const createOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteCreate });
const updateOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteUpdate });
const deleteOverwriteChannelAuditLog = await newChannel.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.ChannelOverwriteDelete });

const createEntry = createOverwriteChannelAuditLog.entries.first();
const updateEntry = updateOverwriteChannelAuditLog.entries.first();
const deleteEntry = deleteOverwriteChannelAuditLog.entries.first();

const message = new EmbedBuilder()
.setTitle('Channel Update')
.setDescription(`**Channel name changed from ${oldChannel.name} to ${newChannel.name}`)
.setColor('Green')
if (createEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override created')
.setDescription(`**Event Type:** ${createEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${createEntry.target} **New permissions:** ${PermissionsBitField.Flags.createEntry.overwrite.permissions} **Moderator:** ${createEntry.executor.toString()}`)
.setColor('Green');
channel.send(message);
}

if (updateEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override updated')
.setDescription(`**Event Type:** ${updateEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${updateEntry.target} **Old permissions:** ${Permissions.FLAGS[updateEntry.overwrite.old_permissions]} **New permissions:** ${Permissions.FLAGS[updateEntry.overwrite.permissions]} **Moderator:** ${updateEntry.executor.toString()}`)
.setColor('Yellow');
channel.send(message);
}

if (deleteEntry) {
const message = new EmbedBuilder()
.setTitle('Channel permission override removed')
.setDescription(`**Event Type:** ${deleteEntry.action} **Channel:** ${oldChannel.name} **Role or user:** ${deleteEntry.target} **Moderator:** ${deleteEntry.executor.toString()}`)
.setColor('Red');
channel.send(message);
}
});
So i use fetchAuditLogs to send a message in embed, which will contain a Moderator mention (the person who edited it) Hm.. Okay, how can I solve this in the simplest way? I'm sorry, but I am beginner and i use AI (like bard or chatgpt) to help, so this explains why some properties don't exist I prefer the cheapest way, but.. I don't known how to catch properly event of channel Owerwriting. What should I do?
Want results from more Discord servers?
Add your server