2021-10-08 23:58:57 +00:00
|
|
|
module.exports = {
|
|
|
|
|
2023-03-19 09:46:57 +00:00
|
|
|
description: 'Reroll a giveaway',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'giveaway',
|
|
|
|
description: 'The giveaway to reroll (message ID or prize)',
|
|
|
|
type: 'STRING',
|
|
|
|
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: ':x: You need to have the manage messages permissions to reroll giveaways.',
|
|
|
|
ephemeral: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const query = interaction.options.getString('giveaway');
|
|
|
|
|
|
|
|
// try to found the giveaway with prize then with ID
|
|
|
|
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
|
|
|
|
if (!giveaway) {
|
|
|
|
return interaction.reply({
|
|
|
|
content: 'Unable to find a giveaway for `'+ query +'`.',
|
|
|
|
ephemeral: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!giveaway.ended) {
|
|
|
|
return interaction.reply({
|
|
|
|
content: 'The giveaway is not ended yet.',
|
|
|
|
ephemeral: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reroll the giveaway
|
|
|
|
client.giveawaysManager.reroll(giveaway.messageId)
|
|
|
|
.then(() => {
|
|
|
|
// Success message
|
|
|
|
interaction.reply('Giveaway rerolled!');
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
interaction.reply({
|
|
|
|
content: e,
|
|
|
|
ephemeral: true
|
|
|
|
});
|
|
|
|
});
|
2022-12-02 08:54:36 +00:00
|
|
|
|
2021-10-08 23:58:57 +00:00
|
|
|
}
|
2021-10-09 07:31:19 +00:00
|
|
|
};
|