#Role Creator Command Not Working

8 messages · Page 1 of 1 (latest)

thorn marlin
#

Hey All,

Apologies if this is really simple... new to JS/discord bot dev stuff (day7),

I have a command that has most of this in it already that works & creates the role etc, but when I try it as a standalone it doesn't work?

const { SlashCommandBuilder, ChannelType, Colors, PermissionFlagsBits} = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('rolecreator.js')
        .setDescription('Create Nils Role Template'),
    async execute(interaction) {
        // Get guild from interaction, shorthands future calls
        const GUILD = interaction.guild;

        try {

            // Check if Test Role1 exists, if not create

            let TEST1_ROLE = GUILD.roles.cache.find(role => role.name === 'Test1 Role');

            if (!TEST1_ROLE) {
                TEST1_ROLE = await GUILD.roles.create({
                    name: 'Test1 Role',
                    color: Colors.Green,
                    reason: 'Automatically created by NilBot',
                });
            }

            interaction.reply({ content: "Command Success! Roles created.", ephemeral: true });

        }
        catch (err) {
            console.error(err)
            interaction.reply({ content: "Something went wrong with this command. Please check that the bot has the appropriate permissions to perform this action.\nIf this error persists, please contact the bot administrator.", ephemeral: true });
        }
    },
};```
dawn veldt
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

thorn marlin
#

js 14.7.1
node 19.7.0

#
/Users/abismith/Downloads/nilbot/node_modules/@sapphire/shapeshift/dist/index.js:41
    throw this.error;
    ^

ExpectedConstraintError: Invalid string format
    at Object.run (/Users/abismith/Downloads/nilbot/node_modules/@sapphire/shapeshift/dist/index.js:1582:64)
    at /Users/abismith/Downloads/nilbot/node_modules/@sapphire/shapeshift/dist/index.js:201:66
    at Array.reduce (<anonymous>)
    at StringValidator.parse (/Users/abismith/Downloads/nilbot/node_modules/@sapphire/shapeshift/dist/index.js:201:29)
    at validateName (/Users/abismith/Downloads/nilbot/node_modules/@discordjs/builders/dist/index.js:903:17)
    at MixedClass.setName (/Users/abismith/Downloads/nilbot/node_modules/@discordjs/builders/dist/index.js:979:5)
    at Object.<anonymous> (/Users/abismith/Downloads/nilbot/commands/rolecreator.js:5:4)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32) {
  constraint: 's.string.regex',
  given: 'rolecreator.js',
  expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}```
#

This is the error I'm being faced with

brave glacier
#

Seems like the error is coming from

@sapphire/shapeshift
thorn marlin
#

ignore my stupid stupid stupid stupid stupid dumb ass

#

it's because I has a . in the cmd name