#thread

1 messages · Page 1 of 1 (latest)

tawdry chasm
#

error

barren coyote
#

there is no way I'm gonna read that

tawdry chasm
#

see? its hell

#
 async setSlashPermissions() {
        const commands = await this.application.commands.fetch();

        for (const guild of this.guilds.cache.values()) {

            const fullPermissions = [];
            for (const { id, name } of commands.values()) {
                const { permissions: perms } = await this.commands.get(name);

                if (!perms) continue;

                let permissions = [];
                for (const perm of perms) {
                    const schema = await permissionSchema.findOne({ guildId: guild.id });

                    console.log(perm);

                    if (perm === "owner") {
                        permissions.push(
                            {
                                id: guild.ownerId,
                                type: 2,
                                permission: true
                            }
                        );
                    } else if (perm === "admin" && schema?.admin) {
                        permissions.push(
                            {
                                id: schema.admin,
                                type: 1,
                                permission: true
                            }
                        );
                    } else if (perm === "moderator" && schema?.moderator) {
                        permissions.push(
                            {
                                id: schema.moderator,
                                type: 1,
                                permission: true
                            }
                        );
                    }
                }

                fullPermissions.push({ id, permissions });
            }

            console.log(fullPermissions);

            await this.REST.put(
                Routes.guildApplicationCommandsPermissions(this.id, guild.id),
                { body: fullPermissions },
            );
        }
    }```
#

is how my permission handler looks like

barren coyote
#

line 8

tawdry chasm
#

it works fine and exactly as intended for my globals yet when i wanted to add a new command it wasnt loaded in

barren coyote
#

whats line 8 supposed to be

tawdry chasm
#

can u quote the line?

barren coyote
#

for (const { id, name } of commands.values()) {

#

whats commands

#

nvm I'm fucking blind

tawdry chasm
#

= await this.application.commands.fetch();

#

oh lol dwdw xd

barren coyote
#

I mean this.commands

tawdry chasm
#
loadCommands() {
        for (const file of sync("./commands/**/*.js")) {
            const command = require(`.${file}`);
            if (command.permissions) command.default_permission = false;
            this[command.guildOnly ? "guildCommands" : "globalCommands"].push(command);
            this.commands.set(command.name, command);
        }
    }
barren coyote
#

ic

tawdry chasm
#
 this.globalCommands = [];
        this.guildCommands = [];
        this.commands = new Collection();
barren coyote
#

and where did you get the error from that you sent me first?

tawdry chasm
#
            await this.REST.put(
                Routes.guildApplicationCommandsPermissions(this.id, guild.id),
                { body: fullPermissions },
            );```
#

which i don't understand

barren coyote
#

yes, I'm once again blind