-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment register & delete command func
- Loading branch information
Showing
4 changed files
with
55 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
// })(); |