3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00

Fix error in mod actions alert_on_rejoin

This commit is contained in:
Dragory 2020-08-28 22:57:11 +03:00
parent cce59f596d
commit bf4c6cc25c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -2,6 +2,7 @@ import { eventListener } from "knub";
import { ModActionsPluginType } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { TextChannel } from "eris";
/**
* Show an alert if a member with prior notes joins the server
@ -17,17 +18,25 @@ export const PostAlertOnMemberJoinEvt = eventListener<ModActionsPluginType>()(
if (!alertChannelId) return;
const actions = await pluginData.state.cases.getByUserId(member.id);
const logs = pluginData.getPlugin(LogsPlugin);
if (actions.length) {
const alertChannel: any = pluginData.guild.channels.get(alertChannelId);
const alertChannel = pluginData.guild.channels.get(alertChannelId);
if (!alertChannel) {
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
logs.log(LogType.BOT_ALERT, {
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,
});
return;
}
alertChannel.send(
if (!(alertChannel instanceof TextChannel)) {
logs.log(LogType.BOT_ALERT, {
body: `Non-text channel configured as \`alert_channel\` in \`mod_actions\`: \`${alertChannelId}\``,
});
return;
}
alertChannel.createMessage(
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
);
}