Androz2091 / discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
https://discord-giveaways.js.org
MIT License
333 stars 128 forks source link

Error at the end of the giveaway. #33

Closed Jujugin closed 4 years ago

Jujugin commented 4 years ago

Hello, I installed the module as well as the code everything works well I launch the giveaway everything works well but at the end or its must choose the winner and well its said to me in the embed of the giveaway: "Giveaway canceled, no valid participations . " I who thought it was because there were not enough participants I did a test on my server and 10 people participated but its made the same mistake.

I really need help!

The code seems to work really well and developed but this error means that I cannot use it.

Thank you for your help

(I translated on google translation because I'm French maybe there is an error in the translation)

SoulHarsh007 commented 4 years ago

Are you using the latest version of the package?

Jujugin commented 4 years ago

@SoulHarsh007 I used the documentation (https://www.npmjs.com/package/discord-giveaways) by taking all the codes well but at the end of the giveaway it puts me this error "Giveaway canceled, no valid participations."

Here is my code:

`const Discord = require("discord.js"), client = new Discord.Client(), settings = { prefix: "g!", token: "my token" };

// Requires Manager from discord-giveaways const { GiveawaysManager } = require("discord-giveaways"); // Starts updating currents giveaways const manager = new GiveawaysManager(client, { storage: "./giveaways.json", updateCountdownEvery: 5000, default: { botsCanWin: false, exemptPermissions: [ "MANAGE_MESSAGES", "ADMINISTRATOR" ], embedColor: "#FF0000", reaction: "🎉" } });

client.on("message", (message) => {

const ms = require("ms"); // npm install ms
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();

if(command === "start-giveaway"){
    // g!start-giveaway 2d 1 Awesome prize!
    // will create a giveaway with a duration of two days, with one winner and the prize will be "Awesome prize!"

    client.giveawaysManager.start(message.channel, {
        time: ms(args[0]),
        prize: args.slice(2).join(" "),
        winnerCount: parseInt(args[1])
    }).then((gData) => {
        console.log(gData); // {...} (messageid, end date and more)
    });
    // And the giveaway has started!
}

});

client.on("message", (message) => {

    const ms = require("ms"); // npm install ms
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();

    if(command === "reroll"){
        let messageID = args[0];
        client.giveawaysManager.reroll(messageID).then(() => {
            message.channel.send("Success! Giveaway rerolled!");
        }).catch((err) => {
            message.channel.send("No giveaway found for "+messageID+", please check and try again");
        });
    }

});

client.on("message", (message) => {

    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();

    if(command === "edit"){
        let messageID = args[0];
        client.giveawaysManager.edit(messageID, {
            newWinnerCount: 3,
            newPrize: "New Prize!",
            addTime: 5000
        }).then(() => {
            message.channel.send("Success! Giveaway will updated in less than "+(manager.updateCountdownEvery/1000)+" seconds.");
        }).catch((err) => {
            message.channel.send("No giveaway found for "+messageID+", please check and try again");
        });
    }

});

client.on("message", (message) => {

    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();

    if(command === "delete"){
        let messageID = args[0];
        client.giveawaysManager.delete(messageID).then(() => {
            message.channel.send("Success! Giveaway deleted!");
        }).catch((err) => {
            message.channel.send("No giveaway found for "+messageID+", please check and try again");
        });
    }

});

// We now have a giveawaysManager property to access the manager everywhere! client.giveawaysManager = manager;

client.on("ready", () => { console.log("I'm ready !"); });

client.login(settings.token);`

Androz2091 commented 4 years ago

@Jujugin are you sure that the people who reacted doesn't have the manage messages permissions?

Jujugin commented 4 years ago

@Androz2091 I managed to get the error, it's this:

function Error () {[native code]}

Androz2091 commented 4 years ago

What do you mean? Did you see my question? https://github.com/Androz2091/discord-giveaways/issues/33#issuecomment-593121076

Jujugin commented 4 years ago

yes, I made a giveaway on my server of +100 members so I believe that there must be 1 who had the permissions ...

Androz2091 commented 4 years ago

I wanted to know if there was at least one member who doesn't have the member. If I well understood, yes.

Also, did you use a custom reaction?

Jujugin commented 4 years ago

no i use the basic reaction

Androz2091 commented 4 years ago

All right, and what Discord.js version are you using? (run npm list to know)

Jujugin commented 4 years ago

discord.js@11.6.1

Jujugin commented 4 years ago

vous êtes français ?

Jujugin commented 4 years ago

GITHUB GIVEAWAY BUG Peut-être que c'est a cause de ça

Maybe it's because of that

Androz2091 commented 4 years ago

Oui, je n'avais pas lu que tu avais utilisé google trad. Normalement ça ne devrait pas poser de problèmes. Tu n'utilises que les commandes de giveaways dans ton bot ?

Jujugin commented 4 years ago

oui je n'utilise que les commande de giveaway car avant de l'incruster dans mon bot principal je voulais voir si sa marchait.

Androz2091 commented 4 years ago

D'accord, et tu n'as aucune erreur dans la console?

Jujugin commented 4 years ago

non 0 erreur juste dans le chat

Androz2091 commented 4 years ago

C'est étrange... Tu peux réessayer comme ça ?

const manager = new GiveawaysManager(client, {
    storage: "./giveaways.json",
    updateCountdownEvery: 5000,
    default: {
        botsCanWin: true,
        exemptPermissions: [],
        embedColor: "#FF0000",
        reaction: "🎉"
    }
});
Jujugin commented 4 years ago

Merci sa marche ! Je vous en remercie ! D'ailleurs j'ai regarder votre github et j'ai été bluffé vraiment ! Bravo d'avoir quelqu'un qui s'y connaisse vraiment et qui partagent son code ! Merci ! Sinon j'ai une question est-ce que les commandes ont une verification de permissions déjà créer ? Ou je doit le faire moi même.

Androz2091 commented 4 years ago

Parfait 👍 Tu dois ajouter toi-même les permissions que tu veux. Tu peux regarder ce bot pour exemple: https://github.com/Androz2091/giveaways-bot