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

197
Visualizações
Discord.js Slash command mention user

Ive been trying to figure out how to get my hug command to mention both the sender and the recipient of the command. As well as when you start the command it'll ask for the sender to select someone to mention before the command is sent off (or is that built in? I don't know yet)

I have read over the docs of the user class and as well as read this post here but have come to the conclusion that both aren't using slash commands though which is what ive been taught of how to do, not using embeds or text for the commands, just a slash command. If there is any help to this that would be greatly appreciated! Here's my resulting code so far though

const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('hug')
        .setDescription('Hug Someone'),
    async execute(interaction) {
        return interaction.reply(`${user} hugs ${user}`)
    },
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can get the author of the Interaction using the Interaction#user property.

To specify a User to hug you'll have to add a SlashCommandUserOption.

You can then get the User by using CommandInteractionOptionResolver#getUser

module.exports = {
    data: new SlashCommandBuilder()
        .setName('hug')
        .setDescription('Hug Someone')
        .addUserOption(option =>
            option
                .setName('user')
                .setDescription('The user you want to hug')
                .setRequired(true)
        ),
    async execute(interaction) {
        return interaction.reply(`${interaction.user} hugs ${interaction.options.getUser('user')}`)
    },
};
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