Merge pull request #311 from likuilin/master

Remove Manage Messages perms requirement by only deleting own reactions
This commit is contained in:
Max Isom 2021-09-14 13:39:45 -04:00 committed by GitHub
commit 1212ffc102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -96,7 +96,7 @@ export default class {
});
this.client.on('ready', async () => {
console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.clientId}&scope=bot&permissions=36760640`);
console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.clientId}&scope=bot&permissions=36752448`);
});
this.client.on('error', console.error);

View file

@ -43,7 +43,7 @@ export default class {
if (reactionToRemove) {
// eslint-disable-next-line no-await-in-loop
await reactionToRemove.remove();
await reactionToRemove.users.remove(this.msg.client.user!.id);
} else {
isRemoving = false;
}
@ -64,15 +64,17 @@ export default class {
this.isStopped = true;
if (str) {
if (wasAlreadyStopped) {
await this.msg.edit(str);
} else {
await Promise.all([this.msg.reactions.removeAll(), this.msg.edit(str)]);
}
} else {
await this.msg.reactions.removeAll();
}
const editPromise = str ? this.msg.edit(str) : null;
const reactPromise = str && !wasAlreadyStopped ? (async () => {
await this.msg.fetch();
await Promise.all(this.msg.reactions.cache.map(async react => {
if (react.me) {
await react.users.remove(this.msg.client.user!.id);
}
}));
})() : null;
await Promise.all([editPromise, reactPromise]);
return this.msg;
}