#Use .find(), .filter()

1 messages · Page 1 of 1 (latest)

kindred sluice
#

Doesn't work :/

    name: 'channelCreate',
    /**
     * 
     * @param {Channel} channel 
     * @param {Client} client 
     */
    async execute (channel, client) {
        const { guild } = channel;
        //ID OF THE PRINCIPAL SRV (string)
        const principal_guild = client.config.guild.principal;
        //ID OF THE LOG SRV (string)
        const log_guild = client.config.guild.logs;
        
        //DETECT THE CREATION OF A CHANNEL IN THE MAIN SRV
        if (channel.type === ChannelType.GuildText && guild.id === principal_guild){

            // zone where i crash
            await client.guilds.cache.get(log_guild).channels.find(c => c.name === channel.parent.name &&
                                       c.type === ChannelType.GuildCategory).then(async (category_find) => {
                console.log("CATEGORY FOUND");
                category_find.channels.create({
                    name: channel.name,
                    type: ChannelType.GuildText,
                    position: channel.position,
                    topic: channel.topic
                })
            })
        }