Skip to content

Commit

Permalink
Comment register & delete command func
Browse files Browse the repository at this point in the history
  • Loading branch information
diksipav committed Aug 1, 2024
1 parent 91da77c commit 5f08c59
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 84 deletions.
30 changes: 0 additions & 30 deletions app/envs.ts

This file was deleted.

3 changes: 2 additions & 1 deletion app/lib/db/drafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -42,6 +42,7 @@ const getDraftsQuery = e.params(
id: true,
title: true,
question: true,
opa: true,
linkedTags: {
name: true,
disabled: true,
Expand Down
58 changes: 29 additions & 29 deletions app/lib/discord/scripts/deleteCommand.ts
Original file line number Diff line number Diff line change
@@ -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);
48 changes: 24 additions & 24 deletions app/lib/discord/scripts/registerCommands.ts
Original file line number Diff line number Diff line change
@@ -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.");
// })();

0 comments on commit 5f08c59

Please sign in to comment.