Added new tryCatch wrapper
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import { REST, Routes } from "discord.js"
|
||||
import env from "../src/utils/Env"
|
||||
import tryCatch from "../src/utils/Functions/trycatch"
|
||||
import { log } from "../src/utils/Logger"
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.DEVTOKEN)
|
||||
|
||||
try {
|
||||
const [error] = await tryCatch(deleteCommands())
|
||||
if (error) log(error, "error")
|
||||
|
||||
async function deleteCommands() {
|
||||
log("Started deleting application (/) commands.", "info")
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(env.dev.DEVID, env.dev.GUILDID),
|
||||
{ body: [] }
|
||||
)
|
||||
log("Successfully deleted application (/) commands.", "info")
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { REST, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
|
||||
import fs from "node:fs"
|
||||
import { ICommand } from "../src/typings"
|
||||
import env from "../src/utils/Env"
|
||||
import tryCatch from "../src/utils/Functions/trycatch"
|
||||
import { log } from "../src/utils/Logger"
|
||||
const rest = new REST({ version: "10" }).setToken(env.prod.TOKEN)
|
||||
|
||||
@@ -18,7 +19,10 @@ for (const file of contentMenuCommands) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
|
||||
try {
|
||||
const [error] = await tryCatch(updateCommands())
|
||||
if (error) log(error, "error")
|
||||
|
||||
async function updateCommands() {
|
||||
log(`Started refreshing ${commands.length} application (/) commands.`, "info", { type: "preset", color: "green" })
|
||||
|
||||
const commandsString = commands.map(command => " " + command.name)
|
||||
@@ -31,6 +35,4 @@ try {
|
||||
log(`Successfully reloaded ${commands.length} application (/) commands.`, "info", { type: "preset", color: "green" })
|
||||
process.exit(0)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { REST, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
|
||||
import fs from "fs"
|
||||
import { ICommand } from "../src/typings"
|
||||
import env from "../src/utils/Env"
|
||||
import tryCatch from "../src/utils/Functions/trycatch"
|
||||
import { log } from "../src/utils/Logger"
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.DEVTOKEN)
|
||||
|
||||
@@ -22,7 +23,10 @@ for (const file of contentMenuCommands) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const [error] = await tryCatch(updateCommands())
|
||||
if (error) log(error, "error")
|
||||
|
||||
async function updateCommands() {
|
||||
log(`Started refreshing ${commands.length} application (/) commands.`, "info")
|
||||
|
||||
await rest.put(
|
||||
@@ -32,6 +36,4 @@ try {
|
||||
log(`Successfully reloaded ${commands.length} application (/) commands.`, "info")
|
||||
process.exit(0)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user