mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
Added Discord attachment link reaction, fixed emoji configuration and moved util functions
This commit is contained in:
parent
a4c4b17a14
commit
592d037148
173 changed files with 1540 additions and 1170 deletions
|
@ -1,7 +1,8 @@
|
|||
import { GuildChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { resolveRoleId, verboseUserMention } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
|
||||
import { rolesCmd } from "../types";
|
||||
|
@ -18,19 +19,21 @@ export const AddRoleCmd = rolesCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!canActOn(pluginData, msg.member, args.member, true)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Cannot add roles to this user: insufficient permissions");
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, "Cannot add roles to this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid role id");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid role id");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,12 +43,12 @@ export const AddRoleCmd = rolesCmd({
|
|||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
|
||||
});
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.member.roles.cache.has(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member already has that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Member already has that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,10 +60,8 @@ export const AddRoleCmd = rolesCmd({
|
|||
roles: [role],
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Added role **${role.name}** to ${verboseUserMention(args.member.user)}!`,
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `Added role **${role.name}** to ${verboseUserMention(args.member.user)}!`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { logger } from "../../../logger";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveRoleId, successMessage } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
|
||||
import { rolesCmd } from "../types";
|
||||
|
@ -29,24 +30,22 @@ export const MassAddRoleCmd = rolesCmd({
|
|||
|
||||
for (const member of members) {
|
||||
if (!canActOn(pluginData, msg.member, member, true)) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
"Cannot add roles to 1 or more specified members: insufficient permissions",
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, "Cannot add roles to 1 or more specified members: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid role id");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid role id");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ export const MassAddRoleCmd = rolesCmd({
|
|||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
|
||||
});
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveRoleId, successMessage } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
|
||||
import { rolesCmd } from "../types";
|
||||
|
@ -28,24 +29,22 @@ export const MassRemoveRoleCmd = rolesCmd({
|
|||
|
||||
for (const member of members) {
|
||||
if (!canActOn(pluginData, msg.member, member, true)) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
"Cannot add roles to 1 or more specified members: insufficient permissions",
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, "Cannot add roles to 1 or more specified members: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid role id");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid role id");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot remove that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ export const MassRemoveRoleCmd = rolesCmd({
|
|||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
|
||||
});
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot remove that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { GuildChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { resolveRoleId, verboseUserMention } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
|
||||
import { rolesCmd } from "../types";
|
||||
|
@ -18,19 +19,21 @@ export const RemoveRoleCmd = rolesCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!canActOn(pluginData, msg.member, args.member, true)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Cannot remove roles from this user: insufficient permissions");
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, "Cannot remove roles from this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid role id");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid role id");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot remove that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,12 +43,12 @@ export const RemoveRoleCmd = rolesCmd({
|
|||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown role configured for 'roles' plugin: ${roleId}`,
|
||||
});
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You cannot remove that role");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.member.roles.cache.has(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member doesn't have that role");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Member doesn't have that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,10 +59,8 @@ export const RemoveRoleCmd = rolesCmd({
|
|||
roles: [role],
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Removed role **${role.name}** from ${verboseUserMention(args.member.user)}!`,
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `Removed role **${role.name}** from ${verboseUserMention(args.member.user)}!`);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue