mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix(censor): handle unknown invites gracefully
This commit is contained in:
parent
aee14eac10
commit
e585f63bec
1 changed files with 10 additions and 2 deletions
|
@ -88,10 +88,18 @@ export class CensorPlugin extends Plugin {
|
||||||
|
|
||||||
const inviteCodes = getInviteCodesInString(msg.content);
|
const inviteCodes = getInviteCodesInString(msg.content);
|
||||||
|
|
||||||
const invites: Invite[] = await Promise.all(
|
let invites: Invite[] = await Promise.all(
|
||||||
inviteCodes.map(code => this.bot.getInvite(code))
|
inviteCodes.map(code => {
|
||||||
|
try {
|
||||||
|
return this.bot.getInvite(code);
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
invites = invites.filter(v => !!v);
|
||||||
|
|
||||||
for (const invite of invites) {
|
for (const invite of invites) {
|
||||||
if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(invite.guild.id)) {
|
if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(invite.guild.id)) {
|
||||||
this.censorMessage(
|
this.censorMessage(
|
||||||
|
|
Loading…
Add table
Reference in a new issue