Skip to content

Commit d9fb80a

Browse files
committed
Fix disabling webhook mentions when bot lacks permissions
1 parent 3eb3727 commit d9fb80a

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/bot.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,8 @@ class Bot {
594594
const username = _.padEnd(author.substring(0, USERNAME_MAX_LENGTH), USERNAME_MIN_LENGTH, '_');
595595
webhook.client.send(withMentions, {
596596
username,
597-
text,
598597
avatarURL,
599-
disableEveryone: !canPingEveryone,
598+
disableMentions: canPingEveryone ? 'none' : 'everyone',
600599
}).catch(logger.error);
601600
return;
602601
}

test/bot.test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,8 @@ describe('Bot', function () {
10011001
this.bot.sendToDiscord('n', '#irc', text);
10021002
this.sendWebhookMessageStub.should.have.been.calledWith(text, {
10031003
username: 'n_',
1004-
text,
10051004
avatarURL: null,
1006-
disableEveryone: true,
1005+
disableMentions: 'everyone',
10071006
});
10081007
});
10091008

@@ -1012,9 +1011,8 @@ describe('Bot', function () {
10121011
this.bot.sendToDiscord('1234567890123456789012345678901234567890', '#irc', text);
10131012
this.sendWebhookMessageStub.should.have.been.calledWith(text, {
10141013
username: '12345678901234567890123456789012',
1015-
text,
10161014
avatarURL: null,
1017-
disableEveryone: true,
1015+
disableMentions: 'everyone',
10181016
});
10191017
});
10201018

@@ -1029,9 +1027,8 @@ describe('Bot', function () {
10291027
this.bot.sendToDiscord('nick', '#irc', text);
10301028
this.sendWebhookMessageStub.should.have.been.calledWith(text, {
10311029
username: 'nick',
1032-
text,
10331030
avatarURL: null,
1034-
disableEveryone: true,
1031+
disableMentions: 'everyone',
10351032
});
10361033
});
10371034

@@ -1047,9 +1044,8 @@ describe('Bot', function () {
10471044
this.bot.sendToDiscord('nick', '#irc', text);
10481045
this.sendWebhookMessageStub.should.have.been.calledWith(text, {
10491046
username: 'nick',
1050-
text,
10511047
avatarURL: null,
1052-
disableEveryone: false,
1048+
disableMentions: 'none',
10531049
});
10541050
});
10551051

0 commit comments

Comments
 (0)