mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-21 16:55:03 +00:00
Migrate LocateUser to new Plugin structure
This commit is contained in:
parent
ef1b993d58
commit
7b191093b3
16 changed files with 380 additions and 0 deletions
20
backend/src/plugins/LocateUser/utils/sendAlerts.ts
Normal file
20
backend/src/plugins/LocateUser/utils/sendAlerts.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { PluginData } from "knub";
|
||||
import { LocateUserPluginType } from "../types";
|
||||
import { resolveMember } from "src/utils";
|
||||
import { sendWhere } from "./sendWhere";
|
||||
import { TextableChannel } from "eris";
|
||||
import { moveMember } from "./moveMember";
|
||||
|
||||
export async function sendAlerts(pluginData: PluginData<LocateUserPluginType>, userId: string) {
|
||||
const triggeredAlerts = await pluginData.state.alerts.getAlertsByUserId(userId);
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
|
||||
|
||||
triggeredAlerts.forEach(alert => {
|
||||
const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${alert.body}\`\n`;
|
||||
const txtChannel = pluginData.client.getChannel(alert.channel_id) as TextableChannel;
|
||||
sendWhere.call(this, pluginData.guild, member, txtChannel, prepend);
|
||||
if (alert.active) {
|
||||
moveMember(pluginData, alert.requestor_id, member, txtChannel);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue