mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
Merge branch '240811_application_commands_merge_2' into next
This commit is contained in:
commit
43b8017985
279 changed files with 6192 additions and 3044 deletions
|
@ -1,5 +1,6 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin.js";
|
||||
import { AddRoleCmd } from "./commands/AddRoleCmd.js";
|
||||
|
@ -50,4 +51,8 @@ export const RolesPlugin = guildPlugin<RolesPluginType>()({
|
|||
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
},
|
||||
|
||||
beforeStart(pluginData) {
|
||||
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
|
||||
import { canActOn } from "../../../pluginUtils.js";
|
||||
import { resolveRoleId, verboseUserMention } from "../../../utils.js";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin.js";
|
||||
|
@ -18,19 +18,19 @@ 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");
|
||||
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) {
|
||||
sendErrorMessage(pluginData, msg.channel, "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)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,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");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.member.roles.cache.has(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member already has that role");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Member already has that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,8 @@ export const AddRoleCmd = rolesCmd({
|
|||
roles: [role],
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
void pluginData.state.common.sendSuccessMessage(
|
||||
msg,
|
||||
`Added role **${role.name}** to ${verboseUserMention(args.member.user)}!`,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { logger } from "../../../logger.js";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils.js";
|
||||
import { canActOn } from "../../../pluginUtils.js";
|
||||
import { resolveMember, resolveRoleId, successMessage } from "../../../utils.js";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin.js";
|
||||
|
@ -29,9 +29,8 @@ export const MassAddRoleCmd = rolesCmd({
|
|||
|
||||
for (const member of members) {
|
||||
if (!canActOn(pluginData, msg.member, member, true)) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
"Cannot add roles to 1 or more specified members: insufficient permissions",
|
||||
);
|
||||
return;
|
||||
|
@ -40,13 +39,13 @@ export const MassAddRoleCmd = rolesCmd({
|
|||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "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)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot assign that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils.js";
|
||||
import { canActOn } from "../../../pluginUtils.js";
|
||||
import { resolveMember, resolveRoleId, successMessage } from "../../../utils.js";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin.js";
|
||||
|
@ -28,9 +28,8 @@ export const MassRemoveRoleCmd = rolesCmd({
|
|||
|
||||
for (const member of members) {
|
||||
if (!canActOn(pluginData, msg.member, member, true)) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
"Cannot add roles to 1 or more specified members: insufficient permissions",
|
||||
);
|
||||
return;
|
||||
|
@ -39,13 +38,13 @@ export const MassRemoveRoleCmd = rolesCmd({
|
|||
|
||||
const roleId = await resolveRoleId(pluginData.client, pluginData.guild.id, args.role);
|
||||
if (!roleId) {
|
||||
sendErrorMessage(pluginData, msg.channel, "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)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "You cannot remove that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
|
||||
import { canActOn } from "../../../pluginUtils.js";
|
||||
import { resolveRoleId, verboseUserMention } from "../../../utils.js";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin.js";
|
||||
|
@ -18,19 +18,22 @@ 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");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.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");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Member doesn't have that role");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,9 +59,8 @@ export const RemoveRoleCmd = rolesCmd({
|
|||
roles: [role],
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
void pluginData.state.common.sendSuccessMessage(
|
||||
msg,
|
||||
`Removed role **${role.name}** from ${verboseUserMention(args.member.user)}!`,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { BasePluginType, guildPluginMessageCommand } from "knub";
|
||||
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
|
||||
import z from "zod";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
||||
export const zRolesConfig = z.strictObject({
|
||||
can_assign: z.boolean(),
|
||||
|
@ -12,6 +13,7 @@ export interface RolesPluginType extends BasePluginType {
|
|||
config: z.infer<typeof zRolesConfig>;
|
||||
state: {
|
||||
logs: GuildLogs;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue