3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 16:15:04 +00:00

Added Discord attachment link reaction, fixed emoji configuration and moved util functions

This commit is contained in:
Lily Bergonzat 2024-02-16 11:51:58 +01:00
parent a4c4b17a14
commit 592d037148
173 changed files with 1540 additions and 1170 deletions

View file

@ -1,7 +1,7 @@
import { Role, Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
import { CommonPlugin } from "../../Common/CommonPlugin";
import { selfGrantableRolesCmd } from "../types";
import { findMatchingRoles } from "../util/findMatchingRoles";
import { getApplyingEntries } from "../util/getApplyingEntries";
@ -39,12 +39,11 @@ export const RoleAddCmd = selfGrantableRolesCmd({
}, new Map());
if (!rolesToAdd.size) {
sendErrorMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(msg, `<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`, {
users: [msg.author.id],
});
lock.unlock();
return;
}
@ -84,12 +83,11 @@ export const RoleAddCmd = selfGrantableRolesCmd({
roles: Array.from(newRoleIds) as Snowflake[],
});
} catch {
sendErrorMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Got an error while trying to grant you the roles`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(msg, `<@!${msg.author.id}> Got an error while trying to grant you the roles`, {
users: [msg.author.id],
});
return;
}
@ -120,7 +118,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
messageParts.push("couldn't recognize some of the roles");
}
sendSuccessMessage(pluginData, msg.channel, `<@!${msg.author.id}> ${messageParts.join("; ")}`, {
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(msg, `<@!${msg.author.id}> ${messageParts.join("; ")}`, {
users: [msg.author.id],
});

View file

@ -1,7 +1,7 @@
import { Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
import { CommonPlugin } from "../../Common/CommonPlugin";
import { selfGrantableRolesCmd } from "../types";
import { findMatchingRoles } from "../util/findMatchingRoles";
import { getApplyingEntries } from "../util/getApplyingEntries";
@ -46,36 +46,34 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
const removedRolesWord = rolesToRemove.length === 1 ? "role" : "roles";
if (rolesToRemove.length !== roleNames.length) {
sendSuccessMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord};` +
` couldn't recognize the other roles you mentioned`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendSuccessMessage(
msg,
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord};` +
` couldn't recognize the other roles you mentioned`,
{ users: [msg.author.id] },
);
} else {
sendSuccessMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord}`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendSuccessMessage(msg, `<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord}`, {
users: [msg.author.id],
});
}
} catch {
sendSuccessMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Got an error while trying to remove the roles`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendSuccessMessage(msg, `<@!${msg.author.id}> Got an error while trying to remove the roles`, {
users: [msg.author.id],
});
}
} else {
sendErrorMessage(
pluginData,
msg.channel,
`<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`,
{ users: [msg.author.id] },
);
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(msg, `<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`, {
users: [msg.author.id],
});
}
lock.unlock();