diff options
| author | Kuilin Li <[email protected]> | 2021-09-12 23:08:33 +0000 |
|---|---|---|
| committer | Kuilin Li <[email protected]> | 2021-09-12 23:56:45 +0000 |
| commit | 257191b1837c0a051c8aae3000dfac039b4d3c1b (patch) | |
| tree | d8c6b12cf65fcfa6c8332398508709cac13fcd77 /src/utils | |
| parent | bd1d026d7209bc8bd2bcb4f5997c86a7c3833df1 (diff) | |
| download | muse-257191b1837c0a051c8aae3000dfac039b4d3c1b.tar.xz muse-257191b1837c0a051c8aae3000dfac039b4d3c1b.zip | |
Remove Manage Messages perms requirement by only deleting own reactions
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/loading-message.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/utils/loading-message.ts b/src/utils/loading-message.ts index 115aff2..95c7a2f 100644 --- a/src/utils/loading-message.ts +++ b/src/utils/loading-message.ts @@ -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; } |
