3
0
Fork 0
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:
Dragory 2018-08-03 19:24:40 +03:00
parent aee14eac10
commit e585f63bec

View file

@ -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(