Fixed commands
This commit is contained in:
parent
75c6d307de
commit
ad53371b3d
4 changed files with 39 additions and 27 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
node_modules
|
||||
package-lock.json
|
||||
giveaways.js
|
||||
config.json
|
||||
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
|
||||
|
@ -34,21 +34,21 @@ module.exports = {
|
|||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const giveawayChannel = interaction.options.getChannel('channel');
|
||||
const giveawayWinnerCount = interaction.options.getInteger('winners');
|
||||
const giveawayPrize = interaction.options.getString('prize');
|
||||
|
||||
|
||||
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,
|
||||
|
@ -59,7 +59,8 @@ module.exports = {
|
|||
// Messages
|
||||
messages
|
||||
});
|
||||
|
||||
|
||||
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,39 +1,48 @@
|
|||
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
|
||||
const giveaway =
|
||||
// Search with giveaway prize
|
||||
client.giveawaysManager.giveaways.find((g) => g.prize == query && g.guildId === messages.guild.id) ||
|
||||
// Search with giveaway ID
|
||||
client.giveawaysManager.giveaways.find((g) => g.messageID === query && g.guildId === messages.guild.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 === 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){
|
||||
// If no giveaway was found
|
||||
if (!giveaway) {
|
||||
return interaction.reply({
|
||||
content: 'Unable to find a giveaway for `'+ query +'`.',
|
||||
content: 'Unable to find a giveaway for `'+ query + '`.',
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
if (giveaway.ended) {
|
||||
return interaction.reply({
|
||||
content: 'This giveaway is already ended.',
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
@ -43,13 +52,14 @@ module.exports = {
|
|||
// Success message
|
||||
.then(() => {
|
||||
// Success message
|
||||
interaction.reply('Giveaway Ended!')
|
||||
interaction.reply('Giveaway ended!');
|
||||
})
|
||||
.catch((e) => {
|
||||
interaction.reply({
|
||||
content: e,
|
||||
ephemeral: true
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
required: true
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
run: async (client, interaction) => {
|
||||
|
||||
// If the member doesn't have enough permissions
|
||||
|
@ -59,4 +59,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue