summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-05-13 01:47:31 -0700
committerFuwn <[email protected]>2022-05-13 01:47:31 -0700
commit6d03e861a4f619b6af6ec2fdc754d2de6966d6db (patch)
tree6fcdb81a4c65ef28f180d2ae483082fc4bde452d
downloadmacy-6d03e861a4f619b6af6ec2fdc754d2de6966d6db.tar.xz
macy-6d03e861a4f619b6af6ec2fdc754d2de6966d6db.zip
feat(0.1.0): initial release
-rw-r--r--.gitignore5
-rw-r--r--config.ts16
-rw-r--r--deps.ts10
-rw-r--r--mod.ts198
4 files changed, 229 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c5b1b2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+# IDE
+.vscode/
+
+# Development
+.env
diff --git a/config.ts b/config.ts
new file mode 100644
index 0000000..66d9465
--- /dev/null
+++ b/config.ts
@@ -0,0 +1,16 @@
+// This file is part of Macy <https://github.com/Fuwn/macy>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// All Rights Reserved.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: UNLICENSED
+
+export const APPROVED_ROLE = "972279632432857118";
+export const BREAKOUT_ROOM_EIGHT_ROLE = "972018981403766784";
+export const LOBBY_CHANNEL = "972281022764970054";
+export const CLASS_MEMBERS = [
+ "Zoltan Szabatin",
+ "Jaden Price",
+ "Derek Reid",
+];
diff --git a/deps.ts b/deps.ts
new file mode 100644
index 0000000..f3c2ba6
--- /dev/null
+++ b/deps.ts
@@ -0,0 +1,10 @@
+// This file is part of Macy <https://github.com/Fuwn/macy>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// All Rights Reserved.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: UNLICENSED
+
+export * as deploy from "https://deno.land/x/[email protected]/deploy.ts";
+export * from "https://deno.land/x/[email protected]/mod.ts";
diff --git a/mod.ts b/mod.ts
new file mode 100644
index 0000000..e4a7b5b
--- /dev/null
+++ b/mod.ts
@@ -0,0 +1,198 @@
+// This file is part of Macy <https://github.com/Fuwn/macy>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// All Rights Reserved.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: UNLICENSED
+
+// import { config } from "./deps.ts";
+import { deploy } from "./deps.ts";
+import {
+ APPROVED_ROLE,
+ BREAKOUT_ROOM_EIGHT_ROLE,
+ CLASS_MEMBERS,
+ LOBBY_CHANNEL,
+} from "./config.ts";
+
+const verificationQueue = new Map<string, string>();
+
+deploy.init({ env: true });
+// deploy.init({ token: config().TOKEN, publicKey: config().PUBLIC_KEY });
+
+if ((await deploy.commands.all()).size !== 4) {
+ deploy.commands.bulkEdit([
+ {
+ name: "verify",
+ description: "Add your account into the verification queue.",
+ options: [
+ {
+ name: "name",
+ description: "Your full name as shown in Zoom.",
+ required: true,
+ type: deploy.ApplicationCommandOptionType.STRING,
+ },
+ ],
+ },
+ {
+ name: "approve",
+ description: "Approve an account in the verification queue.",
+ options: [
+ {
+ name: "name",
+ description:
+ "A users full name as shown in Zoom. If not specified, all " +
+ "queued verifees will be approved.",
+ required: false,
+ type: deploy.ApplicationCommandOptionType.STRING,
+ },
+ ],
+ },
+ {
+ name: "queue",
+ description: "View the verification queue.",
+ },
+ {
+ name: "setup",
+ description: "Setup the informational verification message in the " +
+ "lobby channel.",
+ },
+ ]);
+}
+
+deploy.client.client?.setPresence({
+ activity: {
+ name: "your work",
+ type: "WATCHING",
+ },
+});
+
+deploy.handle("verify", async (d: deploy.ApplicationCommandInteraction) => {
+ const member = d.member;
+ const name = d.option<string>("name");
+
+ if (member === null) {
+ d.respond({
+ content: "I cannot obtain your ID, please try again.",
+ ephemeral: true,
+ });
+
+ return;
+ }
+
+ if ((await member?.roles.get(APPROVED_ROLE)) !== undefined) {
+ d.respond({
+ content: "You are already verified!",
+ ephemeral: true,
+ });
+
+ return;
+ }
+
+ verificationQueue.forEach((verificationName, id) => {
+ if (id === member?.id || verificationName === name) {
+ d.respond({
+ content: "You are already in the verification queue!",
+ ephemeral: true,
+ });
+
+ return;
+ }
+ });
+
+ if (
+ Deno.env.get("CLASS")?.toLowerCase() === "true" ||
+ Deno.env.get("CLASS") === "1"
+ ) {
+ if (!CLASS_MEMBERS.includes(name)) {
+ d.respond({
+ content: "You are not a class member!",
+ ephemeral: true,
+ });
+
+ return;
+ }
+ }
+
+ (await d.guild?.members.fetchList())?.forEach((member) => {
+ if (member.nick === name) {
+ d.respond({
+ content: "Someone with that exact name is already verified! If you " +
+ "think this is an error, DM <@217348698294714370>.",
+ ephemeral: true,
+ });
+
+ return;
+ }
+ });
+
+ verificationQueue.set(name, member!.id);
+
+ d.respond({
+ content:
+ `Hello, ${name}! You have been added into the verification queue and will be ` +
+ "verified shortly.",
+ ephemeral: true,
+ });
+});
+
+deploy.handle("approve", async (d: deploy.ApplicationCommandInteraction) => {
+ const name = d.option<string | undefined>("name");
+
+ if ((await d.member?.roles.get(BREAKOUT_ROOM_EIGHT_ROLE)) === undefined) {
+ d.respond({
+ content: "You do not have sufficient permissions to verify this user!",
+ ephemeral: true,
+ });
+
+ return;
+ }
+
+ if (name === undefined) {
+ verificationQueue.forEach((name, id) => {
+ console.log(`${name} (${id})`);
+ });
+ d.reply("All users within the verification queue have been approved!");
+ } else {
+ const member = verificationQueue.get(name);
+
+ if (member === undefined) {
+ d.reply(`${name} is not in the verification queue.`);
+ } else {
+ verificationQueue.delete(name);
+ (await d.guild!.members.get(member))?.roles.add(APPROVED_ROLE);
+ (await d.guild!.members.get(member))?.setNickname(name);
+ d.reply(`${name} has been approved!`);
+ }
+ }
+});
+
+deploy.handle("queue", (d: deploy.ApplicationCommandInteraction) => {
+ if (verificationQueue.size === 0) {
+ d.reply("There are no users in the verification queue.");
+
+ return;
+ }
+
+ let verificationQueueString = "Map { ";
+ let i = 1;
+
+ verificationQueue.forEach((name, id) => {
+ verificationQueueString += `\"${name}\" => \"${id}\" ${
+ i == verificationQueue.size ? "" : ", "
+ }`;
+ i += 1;
+ });
+
+ d.reply(verificationQueueString + "}");
+});
+
+deploy.handle("setup", (_: deploy.ApplicationCommandInteraction) => {
+ deploy.client.client?.channels.sendMessage(
+ LOBBY_CHANNEL,
+ "To access the rest of the server, send a message structured like so: " +
+ "`/verify [name]`, with `name` being your full name as shown in Zoom." +
+ "\n\nAn example of a valid verification request looks like this: " +
+ "`/verify Zoltan Szabatin`.",
+ );
+});