Androz2091 / discord-giveaways

πŸŽ‰ Complete framework to facilitate the creation of giveaways using discord.js
https://discord-giveaways.js.org
MIT License
333 stars 127 forks source link

Support for more more winners? #36

Closed menix1337 closed 3 years ago

menix1337 commented 4 years ago

Is it possible to adjust the giveaway if the description embed char reaches 255 > it then possibly skips writing names into the embed description?

And eventually if hitting max limit numbers in the say text (where it prints the winners names in) make multiple messages with more names if you have more winners than maybe 20?

All of this to adjust it being able to support more than 20ish winners per giveaway? Cause currently it just doesn't roll if you have above 20-25 winners, since it hits the description char limit from embeds? (Whcih could be avoided with if limit (255) > don't paste into description & just list multiple messages with winner names) to automatic adjust for a 'x' amount of winners?

So if winners < 20 = it can update description to include winnner names.. If > 25, it doesn't upgrade the description with names - eventually just say (Winner(s) listed below) then print alot of rows with names.

Androz2091 commented 4 years ago

Yes, it will be added!

menix1337 commented 4 years ago

Yes, it will be added!

Would be awesome! I know many who uses it, and with discords with over 17.000 members its annoying having to host 4 seperate giveaways for like 70-100 Winners! ^^

I am aware of at least 10 servers myself who Could have use of it ^^

menix1337 commented 4 years ago

Also is there a way to define each Winners discord ids? Lets say you have 100 winners (when this fix is in place)

You reckon its possible to award all Winners with a Discord rank? Provided by the bot using script - automaticly from their mentions or something.. ids?

Androz2091 commented 4 years ago

@menix1337 You should use the giveawayEnded event. You will have access to an array of winners. You'll be able to do something like that:

giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
    winners.forEach((winner) => winner.roles.add("role ID"));
});

Also, can you send me your Discord server? It could help me to have an idea for how to fix your problems with large giveaways.

menix1337 commented 4 years ago

@menix1337 You should use the giveawayEnded event. You will have access to an array of winners. You'll be able to do something like that:

giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
    winners.forEach((winner) => winner.roles.add("role ID"));
});

Also, can you send me your Discord server? It could help me to have an idea for how to fix your problems with large giveaways.

Sure, how would I go about to invite? - or you want the link here? I can easily toss up a test giveaway so you get the idea of the massive amount of people signing into it :D

Androz2091 commented 4 years ago

Yes, you can send the link here.

menix1337 commented 4 years ago

Yes, you can send the link here.

Discord.gg/Asura

I am named MENIX on right side. Let me know on discord in DMs when you’re (or we both) are around and I can start a test giveaway using the script here & you can have an idea of it!

menix1337 commented 4 years ago

@menix1337 You should use the giveawayEnded event. You will have access to an array of winners. You'll be able to do something like that:

giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
    winners.forEach((winner) => winner.roles.add("role ID"));
});

Also, can you send me your Discord server? It could help me to have an idea for how to fix your problems with large giveaways.

manager.on("giveawayEnded", async (giveaway, winners) => {
    const roleCheck = await giveaway.message.guild.roles.cache.find(r => r.name === "GiveawayWinners");
    if (roleCheck) {
        console.log("Found GiveawayWinners role")
        winners.forEach(winner => giveaway.message.guild.member(winner).roles.add(roleCheck.id))
    } 

    if (!roleCheck) {
        console.log("Created GiveawayWinners role")
    const role = await giveaway.message.guild.roles.create({ data: { name: "GiveawayWinners" } });
    winners.forEach(winner => giveaway.message.guild.member(winner).roles.add(role.id))
    }
});

Is the solution for that

menix1337 commented 3 years ago

Any updates on the initial request yet - since you've been working on it back then? @Androz2091 Not sure if you ever got around to fix this (undocumented?)

Androz2091 commented 3 years ago

No, honestly I didn't keep working on this feature. It's still something that's planned, but I can't tell you when it will be added...

Nico105 commented 3 years ago

πŸŽ‰ v4.5.0 is now released!

menix1337 commented 3 years ago

This is awesome!

I wanna give some feedback to you guys, its been 2 years under way.

So i did a test with a 100 winners: https://i.imgur.com/A7XlwK2.png (Reacting) & https://i.imgur.com/bPOApQW.png (Done)

It worked so floorless, its amazing.

Then i tried to see if i could do a test with 300 winners: https://i.imgur.com/vwcZmis.png (Reacting) & https://i.imgur.com/bPOApQW.png (Done)

Out from 300 winners, it still only picked a 100 actually.

Is there a cap on a 100 winners? and is it possible to up this even higher? Theres enough embed space, thats for sure - because look at this here

https://i.imgur.com/5CNSWTC.png

The first message event is well filled out, however the second message event only has like 10 users or so, and could of course handle much more.

Anyhow, i know this is something hard to do - and its been underway for ages.

Thank you so much @Nico105 @Androz2091 .

Edit: I see in your initial test you have 170 more winners, i am just wondering why this is stuck on 100 then (both for either 100 or 300 winners).

I'm using just the default json file - 1 server total, and i wouldn't believe that should cap?

menix1337 commented 3 years ago

giveaways.zip Heres a copy of the giveaways.json zip file containing both of these giveaways.

Nico105 commented 3 years ago

The 100 limit is because default fetch() value (for the reactions) is 100, but you cannot increase it, because it would be API spam or smth. But you can fetch the other users in 100 steps because you can use a option to define the last ID you fetched because data from discord is sorted by ID. #254 would try to do that but I couldn't test it because you would need actual people for testing because you need different IDs as mentioned. You can try to test it if you want and provide feedback but there could be ratelimit errors.

Nico105 commented 3 years ago

For my testing I had those 170 more winners because I pushed myself that many times manually into the winner Array

menix1337 commented 3 years ago

The 100 limit is because default fetch() value (for the reactions) is 100, but you cannot increase it, because it would be API spam or smth. But you can fetch the other users in 100 steps because you can use a option to define the last ID you fetched because data from discord is sorted by ID. #254 would try to do that but I couldn't test it because you would need actual people for testing because you need different IDs as mentioned. You can try to test it if you want and provide feedback but there could be ratelimit errors.

Should i just grab the pull request from that post - and toss another 300 users test up .. See what happens, and give feedback?

Nico105 commented 3 years ago

Yeah, that would be nice. But so just copy the changes and insert them manually since that pr doesn't have the split-messages system

menix1337 commented 3 years ago

Yeah, that would be nice. But so just copy the changes and insert them manually since that pr doesn't have the split-messages system

image

I have one going, expect an answer in 10 minutes times - I've just copied in the changes in Giveaway.js.

menix1337 commented 3 years ago

image image image

It works.. The embed itself looks a little finicky, however the long list of winning users prints out just fine! Bot printed no errors in console or anything.

To double check this, you see i have a script saying "adding roles to 300 users" - its because i have discord auto adding a role to all the winners in the giveaway - it takes toughly 6m 50s to add a role to 300 users because of API rate limits.

But it went through, it actually did work - all users got the roles as expected, i was able to add everyone points..

It actually worked.. I feel like this is a 2 year fight, a huge relief - a battle that has lasted so long towards making this work!

around 10 minutes after payout i looked at the embed again, and it looked like this image

I honestly would deem it approved - i could test with more, but i already pinged 24.000 users 4 times with giveaways within an hour, so i better stop before they get angry.

300 people, this pull request - 100% confirmed.. It might not be fully tested yet if it always will work, but it for sure did a (excuse my swearing) fucking great wonder.

You guys are litteral gods.

Nico105 commented 3 years ago

Thank you very much for testing.

and just to confirm, this: image Changed to image automatically after some time (10m), right?

If yes, then I will request Androz's review for the pr to see if he has any comment/improvement to make and I'll merge afterwards.

menix1337 commented 3 years ago

Thank you very much for testing.

and just to confirm, this: image Changed to image automatically after some time (10m), right?

If yes, then I will request Androz's review for the pr to see if he has any comment/improvement to make and I'll merge afterwards.

If exact 10 minutes - not 100% - But yes, it did change from <@90382948725> into an actual tag, yes - a bit after the giveaway was over, inside the embed.

menix1337 commented 3 years ago

image image

The final output

menix1337 commented 3 years ago

I'm at the point thinking it could probably even take more on - 300+ There was no issues at all doing it at 300, no delays, no crashes, no setbacks..

It was just smooth

Nico105 commented 3 years ago

πŸ‘ Great and thanks again, just inform me if anything strange happens somewhen.

menix1337 commented 3 years ago

πŸ‘ Great and thanks again, just inform me if anything strange happens somewhen.

Will do, its probably not something that will get spammed 24/7 and tested - but i will keep you guys aware in here through time.

Androz2091 commented 3 years ago

Hello @Nico105's PR seems to be the best way to support +100 reactions giveaways. I merged it, you can try to clone the develop branch.

Androz2091 commented 3 years ago

This has been added to v5. Run npm install discord-giveaways@latest to update!