blob: 0c6d03e372133a7a369c34338c204308017d40ac [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001import getEmojiByName from "../utils/getEmojiByName.js";
2
3export const event = 'roleDelete'
4
5export async function callback(client, role) {
6 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
7 let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
8 let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
9 if (audit.executor.id == client.user.id) return;
10 let data = {
11 meta: {
12 type: 'roleDelete',
13 displayName: 'Role Deleted',
14 calculateType: 'guildRoleUpdate',
15 color: NucleusColors.red,
16 emoji: "GUILD.ROLES.DELETE",
17 timestamp: audit.createdTimestamp,
18 },
19 list: {
20 id: entry(role.id, `\`${role.id}\``),
21 role: entry(role.name, role.name),
22 color: entry(role.hexColor, `\`${role.hexColor}\``),
23 showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
24 mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
25 members: entry(role.members.size, `${role.members.size}`),
26 deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
27 created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
28 deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
29 },
30 hidden: {
31 guild: role.guild.id
32 }
33 }
34 log(data, client);
35}