diff options
| author | Max Isom <[email protected]> | 2021-09-14 13:39:45 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-09-14 13:39:45 -0400 |
| commit | 1212ffc102641127479f82f522395c46b74255d0 (patch) | |
| tree | 97cbb75206ef6c356a53262fb1717d14d0da66a3 | |
| parent | fcbff53a7a17e16adfd80cb0723273a17f473d2a (diff) | |
| parent | 427654fc60ee1431690dfb6ea2917c84a7f0ef56 (diff) | |
| download | muse-1212ffc102641127479f82f522395c46b74255d0.tar.xz muse-1212ffc102641127479f82f522395c46b74255d0.zip | |
Merge pull request #311 from likuilin/master
Remove Manage Messages perms requirement by only deleting own reactions
| -rw-r--r-- | src/bot.ts | 2 | ||||
| -rw-r--r-- | src/utils/loading-message.ts | 22 |
2 files changed, 13 insertions, 11 deletions
@@ -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); diff --git a/src/utils/loading-message.ts b/src/utils/loading-message.ts index a5a2fa1..53a2aed 100644 --- a/src/utils/loading-message.ts +++ b/src/utils/loading-message.ts @@ -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; } |
