export const event = 'channelCreate'

export async function callback(client, channel) {
    try {
        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
        let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
        let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
        if (audit.executor.id == client.user.id) return;
        let emoji;
        let readableType;
        let displayName;
        switch (channel.type) {
            case 'GUILD_TEXT': {
                emoji = "CHANNEL.TEXT.CREATE";
                readableType = "Text";
                displayName = "Text Channel"
                break;
            }
            case 'GUILD_NEWS': {
                emoji = "CHANNEL.TEXT.CREATE";
                readableType = "Announcement";
                displayName = "Announcement Channel"
                break;
            }
            case 'GUILD_VOICE': {
                emoji = "CHANNEL.VOICE.CREATE";
                readableType = "Voice";
                displayName = "Voice Channel"
                break;
            }
            case 'GUILD_STAGE': {
                emoji = "CHANNEL.VOICE.CREATE";
                readableType = "Stage";
                displayName = "Stage Channel"
            }
            case 'GUILD_CATEGORY': {
                emoji = "CHANNEL.CATEGORY.CREATE";
                readableType = "Category";
                displayName = "Category"
                break;
            }
            default: {
                emoji = "CHANNEL.TEXT.CREATE";
                readableType = "Channel";
                displayName = "Channel"
            }
        }
        let data = {
            meta: {
                type: 'channelCreate',
                displayName: displayName + ' Created',
                calculateType: 'channelUpdate',
                color: NucleusColors.green,
                emoji: emoji,
                timestamp: channel.createdTimestamp
            },
            list: {
                channelId: entry(channel.id, `\`${channel.id}\``),
                name: entry(channel.name, renderChannel(channel)),
                type: entry(channel.type, readableType),
                category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
                created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
            },
            hidden: {
                guild: channel.guild.id
            }
        }
        log(data);
    } catch {}
}
