3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Add proper types to sendErrorMessage()

This commit is contained in:
Dragory 2021-01-17 21:21:18 +02:00
parent 6896afebfa
commit edaeb7ef0e
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
23 changed files with 123 additions and 78 deletions

View file

@ -17,17 +17,20 @@ export const RemoveRoleCmd = rolesCmd({
async run({ message: msg, args, pluginData }) {
if (!canActOn(pluginData, msg.member, args.member, true)) {
return sendErrorMessage(pluginData, msg.channel, "Cannot remove roles from this user: insufficient permissions");
sendErrorMessage(pluginData, msg.channel, "Cannot remove roles from this user: insufficient permissions");
return;
}
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
if (!roleId) {
return sendErrorMessage(pluginData, msg.channel, "Invalid role id");
sendErrorMessage(pluginData, msg.channel, "Invalid role id");
return;
}
const config = pluginData.config.getForMessage(msg);
if (!config.assignable_roles.includes(roleId)) {
return sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
return;
}
// Sanity check: make sure the role is configured properly
@ -36,11 +39,13 @@ export const RemoveRoleCmd = rolesCmd({
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
});
return sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
return;
}
if (!args.member.roles.includes(roleId)) {
return sendErrorMessage(pluginData, msg.channel, "Member doesn't have that role");
sendErrorMessage(pluginData, msg.channel, "Member doesn't have that role");
return;
}
pluginData.state.logs.ignoreLog(LogType.MEMBER_ROLE_REMOVE, args.member.id);