这是密码-
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());第二行是试图连接到文件- /commands/hi.js
这就是hi.js所包含的内容
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('Hi')
.setDescription('Get introduced to the bot'),
async execute(interaction) {
await interaction.reply('Hi I am Herote bot I was created by a Dog names barood /help for commands');
},
};这就是错误
throw this.error;
^
ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\ranja\Desktop\Discord bot\node_modules\@sapphire\shapeshift\dist\index.js:1549:64)
at C:\Users\ranja\Desktop\Discord bot\node_modules\@sapphire\shapeshift\dist\index.js:113:66
at Array.reduce (<anonymous>)
at StringValidator.parse (C:\Users\ranja\Desktop\Discord bot\node_modules\@sapphire\shapeshift\dist\index.js:113:29)
at validateName (C:\Users\ranja\Desktop\Discord bot\node_modules\@discordjs\builders\dist\index.js:819:17)
at MixedClass.setName (C:\Users\ranja\Desktop\Discord bot\node_modules\@discordjs\builders\dist\index.js:895:5)
at Object.<anonymous> (C:\Users\ranja\Desktop\Discord bot\commands\Hi.js:5:4)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32) {
constraint: 's.string.regex',
given: 'Hi',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}它应该只是运行应用程序后,连接,但我得到了这个错误。我正在使用Node.js/npm模块/Discord.js的最新版本
发布于 2022-11-13 12:49:49
您获得此特定错误的原因是您试图将命令名大写为大写,而使用斜杠命令是不可能的。另外,还需要注意的是,您也不能大写命令选项。
只需将其改为:
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('hi')
.setDescription('Get introduced to the bot'),
async execute(interaction) {
await interaction.reply('Hi I am Herote bot I was created by a Dog names barood /help for commands');
},
};https://stackoverflow.com/questions/74420563
复制相似问题