Delete all vcalerts when a user gets banned
Since they are unnecessary either way, they cannot be triggered anymore and would just idle in the DB
This commit is contained in:
parent
3174425083
commit
d4e76a0fd7
1 changed files with 9 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
import { decorators as d, IPluginOptions, getInviteLink, logger } from "knub";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { Message, Member, Guild, TextableChannel, VoiceChannel, Channel } from "eris";
|
||||
import { Message, Member, Guild, TextableChannel, VoiceChannel, Channel, User } from "eris";
|
||||
import { GuildVCAlerts } from "../data/GuildVCAlerts";
|
||||
import moment = require("moment");
|
||||
import { resolveMember, sorter, createChunkedMessage, errorMessage, successMessage } from "../utils";
|
||||
|
@ -146,6 +146,14 @@ export class LocatePlugin extends ZeppelinPlugin<ILocatePluginConfig> {
|
|||
}
|
||||
}
|
||||
|
||||
@d.event("guildBanAdd")
|
||||
async onGuildBanAdd(_, user: User) {
|
||||
const alerts = await this.alerts.getAlertsByUserId(user.id);
|
||||
alerts.forEach(alert => {
|
||||
this.alerts.delete(alert.id);
|
||||
});
|
||||
}
|
||||
|
||||
async sendAlerts(userid: string) {
|
||||
const triggeredAlerts = await this.alerts.getAlertsByUserId(userid);
|
||||
const member = await resolveMember(this.bot, this.guild, userid);
|
||||
|
|
Loading…
Add table
Reference in a new issue