mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-08 11:37:20 +00:00
Fixes, refactoring and PR feedback
This commit is contained in:
parent
0be54912c4
commit
893a77d562
202 changed files with 1037 additions and 1069 deletions
|
@ -19,21 +19,19 @@ export const AddRoleCmd = rolesCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!canActOn(pluginData, msg.member, args.member, true)) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, "Cannot add roles to this user: insufficient permissions");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Cannot add roles to this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid role id");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Invalid role id");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -43,12 +41,12 @@ export const AddRoleCmd = rolesCmd({
|
|||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
|
||||
});
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.member.roles.cache.has(roleId)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Member already has that role");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Member already has that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,8 +58,6 @@ export const AddRoleCmd = rolesCmd({
|
|||
roles: [role],
|
||||
});
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `Added role **${role.name}** to ${verboseUserMention(args.member.user)}!`);
|
||||
void pluginData.state.common.sendSuccessMessage(msg, `Added role **${role.name}** to ${verboseUserMention(args.member.user)}!`);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue