import getEmojiByName from "../utils/getEmojiByName.js";

export const event = 'roleDelete'

export async function callback(client, role) {
    try {
        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
        if (role.managed) return;
        let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
        let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
        if (audit.executor.id === client.user.id) return;
        let data = {
            meta: {
                type: 'roleDelete',
                displayName: 'Role Deleted',
                calculateType: 'guildRoleUpdate',
                color: NucleusColors.red,
                emoji: "GUILD.ROLES.DELETE",
                timestamp: audit.createdTimestamp,
            },
            list: {
                roleId: entry(role.id, `\`${role.id}\``),
                role: entry(role.name, role.name),
                color: entry(role.hexColor, `\`${role.hexColor}\``),
                showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
                mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
                members: entry(role.members.size, `${role.members.size}`),
                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
            },
            hidden: {
                guild: role.guild.id
            }
        }
        log(data);
    } catch {}
}
