summaryrefslogtreecommitdiff
path: root/packages/interactions
diff options
context:
space:
mode:
Diffstat (limited to 'packages/interactions')
-rw-r--r--packages/interactions/discord/commands/index.ts14
-rw-r--r--packages/interactions/discord/embeds.ts35
-rw-r--r--packages/interactions/register.ts2
-rw-r--r--packages/interactions/server.ts93
4 files changed, 144 insertions, 0 deletions
diff --git a/packages/interactions/discord/commands/index.ts b/packages/interactions/discord/commands/index.ts
index a69e786..0a13e33 100644
--- a/packages/interactions/discord/commands/index.ts
+++ b/packages/interactions/discord/commands/index.ts
@@ -86,6 +86,20 @@ export const APPEAL_COMMAND: DiscordCommand = {
],
};
+export const NSFW_APPLY_COMMAND: DiscordCommand = {
+ name: "nsfw-apply",
+ description: "Submit an NSFW access application to the moderators",
+ contexts: [0],
+ options: [
+ {
+ type: 3,
+ name: "message",
+ description: "Your NSFW access application message",
+ required: true,
+ },
+ ],
+};
+
export const COLOURS_COMMAND: DiscordCommand = {
name: "colours",
description: "Show the distribution of colour roles in the server",
diff --git a/packages/interactions/discord/embeds.ts b/packages/interactions/discord/embeds.ts
index 3f7c344..16e485e 100644
--- a/packages/interactions/discord/embeds.ts
+++ b/packages/interactions/discord/embeds.ts
@@ -179,3 +179,38 @@ export const createAppealEmbed = (
},
};
};
+
+export const createNSFWApplicationEmbed = (
+ applicationContent: string,
+ applicant: { username: string; id: string; avatar?: string },
+ timestamp: number,
+ isDM: boolean = true,
+): DiscordEmbed => {
+ return {
+ title: "🔞 NSFW Access Application",
+ description: applicationContent,
+ color: 0xff69b4,
+ fields: [
+ {
+ name: "Applicant",
+ value: `${applicant.username} (${applicant.id})`,
+ inline: true,
+ },
+ {
+ name: "Timestamp",
+ value: `<t:${Math.floor(timestamp / 1000)}:F>`,
+ inline: true,
+ },
+ ],
+ thumbnail: applicant.avatar
+ ? {
+ url: `https://cdn.discordapp.com/avatars/${applicant.id}/${applicant.avatar}.png?size=256`,
+ }
+ : undefined,
+ footer: {
+ text: isDM
+ ? "Application submitted via DM"
+ : "Application submitted from server",
+ },
+ };
+};
diff --git a/packages/interactions/register.ts b/packages/interactions/register.ts
index 00f4f9b..e076e5c 100644
--- a/packages/interactions/register.ts
+++ b/packages/interactions/register.ts
@@ -5,6 +5,7 @@ import {
TOP_COMMAND,
COMPLAIN_COMMAND,
APPEAL_COMMAND,
+ NSFW_APPLY_COMMAND,
COLOURS_COMMAND,
ROLEPLAY_VERIFY_COMMAND,
AGE_VERIFY_COMMAND,
@@ -35,6 +36,7 @@ const commands: DiscordCommand[] = [
TOP_COMMAND,
COMPLAIN_COMMAND,
APPEAL_COMMAND,
+ NSFW_APPLY_COMMAND,
COLOURS_COMMAND,
ROLEPLAY_VERIFY_COMMAND,
AGE_VERIFY_COMMAND,
diff --git a/packages/interactions/server.ts b/packages/interactions/server.ts
index 3a9651e..29245b6 100644
--- a/packages/interactions/server.ts
+++ b/packages/interactions/server.ts
@@ -7,6 +7,7 @@ import {
TOP_COMMAND,
COMPLAIN_COMMAND,
APPEAL_COMMAND,
+ NSFW_APPLY_COMMAND,
COLOURS_COMMAND,
ROLEPLAY_VERIFY_COMMAND,
AGE_VERIFY_COMMAND,
@@ -23,6 +24,7 @@ import {
createPostEmbed,
createComplaintEmbed,
createAppealEmbed,
+ createNSFWApplicationEmbed,
createRoleDistributionEmbed,
} from "./discord/embeds.ts";
import { JSONResponse } from "./discord/responses.ts";
@@ -32,6 +34,7 @@ import { GUILD_ID, COLOR_ROLE_IDS } from "../shared";
const router = AutoRouter();
const COMPLAINT_CHANNEL_ID = "1415868433714778204";
const APPEAL_CHANNEL_ID = "1420340807931531385";
+const NSFW_APPLY_CHANNEL_ID = "1423148301221625926";
const VERIFIED_ROLEPLAY_ROLE_ID = "1418311833303122021";
const ROLE_MANAGER_ROLE_ID = "1410993207608873070";
const ART_MEDIA_ROLE_ID = "1410333831281643630";
@@ -67,6 +70,32 @@ const sendComplaintToChannel = async (
}
};
+const sendNSFWApplicationToChannel = async (
+ environment: Environment,
+ embed: DiscordEmbed,
+): Promise<boolean> => {
+ const url = `https://discord.com/api/v10/channels/${NSFW_APPLY_CHANNEL_ID}/messages`;
+
+ try {
+ const response = await fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bot ${environment.DISCORD_TOKEN}`,
+ },
+ body: JSON.stringify({
+ embeds: [embed],
+ }),
+ });
+
+ return response.ok;
+ } catch (error) {
+ console.error("Error sending NSFW application to channel:", error);
+
+ return false;
+ }
+};
+
const sendAppealToChannel = async (
environment: Environment,
embed: DiscordEmbed,
@@ -487,6 +516,70 @@ router.post("/", async (request: Request, environment: Environment) => {
}
}
+ case NSFW_APPLY_COMMAND.name.toLowerCase(): {
+ try {
+ const applicationMessage = interaction.data.options?.[0]?.value as string;
+
+ if (!applicationMessage)
+ return new JSONResponse({
+ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
+ data: {
+ content: "❌ Please provide a message for your NSFW access application.",
+ flags: 64,
+ },
+ });
+
+ const applicant = {
+ username:
+ interaction.member?.user?.username ||
+ interaction.user?.username ||
+ "Unknown",
+ id:
+ interaction.member?.user?.id || interaction.user?.id || "Unknown",
+ avatar:
+ interaction.member?.user?.avatar || interaction.user?.avatar,
+ };
+ const isDM = !interaction.guild_id;
+ const applicationEmbed = createNSFWApplicationEmbed(
+ applicationMessage,
+ applicant,
+ Date.now(),
+ isDM,
+ );
+ const success = await sendNSFWApplicationToChannel(environment, applicationEmbed);
+
+ if (success) {
+ return new JSONResponse({
+ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
+ data: {
+ content:
+ "✅ Your NSFW access application has been submitted successfully! A moderator will review it and follow up with you soon.",
+ flags: 64,
+ },
+ });
+ } else {
+ return new JSONResponse({
+ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
+ data: {
+ content:
+ "❌ Failed to submit your NSFW access application. Please try again later.",
+ flags: 64,
+ },
+ });
+ }
+ } catch (error) {
+ console.error("Error in nsfw-apply command:", error);
+
+ return new JSONResponse({
+ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
+ data: {
+ content: "❌ An error occurred while processing your NSFW access application.",
+ flags: 64,
+ },
+ });
+ }
+ }
+
case COLOURS_COMMAND.name.toLowerCase(): {
try {
if (!interaction.guild_id)