Fixed commands
This commit is contained in:
parent
75c6d307de
commit
ad53371b3d
4 changed files with 39 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ node_modules
|
|||
package-lock.json
|
||||
giveaways.js
|
||||
config.json
|
||||
giveaways.json
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
|
||||
options: [
|
||||
{
|
||||
name: 'Winners',
|
||||
name: 'winners',
|
||||
description: 'How many winners the giveaway should have',
|
||||
type: 'INTEGER',
|
||||
required: true
|
||||
|
@ -41,14 +41,14 @@ module.exports = {
|
|||
|
||||
if(!giveawayChannel.isText()) {
|
||||
return interaction.reply({
|
||||
content: ':x: Selected channel; is not text-based.',
|
||||
content: ':x: Selected channel is not text-based.',
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
// Start the giveaway
|
||||
client.giveawaysManager.start(giveawayChannel, {
|
||||
// The number of winners for this frop
|
||||
// The number of winners for this drop
|
||||
winnerCount: giveawayWinnerCount,
|
||||
// The prize of the giveaway
|
||||
prize: giveawayPrize,
|
||||
|
@ -61,5 +61,6 @@ module.exports = {
|
|||
});
|
||||
|
||||
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,36 +1,38 @@
|
|||
const ms = require('ms');
|
||||
const messages = require('../utils/messages');
|
||||
|
||||
module.exports = {
|
||||
description: 'End a Giveaway',
|
||||
|
||||
description: 'End a giveaway',
|
||||
|
||||
options: [
|
||||
{
|
||||
name: 'giveaway',
|
||||
description: 'The giveaway to end (message ID or Giveaway prize.)',
|
||||
description: 'The giveaway to end (message ID or giveaway prize)',
|
||||
type: 'STRING',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
|
||||
run: async (client, interaction) => {
|
||||
// If the member does not have enough permissions
|
||||
if(!interaction.member.permission.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")){
|
||||
|
||||
// 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 ot end giveaways.`,
|
||||
content: ':x: You need to have the manage messages permissions to end giveaways.',
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
const query = interaction.options.getString('giveaway');
|
||||
|
||||
// try to find the giveaway with prize then with ID
|
||||
// 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 === messages.guild.id) ||
|
||||
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 === messages.guild.id);
|
||||
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
|
||||
|
||||
//if no giveaway was found
|
||||
// If no giveaway was found
|
||||
if (!giveaway) {
|
||||
return interaction.reply({
|
||||
content: 'Unable to find a giveaway for `'+ query + '`.',
|
||||
|
@ -38,18 +40,26 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
if (giveaway.ended) {
|
||||
return interaction.reply({
|
||||
content: 'This giveaway is already ended.',
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
// Edit the giveaway
|
||||
client.giveawaysManager.end(giveaway.messageId)
|
||||
// Success message
|
||||
.then(() => {
|
||||
// Success message
|
||||
interaction.reply('Giveaway Ended!')
|
||||
interaction.reply('Giveaway ended!');
|
||||
})
|
||||
.catch((e) => {
|
||||
interaction.reply({
|
||||
content: e,
|
||||
ephemeral: true
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
|
@ -59,4 +59,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue