Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.2K
Visualizações
Discord.JS Slash Command Error: "ExpectedConstraintError: Invalid string format"

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.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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')
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda