Arcane_ish
Arcane_ish
DIAdiscord.js - Imagine an app
Created by Arcane_ish on 6/23/2023 in #djs-questions
Can't read default_member_permissions from SlashCommandBuilder?
I'm building a script that documents slash command attributes for a wiki page. I have a wrapper class that holds command attributes that aren't directly used by the SlashCommandBuilder (eg cooldown, execute function). Strangely, the default_member_permissions is readable inside the class, but not outside the wrapper. For a more concrete exmaple, here's the wrapper constructor:
...
this.data = new SlashCommandBuilder()
.setName(customIdInput)
.setDescription(descriptionInput)
.setDefaultMemberPermissions(PermissionFlagsBits.ViewChannel)
.setDMPermission(allowInDMsInput);
console.log("inside wrapper", this.data);
...
...
this.data = new SlashCommandBuilder()
.setName(customIdInput)
.setDescription(descriptionInput)
.setDefaultMemberPermissions(PermissionFlagsBits.ViewChannel)
.setDMPermission(allowInDMsInput);
console.log("inside wrapper", this.data);
...
In the console.log, this shows default_member_permissions: '1024',. However, this differs from when it gets logged outside the wrapper class.
module.exports = new CommandWrapper(customId, "Get a link to BountyBot's commands page", PermissionFlagsBits.ViewChannel, false, true, 3000, options, subcommands,
/** Link the user to the repo Commands wiki page (automatically updated) */
(interaction) => {
interaction.reply({ content: "Here's a link to the BountyBot Commands page (automatically updated): https://github.com/Imaginary-Horizons-Productions/BountyBot/wiki/Commands", ephemeral: true });
}
);

console.log("outside wrapper", module.exports);
module.exports = new CommandWrapper(customId, "Get a link to BountyBot's commands page", PermissionFlagsBits.ViewChannel, false, true, 3000, options, subcommands,
/** Link the user to the repo Commands wiki page (automatically updated) */
(interaction) => {
interaction.reply({ content: "Here's a link to the BountyBot Commands page (automatically updated): https://github.com/Imaginary-Horizons-Productions/BountyBot/wiki/Commands", ephemeral: true });
}
);

console.log("outside wrapper", module.exports);
This ends up logging default_member_permissions: undefined,. This seems especially problematic since my command uploader reads the default member permission in the same way, which would likely mean that attribute is getting stripped before getting uploaded. Am I missing something about how exporting might affect SlashCommandBuilders? Bonus: any recommendations on converting from a permission bit field back to a human readable list of permissions?
9 replies