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

189
Visualizações
How do I make a command give the first mention a role with the ID "973182673306660885"

I have tried this but somehow "msg.mentions.users.first.addRole is not a function"

let BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
  const FMT = msg.mentions.users.first();

if (msg.content.startsWith('$BotBan')) {
    if (FMT === undefined) {
      msg.reply('Did not detect user')
    return; // Do not proceed, there is no user.
  }
  const FM = FMT.username;
  // Do stuff with the username
    msg.mentions.users.first.addRole(BotBanRole);
    msg.reply('Bot Banned ' + FM.tag)
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

let BotBanRole = msg.guild.roles.cache.get("973182673306660885");
const FMT = msg.mentions.members.first();

if (msg.content.startsWith('$BotBan')) {
    if (!msg.mentions.members.first()) {
      msg.reply('Did not detect user')
    return; // Do not proceed, there is no user.
  }
  const FM = FMT.user;
  // Do stuff with the username
    FMT.roles.add(BotBanRole);
    msg.reply('Bot Banned ' + FM.tag)
}

I edited your code and if it's v13, it works like this.

about 4 years ago · Juan Pablo Isaza Relatório

0

You were pretty close, give this a try.

const BotBanRole = msg.guild.roles.cache.find(r => r.id === "973182673306660885");
const FMT = msg.mentions.members.first();

if (msg.content.startsWith('$BotBan')) {
    if (!FMT) {
        msg.reply('Did not detect user')
        return;
    } else {
        FMT.roles.add(BotBanRole);
        msg.reply(`Bot Banned ${FMT.user.username}`)
    }
}
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