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:
parent
37fa9c736d
commit
d3d51a5308
1 changed files with 13 additions and 2 deletions
|
@ -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)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue