1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 00:10:58 -05:00

fix perms ?bug?

This commit is contained in:
toast-ts 2022-11-26 19:52:43 +11:00
parent 5908ae5631
commit addf4573c9

View File

@ -3,11 +3,11 @@ import { TClient } from '../client';
export default { export default {
name: 'roleUpdate', name: 'roleUpdate',
execute: async(client:TClient, oldRole:Discord.Role, newRole:Discord.Role)=>{ execute: async(client:TClient, oldRole:Discord.Role, newRole:Discord.Role)=>{
if (oldRole.guild?.id != client.config.mainServer.id) return;
const fetchRoleUpdoot = await client.guilds.cache.get(oldRole.guild.id).fetchAuditLogs({ const fetchRoleUpdoot = await client.guilds.cache.get(oldRole.guild.id).fetchAuditLogs({
limit: 1, limit: 1,
type: AuditLogEvent.RoleUpdate type: AuditLogEvent.RoleUpdate
}) })
if (oldRole.guild?.id != client.config.mainServer.id) return;
const roleLog = fetchRoleUpdoot.entries.first(); const roleLog = fetchRoleUpdoot.entries.first();
if (!roleLog) return if (!roleLog) return
const {executor, target} = roleLog; const {executor, target} = roleLog;
@ -22,8 +22,8 @@ export default {
embed.addFields({name: '🔹 Role changes', value: `**Old color:** ${oldRole.hexColor}\n**New color:** ${newRole.hexColor}`}) embed.addFields({name: '🔹 Role changes', value: `**Old color:** ${oldRole.hexColor}\n**New color:** ${newRole.hexColor}`})
} else if (oldRole.name !== newRole.name) { } else if (oldRole.name !== newRole.name) {
embed.addFields({name: '🔹 Role changes', value: `**Old name:** ${oldRole.name}\n**New name:** ${newRole.name}`}) embed.addFields({name: '🔹 Role changes', value: `**Old name:** ${oldRole.name}\n**New name:** ${newRole.name}`})
} else if (oldRole.permissions !== newRole.permissions) { } else if (!oldRole.permissions.equals(newRole.permissions)) {
embed.addFields({name: '🔹 Role changes', value: `**Old permission(s):** ${newRole.permissions.missing(oldRole.permissions)}\n**New permission(s):** ${oldRole.permissions.missing(newRole.permissions)}`}) embed.addFields({name: '🔹 Role changes', value: `**Old permission(s):** ${newRole.permissions.missing(oldRole.permissions).join(', ')}\n**New permission(s):** ${oldRole.permissions.missing(newRole.permissions).join(', ')}`})
} }
} else { } else {
console.log(`${target.id} was modified from ${client.guilds.cache.get(oldRole.guild.name)} but no audit log could be fetched.`) console.log(`${target.id} was modified from ${client.guilds.cache.get(oldRole.guild.name)} but no audit log could be fetched.`)