Androz2091 / discord-giveaways

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

Suggestion: Add support for mongodb #127

Closed wolfier74 closed 3 years ago

wolfier74 commented 3 years ago

Hello, can you please create option to use mongodb database as storage for giveaways? This would be useful, json files are sometimes buggy, when more values are saved there.

Another suggestion: Auto remove giveaway from database after 30 days when it ended. I think that nobody will edit or reroll 30 days old giveaway. Its just spamming database.

Nico105 commented 3 years ago

If you want to use mongodb then go to the bottom of #90, it works, it uses quickmongo, a mongoDB wrapper, and you can add the after 30 days deletion yourself if you want with just checking on startup or every day when on runtime and doing Array.forEach but I agree that it would be a nice utility to add to the module itself somewhen

wolfier74 commented 3 years ago

Ok, the mongo is working. Can you please send me code how to delete giveaways older than 30 days on ready event?

Nico105 commented 3 years ago

client.giveawaysManager.giveaways.filter(g => g.ended && Date.now() - g.endAt >= ms('30d')).forEach(g => client.giveawaysManager.deleteGiveaway(g.messageID)) But for real you should really take a look at the docs or the README if you want to work with this module if you have to ask for module code...

wolfier74 commented 3 years ago

Ty, it will delete giveaway data from database or also the giveaway embed from discord?

wolfier74 commented 3 years ago

Also how can i send DM "Giveaway entry for {giveaway message id} was confirmed" to member who joined giveaway?

Nico105 commented 3 years ago

deleteGiveaway() only deletes from DB, delete() would delete message too/you can choose if message should get deleted or not. For DM, use the giveawayReactionAdded event: https://discord-giveaways.js.org/ just look at the docs, you can add it to your code like you added discord.js events If that's all then please close this issue again cause its currently more of a "ask for how to code" conversation and not a issue anymore. If you need further CODE help then go to the official support server and don't ask it here.