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

154
Visualizações
setNickname is not including spaces in discord.js v13

When I set someone's nickname for example Stack Overflow", It does not set It correctly. It sets my nickname to "stackoverflow", Without spaces.

My code:

const { MessageEmbed } = require('discord.js');
module.exports = {
    name: 'changenickname',
    aliases: ['changenick'],
    permissions: ["MANAGE_NICKNAMES"],
    cooldown: 5,
    description: "change your target's nickname",
    usage: "d!changenickname <@user> <nickname>",
    async execute(message, args, cmd, client, Discord, profileData){
        const target = message.mentions.members.first();
        const nickname = args.slice(1).join('');
        if(!target) return message.channel.send('Please specify a target to change nickname');
        if(!nickname) return message.channel.send('Please specify a nickname to change');
        if (member.roles.highest.position >= message.guild.me.roles.highest.position) return message.reply('I cannot moderate this user as their highest role is higher than mine or I have the same highest role position as them.')


        target.setNickname(nickname);
        const done = new MessageEmbed()
        .setColor("GREEN")
        .setTitle("✅ Done")
        .setDescription(`Changed <@${target.id}> nickname to ${nickname}`)
        .setTimestamp()
        message.channel.send({embeds: [done]})
    }
}

Note: The command sets the nickname without any error, but it must set the nicknames with spaces(if there were in args).

I am using discord.js v13 and node.js v16

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

At line 11 you have this:

const nickname = args.slice(1).join('');

In your case args.slice(1) returns the array ['The', 'God']. The join() method takes every element of the array and puts it together in one string with the given string between every element. The string you gave to the function is '', so it will put the elements together without anything between it. So from the array ['The', 'God'] it makes the string TheGod instead of The God.

So what you would need is .join(' '), not .join('').

I hope that helps.

about 4 years ago · Juan Pablo Isaza 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