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
|
package-lock.json
|
||||||
giveaways.js
|
giveaways.js
|
||||||
config.json
|
config.json
|
||||||
|
giveaways.json
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
|
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Winners',
|
name: 'winners',
|
||||||
description: 'How many winners the giveaway should have',
|
description: 'How many winners the giveaway should have',
|
||||||
type: 'INTEGER',
|
type: 'INTEGER',
|
||||||
required: true
|
required: true
|
||||||
|
@ -41,14 +41,14 @@ module.exports = {
|
||||||
|
|
||||||
if(!giveawayChannel.isText()) {
|
if(!giveawayChannel.isText()) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: ':x: Selected channel; is not text-based.',
|
content: ':x: Selected channel is not text-based.',
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the giveaway
|
// Start the giveaway
|
||||||
client.giveawaysManager.start(giveawayChannel, {
|
client.giveawaysManager.start(giveawayChannel, {
|
||||||
// The number of winners for this frop
|
// The number of winners for this drop
|
||||||
winnerCount: giveawayWinnerCount,
|
winnerCount: giveawayWinnerCount,
|
||||||
// The prize of the giveaway
|
// The prize of the giveaway
|
||||||
prize: giveawayPrize,
|
prize: giveawayPrize,
|
||||||
|
@ -61,5 +61,6 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
|
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
|
@ -1,39 +1,48 @@
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
const messages = require('../utils/messages');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
description: 'End a Giveaway',
|
|
||||||
|
description: 'End a giveaway',
|
||||||
|
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'giveaway',
|
name: 'giveaway',
|
||||||
description: 'The giveaway to end (message ID or Giveaway prize.)',
|
description: 'The giveaway to end (message ID or giveaway prize)',
|
||||||
type: 'STRING',
|
type: 'STRING',
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
run: async (client, interaction) => {
|
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({
|
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
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = interaction.options.getString('giveaway');
|
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 =
|
const giveaway =
|
||||||
// Search with giveaway prize
|
// 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
|
// 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){
|
if (!giveaway) {
|
||||||
return interaction.reply({
|
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
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,13 +52,14 @@ module.exports = {
|
||||||
// Success message
|
// Success message
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Success message
|
// Success message
|
||||||
interaction.reply('Giveaway Ended!')
|
interaction.reply('Giveaway ended!');
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
content: e,
|
content: e,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -59,4 +59,4 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
Loading…
Reference in a new issue