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

314
Visualizações
Awaiting reactions accepts the bot and the addressee, not the author of the command

I'm trying to create a discord bot, and I'm writing the command "marry".

It is already essentially ready, from the main thing I want the confirmation of the wedding to be not a yes/no message, but a click on the reaction.

Now everything works, when entering a command, the user who clicks and responds to the proposal to marry, but not with the one who wrote the command, but with the bot.

That is, it works for me now that the author of the message (ie, a bot) and the one to whom the proposal is addressed are getting married. And it is necessary that the one who wrote the command and the user to whom it is addressed get married.

How can I fix this?

Here is my function awaitReactions:

(`Are you ready to get married?`).then(message => {
      message.react('👍').then(() => message.react('👎'));
    

      message.awaitReactions((reaction, user) => user.id == userToMarry.id && (reaction.emoji.name == '👍' || reaction.emoji.name == '👎'),
        { max: 1, time: 60000, errors: ['time'] })
      .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === '👎') {
      return message.channel.send('I think **no**...')}
    if (reaction.emoji.name === '👍') {
      db.set(message.author.id, { user: message.author.id, partner: userToMarry.id });
      db.set(userToMarry.id, { user: userToMarry.id, partner: message.author.id });
    message.channel.send(`${message.author} and ${userToMarry} now married!!`)
      .catch(err => {
        message.channel.send(
          `Something went wrong while trying to marry this user. ${err}`
        );
        return console.log(err)});
      }
  })
  .catch(collected => {
        message.reply('You reacted with neither a thumbs up, nor a thumbs down.');
    });
});

Full command code

const { Command } = require('discord.js-commando');
const db = require("quick.db");


module.exports = class MarryCommand extends Command {
  constructor(client) {
    super(client, {
      name: 'marry',
      memberName: 'marry',
      group: 'test',
      description: 'Marry the mentioned user',
      guildOnly: true,
      args: [
        {
          key: 'userToMarry',
          prompt: 'Please select the member you wish to marry.',
          type: 'member'
        }
      ]
    });
  }

  run(message, { userToMarry }) {
    const exists = db.get(`${message.author.id}.user`);
    const married = db.get(`${userToMarry.id}.user`);
    if (!userToMarry) {
      return message.channel.send('Please try again with a valid user.')}
    if (exists == message.author.id) {
      return message.channel.send('You are already married!')}
    if (married == userToMarry.id) {
      return message.channel.send('This user is already married!')}
    if (userToMarry.id == message.author.id) {
      return message.channel.send('You cannot marry yourself!');
    }
    if (exists != message.author.id && married != userToMarry.id) {
    message.channel.send(`**Important announcement!**
    
    ${message.author} makes a marriage proposal ${userToMarry}
    
    Are you ready to get married?`).then(message => {
      message.react('👍').then(() => message.react('👎'));
    

      message.awaitReactions((reaction, user) => user.id == userToMarry.id && (reaction.emoji.name == '👍' || reaction.emoji.name == '👎'),
        { max: 1, time: 60000, errors: ['time'] })
      .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === '👎') {
      return message.channel.send('I think **no**...')}
    if (reaction.emoji.name === '👍') {
      db.set(message.author.id, { user: message.author.id, partner: userToMarry.id });
      db.set(userToMarry.id, { user: userToMarry.id, partner: message.author.id });
    message.channel.send(`${message.author} and ${userToMarry} now married!!`)
      .catch(err => {
        message.channel.send(
          `Something went wrong while trying to marry this user. ${err}`
        );
        return console.log(err)});
      }
  })
  .catch(collected => {
        message.reply('You reacted with neither a thumbs up, nor a thumbs down.');
    });
});
}}};
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try like this

.then(message => {
      message.react('👍').then(() => message.react('👎'));
    

      message.awaitReactions((reaction, user) => user.id == userToMarry.id && (reaction.emoji.name == '👍' || reaction.emoji.name == '👎'),
        { max: 1, time: 60000, errors: ['time'] })
      .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === '👎') {
      return message.channel.send('I think **no**...')}
    if (reaction.emoji.name === '👍') {
      db.set(message.author.id, { user: message.author.id, partner: userToMarry.id });
      db.set(userToMarry.id, { user: userToMarry.id, partner: message.author.id });
    message.channel.send(`${message.author} and ${userToMarry} now married!!`)
 
    ...

  });
});
over 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