Bozai Ákos
Bozai Ákos

Reputation: 55

Reactions in Discord.js

I just updated my djs bot from v11 to v12, and all commands are working, but one isn't. I have a vote command, if I type !vote 3, it reacts with 1,2,3. And it gives me back nothing. It deletes my message, but, it doesn't react and doesn't send the embed. In v11 it worked fine.

module.exports = {
    name: 'vote',
    description: 'Szavazás létrehozása',
    guildOnly: true,
    dmOnly: false,
    adminOnly: false,
    execute(message, args) {
        const channel = message.channel;
        if (!args[0]) {
            message.channel.send("Adj meg egy paramétert!");
        } else {

        const parameter = parseInt(args[0], 10);
        if (parameter > 10 || parameter < 0) {
            message.channel.send("Adj meg egy 0 és 10 közötti számot!");
            return;
        }
        message.delete({ timeout: 1 })
        .then (() => channel.fetchMessages({ limit: 1 }).then(messages => {
            let lastMessage = messages.first();
            if (lastMessage.member != message.member) {
                message.channel.send("Nem tőled származik az előző üzenet.");
            }
            
          
            if (!lastMessage.author.bot) {
                if (args[0] === "0") {
                    lastMessage.react('✅')
                    .then (() => lastMessage.react('❎'));
                }
                if (args[0] === "1") {
                    lastMessage.react('1️⃣')
                }
                if (args[0] === "2") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                }
                if (args[0] === "3") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                }
                if (args[0] === "4") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                }
                if (args[0] === "5") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                }
                if (args[0] === "6") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                    .then (() => lastMessage.react('6️⃣'))
                }
                if (args[0] === "7") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                    .then (() => lastMessage.react('6️⃣'))
                    .then (() => lastMessage.react('7️⃣'))
                }
                if (args[0] === "8") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                    .then (() => lastMessage.react('6️⃣'))
                    .then (() => lastMessage.react('7️⃣'))
                    .then (() => lastMessage.react('8️⃣'))
                }
                if (args[0] === "9") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                    .then (() => lastMessage.react('6️⃣'))
                    .then (() => lastMessage.react('7️⃣'))
                    .then (() => lastMessage.react('8️⃣'))
                    .then (() => lastMessage.react('9️⃣'))
                }
                if (args[0] === "10") {
                    lastMessage.react('1️⃣')
                    .then (() => lastMessage.react('2️⃣'))
                    .then (() => lastMessage.react('3️⃣'))
                    .then (() => lastMessage.react('4️⃣'))
                    .then (() => lastMessage.react('5️⃣'))
                    .then (() => lastMessage.react('6️⃣'))
                    .then (() => lastMessage.react('7️⃣'))
                    .then (() => lastMessage.react('8️⃣'))
                    .then (() => lastMessage.react('9️⃣'))
                    .then (() => lastMessage.react('🔟'))
                }
                
            }
          }))
          .then(() => {
          const Discord = require('discord.js');
          const confirm = new Discord.MessageEmbed()
          .setColor("GREEN")
          .setDescription("Szavazás létrehozva. Reagálj a megfelelő emojival a szavazáshoz!");
          message.channel.send({embed: confirm});
    }) ; }
}
}

Can you help me please?

Upvotes: 0

Views: 206

Answers (1)

Diamond
Diamond

Reputation: 122

First of all, please don't use if chains that could be replaced with a switch. If you still are going to use this at least change it to if/elseif

Heres the issue: message.channel.send({embed: confirm});

Change it to message.channel.send(confirm);

Upvotes: 1

Related Questions