#i dont understand why my commands defaultPermission false doesnt lock my command in guild server
1 messages · Page 1 of 1 (latest)
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 });
the result of full permission looks like this ```js
[
{
name: 'clear',
description: 'removes a specified amount of messages',
defaultPermission: false,
permissions: [ [Object] ],
options: [ [Object] ],
execute: [AsyncFunction: execute]
},
]
why doesnt this work?
this should work. but my command's default permission isn't registered
how do you deploy your commands?
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);
}
}
this is being loaded before the registration of my slash commands
how is this.guildCommands defined?
this.guildCommands = [];
and what do you push inside?
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));
}
so just the object you defined
yes!
np lol
discord dev docs
ohh im going to take a closer look at that next time