ig
DIAdiscord.js - Imagine an app
•Created by ig on 7/20/2023 in #djs-questions
How to make SlashCommand Args
Okay thank you
6 replies
DIAdiscord.js - Imagine an app
•Created by ig on 7/20/2023 in #djs-questions
How to make SlashCommand Args
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('DeleteMessages')
.setDescription('Deletes the past messages of a specified amount.')
.addIntegerOption((option) => {
option.setName("Amount")
.setDescription("How many messages to delete.")
.setRequired(true) // error here
}),
async execute(interaction) {
interaction.channel.bulkDelete(interaction.options.getInteger("amount"))
await interaction.reply('Done!');
},
};
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('DeleteMessages')
.setDescription('Deletes the past messages of a specified amount.')
.addIntegerOption((option) => {
option.setName("Amount")
.setDescription("How many messages to delete.")
.setRequired(true) // error here
}),
async execute(interaction) {
interaction.channel.bulkDelete(interaction.options.getInteger("amount"))
await interaction.reply('Done!');
},
};
C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:47
throw this.error;
^
ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:1592:64)
at C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:212:66
at Array.reduce (<anonymous>)
at StringValidator.parse (C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:212:29)
at validateName (C:\Users\jorde\source\repos\mybot\node_modules\@discordjs\builders\dist\index.js:1402:17)
at MixedClass.setName (C:\Users\jorde\source\repos\mybot\node_modules\@discordjs\builders\dist\index.js:1499:5)
at Object.<anonymous> (C:\Users\jorde\source\repos\mybot\commands\testing\deleteMessages.js:5:10)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
constraint: 's.string.regex',
given: 'DeleteMessages',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}
C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:47
throw this.error;
^
ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:1592:64)
at C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:212:66
at Array.reduce (<anonymous>)
at StringValidator.parse (C:\Users\jorde\source\repos\mybot\node_modules\@sapphire\shapeshift\dist\index.js:212:29)
at validateName (C:\Users\jorde\source\repos\mybot\node_modules\@discordjs\builders\dist\index.js:1402:17)
at MixedClass.setName (C:\Users\jorde\source\repos\mybot\node_modules\@discordjs\builders\dist\index.js:1499:5)
at Object.<anonymous> (C:\Users\jorde\source\repos\mybot\commands\testing\deleteMessages.js:5:10)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
constraint: 's.string.regex',
given: 'DeleteMessages',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}
6 replies