aboutsummaryrefslogtreecommitdiff
path: root/src/utils/loading-message.ts
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2021-09-14 13:39:45 -0400
committerGitHub <[email protected]>2021-09-14 13:39:45 -0400
commit1212ffc102641127479f82f522395c46b74255d0 (patch)
tree97cbb75206ef6c356a53262fb1717d14d0da66a3 /src/utils/loading-message.ts
parentfcbff53a7a17e16adfd80cb0723273a17f473d2a (diff)
parent427654fc60ee1431690dfb6ea2917c84a7f0ef56 (diff)
downloadmuse-1212ffc102641127479f82f522395c46b74255d0.tar.xz
muse-1212ffc102641127479f82f522395c46b74255d0.zip
Merge pull request #311 from likuilin/master
Remove Manage Messages perms requirement by only deleting own reactions
Diffstat (limited to 'src/utils/loading-message.ts')
-rw-r--r--src/utils/loading-message.ts22
1 files changed, 12 insertions, 10 deletions
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;
}