Rename Events and files to prevent ambiguity and order availablePlugins
This commit is contained in:
parent
f324dfc227
commit
0bc7dc17b7
13 changed files with 59 additions and 65 deletions
39
backend/src/plugins/LocateUser/events/SendAlertsEvts.ts
Normal file
39
backend/src/plugins/LocateUser/events/SendAlertsEvts.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { locateUserEvent } from "../types";
|
||||
import { sendAlerts } from "../utils/sendAlerts";
|
||||
import { VoiceChannel, TextableChannel } from "eris";
|
||||
|
||||
export const ChannelJoinAlertsEvt = locateUserEvent({
|
||||
event: "voiceChannelJoin",
|
||||
|
||||
async listener(meta) {
|
||||
if (meta.pluginData.state.usersWithAlerts.includes(meta.args.member.id)) {
|
||||
sendAlerts(meta.pluginData, meta.args.member.id);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const ChannelSwitchAlertsEvt = locateUserEvent({
|
||||
event: "voiceChannelSwitch",
|
||||
|
||||
async listener(meta) {
|
||||
if (meta.pluginData.state.usersWithAlerts.includes(meta.args.member.id)) {
|
||||
sendAlerts(meta.pluginData, meta.args.member.id);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const ChannelLeaveAlertsEvt = 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}\``,
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue