Updated scripts to new format

This commit is contained in:
2023-12-30 17:34:59 +01:00
parent 00ea25e389
commit 443c20a559
3 changed files with 9 additions and 9 deletions

View File

@@ -1,13 +1,13 @@
import { REST, Routes } from "discord.js" import { REST, Routes } from "discord.js"
import config from "../src/utils/Config" import env from "../src/utils/Env"
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken) const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
async function deleteCommands() { async function deleteCommands() {
try { try {
console.log("Started deleting application (/) commands.") console.log("Started deleting application (/) commands.")
await rest.put( await rest.put(
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid), Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
{ body: [] }, { body: [] },
) )
console.log("Successfully deleted application (/) commands.") console.log("Successfully deleted application (/) commands.")

View File

@@ -1,8 +1,8 @@
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js" import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
import fs from "node:fs" import fs from "node:fs"
import { Command } from "../src/interfaces" import { Command } from "../src/interfaces"
import config from "../src/utils/Config" import env from "../src/utils/Env"
const rest = new REST({ version: "10" }).setToken(config.prod.token) const rest = new REST({ version: "10" }).setToken(env.prod.token!)
const commands: RESTPutAPIApplicationCommandsJSONBody = [] const commands: RESTPutAPIApplicationCommandsJSONBody = []
const commandFiles = fs.readdirSync("./dist/src/commands").filter(file => file.endsWith(".js")) const commandFiles = fs.readdirSync("./dist/src/commands").filter(file => file.endsWith(".js"))
@@ -22,7 +22,7 @@ for (const file of contentMenuCommands) {
console.log(`Started refreshing ${commands.length} application (/) commands.`) console.log(`Started refreshing ${commands.length} application (/) commands.`)
const data = await rest.put( const data = await rest.put(
Routes.applicationCommands(config.dev.clientid), Routes.applicationCommands(env.dev.clientid!),
{ body: commands }, { body: commands },
) as RESTGetAPIApplicationGuildCommandResult[] ) as RESTGetAPIApplicationGuildCommandResult[]

View File

@@ -1,8 +1,8 @@
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js" import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
import fs from "fs" import fs from "fs"
import config from "../src/utils/Config" import env from "../src/utils/Env"
import { Command } from "../src/interfaces" import { Command } from "../src/interfaces"
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken) const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
const commands: RESTPutAPIApplicationCommandsJSONBody = [] const commands: RESTPutAPIApplicationCommandsJSONBody = []
const commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(".js")) const commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(".js"))
@@ -26,7 +26,7 @@ for (const file of contentMenuCommands) {
console.log(`Started refreshing ${commands.length} application (/) commands.`) console.log(`Started refreshing ${commands.length} application (/) commands.`)
const data = await rest.put( const data = await rest.put(
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid), Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
{ body: commands }, { body: commands },
) as RESTGetAPIApplicationGuildCommandResult[] ) as RESTGetAPIApplicationGuildCommandResult[]