aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/pronoundb/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/pronoundb/index.ts')
-rw-r--r--src/plugins/pronoundb/index.ts59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts
index c848110..87fb902 100644
--- a/src/plugins/pronoundb/index.ts
+++ b/src/plugins/pronoundb/index.ts
@@ -1,6 +1,6 @@
/*
* Vencord, a modification for Discord's desktop app
- * Copyright (c) 2022 Vendicated and contributors
+ * Copyright (c) 2022-2023 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,12 +16,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import PronounsAboutComponent from "./components/PronounsAboutComponent";
import PronounsChatComponent from "./components/PronounsChatComponent";
import PronounsProfileWrapper from "./components/PronounsProfileWrapper";
+import { formatPronouns, getLocalPronounOverride, setLocalPronounOverride } from "./pronoundbUtils";
+import { PronounCode, PronounMapping } from "./types";
export enum PronounsFormat {
Lowercase = "LOWERCASE",
@@ -81,6 +84,60 @@ export default definePlugin({
default: true
}
},
+
+ commands: [
+ {
+ description: "Set local pronouns for a person",
+ name: "setpronouns",
+ options: [
+ {
+ description: "The user for which you want to set the local pronoun override",
+ name: "user",
+ displayName: "User",
+ type: ApplicationCommandOptionType.USER,
+ required: true,
+ },
+ {
+ name: "pronouns",
+ displayName: "Pronouns",
+ type: ApplicationCommandOptionType.STRING,
+ description: "What pronouns should I display for this user.",
+ required: false,
+ choices: [
+ ...Object.keys(PronounMapping).map(id => ({
+ label: PronounMapping[id],
+ value: id,
+ name: PronounMapping[id],
+ })),
+ {
+ label: "Clear local override",
+ name: "Clear local override",
+ value: "clear",
+ }
+ ],
+ }
+ ],
+ inputType: ApplicationCommandInputType.BOT,
+ async execute(args, ctx) {
+ const user = findOption<string>(args, "user")!!;
+ const overrideWith = findOption<string>(args, "pronouns", "view");
+ const currentOverride = await getLocalPronounOverride(user);
+ const currentOverrideText = currentOverride ? formatPronouns(currentOverride) : "No override";
+ if (overrideWith === "view") {
+ sendBotMessage(ctx.channel.id, { content: `Current pronoun override for <@${user}>: ${currentOverrideText}` });
+ return;
+ }
+ if (overrideWith !== currentOverride) {
+ const asPronounCode = overrideWith === "clear" ? null : overrideWith as PronounCode;
+ await setLocalPronounOverride(user, asPronounCode);
+ sendBotMessage(ctx.channel.id, { content: `Changed pronoun override for <@${user}> from ${currentOverrideText} to ${asPronounCode ? formatPronouns(asPronounCode) : "No override"}` });
+ return;
+ }
+ sendBotMessage(ctx.channel.id, { content: `Pronoun override for <@${user}> is alredy ${currentOverrideText}` });
+ },
+ },
+ ],
+
settingsAboutComponent: PronounsAboutComponent,
// Re-export the components on the plugin object so it is easily accessible in patches
PronounsChatComponent,