3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Add eager permission check in PostAlertOnMemberJoinEvt

This commit is contained in:
Dragory 2021-04-29 02:40:29 +03:00
parent 37fa9c736d
commit d3d51a5308
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -1,7 +1,9 @@
import { modActionsEvt } from "../types"; import { modActionsEvt } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { TextChannel } from "eris"; import { Constants, TextChannel } from "eris";
import { resolveMember } from "../../../utils";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
/** /**
* Show an alert if a member with prior notes joins the server * Show an alert if a member with prior notes joins the server
@ -35,7 +37,16 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt(
return; return;
} }
alertChannel.createMessage( const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user.id);
const botPerms = alertChannel.permissionsOf(botMember ?? pluginData.client.user.id);
if (!hasDiscordPermissions(botPerms, Constants.Permissions.sendMessages)) {
logs.log(LogType.BOT_ALERT, {
body: `Missing "Send Messages" permissions for the \`alert_channel\` configured in \`mod_actions\`: \`${alertChannelId}\``,
});
return;
}
await alertChannel.createMessage(
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`, `<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
); );
} }