#Cmd error

11 messages · Page 1 of 1 (latest)

rancid forgeBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by staff
twilit folio
#

const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('Review')
        .setDescription('Submit a review')
        .addUserOption(option => option.setName('designer').setDescription('Designer name').setRequired(true))
        .addStringOption(option => option.setName('product').setDescription('Product name').setRequired(true))
        .addStringOption(option => option.setName('feedback').setDescription('Please share your thoughts').setRequired(true))
        .addStringOption(option =>option.setName("rating").setDescription("Product rating (1-10)").addChoices(
            { name: "1/10", value: "1/10" },
            { name: "2/10", value: "2/10" },
            { name: "3/10", value: "3/10" },
            { name: "4/10", value: "4/10" },
            { name: "5/10", value: "5/10" },
            { name: "6/10", value: "6/10" },
            { name: "7/10", value: "7/10" },
            { name: "8/10", value: "8/10" },
            { name: "9/10", value: "9/10" },
            { name: "10/10", value: "10/10" }
        )
        .setRequired(true)),
 async execute(interaction) {
        try {
           
            const requiredRoleIdForReview = '1217193437917483240';
            const requiredRoleForReview = interaction.guild.roles.cache.get(requiredRoleIdForReview);
            if (!requiredRoleForReview || !interaction.member.roles.cache.has(requiredRoleForReview.id)) {
                return interaction.reply({ content: 'This feature is available to customers only.', ephemeral: false });
            }

         
            const designer = interaction.options.getUser('designer');
            const product = interaction.options.getString('product');
            const feedback = interaction.options.getString('feedback');
            const rating = interaction.options.getInteger('rating');
            
const embed = new EmbedBuilder()
                .setColor('#0280FC')
                .setAuthor({ name: `Review by ${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL() })
                .setTitle('New Review')
                .addFields(
                    { name: 'Designer', value: designer, inline: true },
                    { name: 'Product', value: product, inline: true },
                    { name: 'Rating', value: `${rating}/10`, inline: true },
                    { name: 'Feedback', value: feedback, inline: false }
                   
                .setTimestamp();

           
            const reviewChannel = interaction.client.channels.cache.get('1217193438735368337');
            if (!reviewChannel) {
                return interaction.reply({ content: 'Review channel not found.', ephemeral: true });
            }

            await reviewChannel.send({ embeds: [embed] });

           
            interaction.reply({ content: 'Review sent successfully! Thanks for your feedback.', ephemeral: true });
        } catch (error) {
             interaction.reply({ content: 'Error', ephemeral: true });
        }
    },
};
#

cmd

#


 return regex.test(input) ? Result.ok(input) : Result.err(new ExpectedConstraintError(type, "Invalid string format", input, expected));     
                                                               ^

ExpectedConstraintError: Invalid string format
    at Object.run (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2350:64)
    at D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:939:67
    at Array.reduce (<anonymous>)
    at _StringValidator.parse (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:939:29)      
    at validateName (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@discordjs\builders\dist\index.js:1581:17)
    at MixedClass.setName (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@discordjs\builders\dist\index.js:1677:5)
    at D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\src\commands\Community\tax.js:9:10
    at MixedClass._sharedAddOptionMethod (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@discordjs\builders\dist\index.js:2388:50)
    at MixedClass.addStringOption (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\node_modules\@discordjs\builders\dist\index.js:2360:17)
    at Object.<anonymous> (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\src\commands\Community\tax.js:8:6)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at client.handleCommands (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\src\functions\handelCommands.js:14:33)
    at D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\src\index.js:18:12
    at Object.<anonymous> (D:\scott bot\node_modules\pm2\lib\API\ExtraMgmt\src\index.js:20:3)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32) {
  constraint: 's.string.regex',
  given: 'Amount',
  expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}

#

error

twilit folio
rancid igloo
twilit folio
#

i try many times

#

and i just did 1 more time

rancid igloo
# twilit folio Its still same error

The above error is not from the code you sent, it gives error for Amount, check where that is, and correct it, slash command and it's options name cannot be uppercase and cannot have spaces