Migrate LocateUser to new Plugin structure

This commit is contained in:
Dark 2020-07-08 02:53:44 +02:00
parent 4a8a63e8b8
commit 63efaf84ee
16 changed files with 380 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import { locateUserEvent } from "../types";
import { sendAlerts } from "../utils/sendAlerts";
import { VoiceChannel, TextableChannel } from "eris";
export const ChannelLeaveEvt = locateUserEvent({
event: "voiceChannelLeave",
async listener(meta) {
const triggeredAlerts = await meta.pluginData.state.alerts.getAlertsByUserId(meta.args.member.id);
const voiceChannel = meta.args.oldChannel as VoiceChannel;
triggeredAlerts.forEach(alert => {
const txtChannel = meta.pluginData.client.getChannel(alert.channel_id) as TextableChannel;
txtChannel.createMessage(
`🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`${voiceChannel.name}\``,
);
});
},
});