wtfnotavailable / Discord-MusicBot

Discord Music Bot Source Tree
Other
179 stars 84 forks source link

Fix syntax error in guildleave.js #224

Closed gspxrk closed 7 months ago

gspxrk commented 7 months ago

i fix code

LewdHuTao commented 7 months ago

i was dumb for merged this pr and not check them properly, actually the code was fine

try {
            const id = interaction.options.getString('id');

            if (id.toLowerCase() === 'list') {
                try {
                    const guildList = client.guilds.cache.map(guild => `${guild.name} | ${guild.id}`).join('\n');
                    return interaction.reply({ content: `Guilds:\n\`${guildList}\``, ephemeral: true });
                } catch (error) {
                    console.error('Error listing guilds:', error);
                    return interaction.reply({ content: `Check console for list of guilds`, ephemeral: true });
                }
            }

            const guild = client.guilds.cache.get(id);
            if (!guild) {
                return interaction.reply({ content: `\`${id}\` is not a valid guild ID`, ephemeral: true });
            }
                try {
            await guild.leave();
            return interaction.reply({ content: `Left guild \`${id}\``, ephemeral: true });
        } catch (error) {
            console.error(`There was an error trying to leave guild ${id}:`, error);
            return interaction.reply({ content: `Error leaving guild.`, ephemeral: true });
        }

there is already try { at the top so adding another one broke the code

LewdHuTao commented 7 months ago

if you get an error from this command then send the log here

DarrenOfficial commented 7 months ago

When you forgot to review code moment