From 5f08c594f33ea94b55b4662b7aaf42ed0eabc11e Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Thu, 1 Aug 2024 14:07:12 +0200 Subject: [PATCH] Comment register & delete command func --- app/envs.ts | 30 ----------- app/lib/db/drafts.ts | 3 +- app/lib/discord/scripts/deleteCommand.ts | 58 ++++++++++----------- app/lib/discord/scripts/registerCommands.ts | 48 ++++++++--------- 4 files changed, 55 insertions(+), 84 deletions(-) delete mode 100644 app/envs.ts diff --git a/app/envs.ts b/app/envs.ts deleted file mode 100644 index 5c6c14d..0000000 --- a/app/envs.ts +++ /dev/null @@ -1,30 +0,0 @@ -if (!process.env.DISCORD_CLIENT_ID) { - throw new Error("DISCORD_CLIENT_ID env var not configured"); -} -export const discordClientId = process.env.DISCORD_CLIENT_ID; - -if (!process.env.DISCORD_CLIENT_PUBLIC_KEY) { - throw new Error("DISCORD_CLIENT_PUBLIC_KEY env var not configured"); -} -export const discordClientPublicKey = process.env.DISCORD_CLIENT_PUBLIC_KEY; - -if (!process.env.DISCORD_TOKEN) { - throw new Error(`DISCORD_TOKEN env var not configured`); -} -export const discordToken = process.env.DISCORD_TOKEN; - -if (!process.env.DISCORD_GUILD_ID) { - throw new Error("DISCORD_GUILD_ID env var not configured"); -} -export const discordGuildId = process.env.DISCORD_GUILD_ID; - -if (!process.env.DISCORD_MODERATION_ACCESS_ROLES) { - throw new Error("DISCORD_MODERATION_ACCESS_ROLES env var not configured"); -} -export const authorizedRoleIds = - process.env.DISCORD_MODERATION_ACCESS_ROLES.split(","); - -if (!process.env.REVIEW_CHANNEL_ID) { - throw new Error("REVIEW_CHANNEL_ID env var not configured"); -} -export const reviewChannelId = process.env.REVIEW_CHANNEL_ID; diff --git a/app/lib/db/drafts.ts b/app/lib/db/drafts.ts index b4306c3..4ab4ae9 100644 --- a/app/lib/db/drafts.ts +++ b/app/lib/db/drafts.ts @@ -2,7 +2,7 @@ import createClient from "edgedb"; import { client, auth } from "@/app/lib/edgedb"; -import e from "@/dbschema/edgeql-js"; +import e, { type $infer } from "@/dbschema/edgeql-js"; import { getFtsDraftsCount } from "./queries/getFtsDraftsCount.query"; import { getFtsDrafts } from "./queries/getFtsDrafts.query"; @@ -42,6 +42,7 @@ const getDraftsQuery = e.params( id: true, title: true, question: true, + opa: true, linkedTags: { name: true, disabled: true, diff --git a/app/lib/discord/scripts/deleteCommand.ts b/app/lib/discord/scripts/deleteCommand.ts index dbfbe8f..11e8410 100644 --- a/app/lib/discord/scripts/deleteCommand.ts +++ b/app/lib/discord/scripts/deleteCommand.ts @@ -1,36 +1,36 @@ -import dotenv from "dotenv"; -import { REST } from "@discordjs/rest"; -import { Routes } from "discord-api-types/v10"; +// import dotenv from "dotenv"; +// import { REST } from "@discordjs/rest"; +// import { Routes } from "discord-api-types/v10"; -dotenv.config(); -dotenv.config({ path: ".env.prod" }); +// dotenv.config(); +// dotenv.config({ path: ".env.prod" }); -if (!process.env.DISCORD_TOKEN) { - console.error("DISCORD_TOKEN environment variable is not set."); - process.exit(1); -} +// if (!process.env.DISCORD_TOKEN) { +// console.error("DISCORD_TOKEN environment variable is not set."); +// process.exit(1); +// } -if (!process.env.DISCORD_CLIENT_ID) { - console.error("DISCORD_CLIENT_ID environment variable is not set."); - process.exit(1); -} +// if (!process.env.DISCORD_CLIENT_ID) { +// console.error("DISCORD_CLIENT_ID environment variable is not set."); +// process.exit(1); +// } -const rest = new REST().setToken(process.env.DISCORD_TOKEN!); +// const rest = new REST().setToken(process.env.DISCORD_TOKEN!); -// for guild-based commands +// // for guild-based commands +// // rest +// // .delete( +// // Routes.applicationGuildCommand( +// // process.env.DISCORD_CLIENT_ID!, +// // process.env.DISCORD_GUILD_ID!, +// // "1157365753314553900" +// // ) +// // ) +// // .then(() => console.log("Successfully deleted guild command")) +// // .catch(console.error); + +// // for global commands // rest -// .delete( -// Routes.applicationGuildCommand( -// process.env.DISCORD_CLIENT_ID!, -// process.env.DISCORD_GUILD_ID!, -// "1157365753314553900" -// ) -// ) -// .then(() => console.log("Successfully deleted guild command")) +// .delete(Routes.applicationCommand(process.env.DISCORD_CLIENT_ID, "commandId")) +// .then(() => console.log("Successfully deleted global command")) // .catch(console.error); - -// for global commands -rest - .delete(Routes.applicationCommand(process.env.DISCORD_CLIENT_ID, "commandId")) - .then(() => console.log("Successfully deleted global command")) - .catch(console.error); diff --git a/app/lib/discord/scripts/registerCommands.ts b/app/lib/discord/scripts/registerCommands.ts index 58e840b..93d4cde 100644 --- a/app/lib/discord/scripts/registerCommands.ts +++ b/app/lib/discord/scripts/registerCommands.ts @@ -1,30 +1,30 @@ -import dotenv from "dotenv"; -import { REST } from "@discordjs/rest"; -import { loadCommandDefinitions } from "../command"; -import { Routes } from "discord-api-types/v10"; +// import dotenv from "dotenv"; +// import { REST } from "@discordjs/rest"; +// import { loadCommandDefinitions } from "../command"; +// import { Routes } from "discord-api-types/v10"; -dotenv.config(); -dotenv.config({ path: ".env.prod" }); +// dotenv.config(); +// dotenv.config({ path: ".env.prod" }); -(async function () { - if (!process.env.DISCORD_TOKEN) { - console.error("DISCORD_TOKEN environment variable is not set."); - process.exit(1); - } +// (async function () { +// if (!process.env.DISCORD_TOKEN) { +// console.error("DISCORD_TOKEN environment variable is not set."); +// process.exit(1); +// } - var commands = await loadCommandDefinitions(); +// var commands = await loadCommandDefinitions(); - const rest = new REST().setToken(process.env.DISCORD_TOKEN); +// const rest = new REST().setToken(process.env.DISCORD_TOKEN); - await rest.put( - Routes.applicationGuildCommands( - process.env.DISCORD_CLIENT_ID!, - process.env.DISCORD_GUILD_ID! - ), - { - body: commands.map((c) => c.definition), - } - ); +// await rest.put( +// Routes.applicationGuildCommands( +// process.env.DISCORD_CLIENT_ID!, +// process.env.DISCORD_GUILD_ID! +// ), +// { +// body: commands.map((c) => c.definition), +// } +// ); - console.log("Successfully registered guild commands."); -})(); +// console.log("Successfully registered guild commands."); +// })();