#i dont understand why my commands defaultPermission false doesnt lock my command in guild server

1 messages · Page 1 of 1 (latest)

jolly plinth
#
module.exports = {
    name: "clear",
    description: "removes a specified amount of messages",
    defaultPermission: false,
    permissions: [
        {
            id: "806714620605628426",
            type: 1,
            permission: true
        }
    ],
    options: [
        {
            name: "number",
            description: "sepcift an amount of messages to be removed",
            type: 10,
            required: true
        }
    ],

    async execute(client, interaction) {
        const amount = interaction.options.getNumber("number", true);

        if (amount < 1) {
            interaction.reply({ content: "specified amount cannot be negative", ephemeral: true });

            return;
        }

        if (amount > 100) {
            interaction.reply({ content: "specified amount cannot be greater than 100", ephemeral: true });

            return;
        }

        await interaction.channel.bulkDelete(amount, true);

        interaction.reply({ content: `i have deleted \`${amount}\` messages`, ephemeral: true });
    },
};```
#

is how the code looks like

#

of the command i'm trying to lock for everyone

#

this is how i fill in the fullPermission array

#
        const commands = await this.guilds.cache.get(this.GUILD_ID).commands.fetch();

        const fullPermissions = [];

        for (const [id, command] of this.commands) {
            for (const cmd of commands.values()) {
                if (cmd.name === command.name) {
                    if (!command.permissions) continue;
                    cmd.defaultPermission = false;
                    fullPermissions.push(
                        {
                            id: cmd.id,
                            permissions: command.permissions,
                        }
                    );
                }
            }
        }

        this.guilds.cache.get(this.GUILD_ID).commands.permissions.set({ fullPermissions });
jolly plinth
#

why doesnt this work?

#

this should work. but my command's default permission isn't registered

maiden bramble
#

how do you deploy your commands?

jolly plinth
#
    async registerSlashCommands() {
        try {
            await this.REST.put(Routes.applicationGuildCommands(this.CLIENT_ID, this.GUILD_ID), { body: this.guildCommands });
            console.log("registered application slash commands");
        } catch (error) {
            console.error(error);
        }
    }
jolly plinth
maiden bramble
#

how is this.guildCommands defined?

jolly plinth
#

this.guildCommands = [];

maiden bramble
#

and what do you push inside?

jolly plinth
#

    loadCommand(commandName) {
        try {
            const command = require(`.${commandName}`);
            this.guildCommands.push(command);
            this.commands.set(command.name, command);
        } catch (error) {
            console.error(error);
        }
    }

    loadEvent(eventName) {
        const { name, execute } = require(`.${eventName}`);
        this.on(name, (...args) => execute(this, ...args));
    }
maiden bramble
#

so just the object you defined

jolly plinth
#

yes!

maiden bramble
#

rest needs raw discord objects

#

change defaultPermission to default_permission

jolly plinth
#

thank you

#

so much

#

i love you

maiden bramble
#

np lol

jolly plinth
#

it worked!

#

is there any docs behind this?

maiden bramble
#

discord dev docs

jolly plinth
#

ohh im going to take a closer look at that next time