#thread
1 messages · Page 1 of 1 (latest)
there is no way I'm gonna read that
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
line 8
it works fine and exactly as intended for my globals yet when i wanted to add a new command it wasnt loaded in
whats line 8 supposed to be
can u quote the line?
for (const { id, name } of commands.values()) {
whats commands
nvm I'm fucking blind
I mean this.commands
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);
}
}
ic
this.globalCommands = [];
this.guildCommands = [];
this.commands = new Collection();
and where did you get the error from that you sent me first?