Here is my code
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('Ping')
.setDescription('Return my ping'),
async execute(interaction, client) {
const message = await interaction.deferReply({
fetchReply : true
});
const newMessage = `API Latency: ${client.ws.ping}\nClient Ping: ${message.createdTimestamp - interaction.createdTimestamp}`
await interaction.editReply({
content: newMessage
});
}
}
And here is the console error
C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@sapphire\shapeshift\dist\index.js:1564
return regex.test(input) ? Result.ok(input) : Result.err(new ExpectedConstraintError(type, "Invalid string format", input, expected));
^
ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@sapphire\shapeshift\dist\index.js:1564:64)
at C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@sapphire\shapeshift\dist\index.js:142:66
at Array.reduce (<anonymous>)
at StringValidator.parse (C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@sapphire\shapeshift\dist\index.js:142:29)
at validateName (C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@discordjs\builders\dist\index.js:782:17)
at MixedClass.setName (C:\Users\The Friesen Boy's\Desktop\georgebot\node_modules\@discordjs\builders\dist\index.js:856:5)
at Object.<anonymous> (C:\Users\The Friesen Boy's\Desktop\georgebot\src\commands\tools\ping.js:5:10)
at Module._compile (node:internal/modules/cjs/loader:1120:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
at Module.load (node:internal/modules/cjs/loader:998:32) {
constraint: 's.string.regex',
given: 'Ping',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}
Node.js v18.6.0
Does anyone know a fix to this? I could not find an answer. There is one other thread on this subject and it didn't fix my issue.
According to stack trace, 'Ping' seems to be an invalid command name. Have you tried using 'ping' (lowercase) as stated in the docs?
new SlashCommandBuilder().setName('ping')