Closed TheDogHusky closed 2 years ago
giveaway data does not get deleted by default.
you have to use the endedGiveawaysLifetime
manager option.
for the "coult not get edited" error tho, I will have to investigate more
" but the error for the auto end it" "it gets error after trying to delete it a the end time." => Ending aborted because giveaway with
could you describe the things you did to get a this a bit more (precisely)?
So, i try to end the giveaway with the command, first, it's supposed to reply after and i just get an interaction failed then the giveaways stops. After, the package tries to delete it manually but it gets this error. Code of the end.js command:
module.exports = {
name: "end",
description: '🎉 Mettre fin à un giveaway déjà lancé',
options: [
{
name: 'giveaway',
description: 'Mettre fin au giveaway (message ID ou prix du giveaway)',
type: 3,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:Non_:844228495542452296> **Vous devez disposer des autorisations de gestion des messages pour terminer des giveaways.**',
ephemeral: true
});
}
const query = interaction.options.getString('giveaway');
// fetching the giveaway with message Id or prize
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find((g) => g.prize === query && g.guildId === interaction.guild.id) ||
// Search with giveaway Id
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
// If no giveaway was found with the corresponding input
if (!giveaway) {
return interaction.reply({
content: 'Impossible de trouver un giveaway pour `' + query + '`.',
ephemeral: true
});
}
if (giveaway.ended) {
return interaction.reply({
content: 'Ce giveaway est déjà terminé !',
ephemeral: true
});
}
// Edit the giveaway
client.giveawaysManager.end(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply(`**[Ce giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) à été terminé !**`);
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true
});
});
}
};
and for the ednedGiveawayLifetime it's ms passed or something else?
and for the ednedGiveawayLifetime it's ms passed or something else?
ms yeah
huh.. I passed 10000 as parameter (10s) and after 10 seconds the document doesn't get deleted
Any ideas?
I found the issue
The giveaway isn't marked as ended and doesn't get deleted. I found it while debugging and logging every giveaway on the _checkGiveaways() function. The ended property doesn't get updated. Still ended: false.
@Nico105 need to patch that
if it would be that easy could you provide your discord.js client options?
Here you are:
const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS] });
@Nico105 ?
@Nico105, so what’s the problem? I need to fix it fast so I can publish a mongo version of a certified bot, it’s really important.
So, i try to end the giveaway with the command, first, it's supposed to reply after and i just get an interaction failed then the giveaways stops. After, the package tries to delete it manually but it gets this error. Code of the end.js command:
module.exports = { name: "end", description: '🎉 Mettre fin à un giveaway déjà lancé', options: [ { name: 'giveaway', description: 'Mettre fin au giveaway (message ID ou prix du giveaway)', type: 3, required: true } ], run: async (client, interaction) => { // If the member doesn't have enough permissions if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) { return interaction.reply({ content: '<:Non_:844228495542452296> **Vous devez disposer des autorisations de gestion des messages pour terminer des giveaways.**', ephemeral: true }); } const query = interaction.options.getString('giveaway'); // fetching the giveaway with message Id or prize const giveaway = // Search with giveaway prize client.giveawaysManager.giveaways.find((g) => g.prize === query && g.guildId === interaction.guild.id) || // Search with giveaway Id client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id); // If no giveaway was found with the corresponding input if (!giveaway) { return interaction.reply({ content: 'Impossible de trouver un giveaway pour `' + query + '`.', ephemeral: true }); } if (giveaway.ended) { return interaction.reply({ content: 'Ce giveaway est déjà terminé !', ephemeral: true }); } // Edit the giveaway client.giveawaysManager.end(giveaway.messageId) // Success message .then(() => { // Success message interaction.reply(`**[Ce giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) à été terminé !**`); }) .catch((e) => { interaction.reply({ content: e, ephemeral: true }); }); } };
Instead of using the .end() function, try using the .edit() function and set the end timestamp parameter to the current date. Example:
client.giveawaysManager.edit(giveaway.messageId, {
setEndTimestamp: Date.now()
})
@Nico105 ?
try updating to the latest version
you guys should add a feature that after a set amount of time, ended giveaways will get permanently deleted from the db
you guys should add a feature that after a set amount of time, ended giveaways will get permanently deleted from the db
that feature exist: endedGiveawaysLifeTime
ah, i didnt notice lol
Thank you very much, it's finally solved with the new Update.