Skip to content

Commit

Permalink
enforce GUILD_MESSAGE_REACTIONS intent
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 16, 2021
1 parent c363992 commit 0cf4298
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class GiveawaysManager extends EventEmitter {
constructor(client, options, init = true) {
super();
if (!client?.options) throw new Error(`Client is a required option. (val=${client})`);
if (!new Discord.Intents(client.options.intents).has(Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS)) {
throw new Error('Client is missing the "GUILD_MESSAGE_REACTIONS" intent.');
}

/**
* The Discord Client
* @type {Discord.Client}
Expand All @@ -45,6 +49,7 @@ class GiveawaysManager extends EventEmitter {
* @type {GiveawaysManagerOptions}
*/
this.options = merge(GiveawaysManagerOptions, options || {});

if (init) this._init();
}

Expand Down Expand Up @@ -351,7 +356,7 @@ class GiveawaysManager extends EventEmitter {

if (!doNotDeleteMessage) {
await giveaway.fetchMessage().catch(() => {});
if (giveaway.message) giveaway.message.delete();
giveaway.message?.delete();
}
this.giveaways = this.giveaways.filter((g) => g.messageId !== messageId);
await this.deleteGiveaway(messageId);
Expand Down

0 comments on commit 0cf4298

Please sign in to comment.