General structure works
This commit is contained in:
32
src/utilties/discord/command_utils.ts
Normal file
32
src/utilties/discord/command_utils.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { REST, Routes } from "discord.js"
|
||||
import { config } from "../../config"
|
||||
import { commands } from "../../commands"
|
||||
|
||||
const commandsData = Object.values(commands)
|
||||
.filter((command) => command.enabled)
|
||||
.map((command) => command.data)
|
||||
|
||||
const rest : REST = new REST({ version: "10" }).setToken(config.DISCORD_TOKEN)
|
||||
|
||||
export async function deployCommands(guildId: string) {
|
||||
try {
|
||||
// TODO Winston should handle this
|
||||
console.log(`Refreshing slash commands for ${guildId}`)
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(
|
||||
config.DISCORD_CLIENT_ID,
|
||||
guildId
|
||||
),
|
||||
{
|
||||
body: commandsData
|
||||
}
|
||||
)
|
||||
|
||||
// TODO Winston should handle this
|
||||
console.log(`Successfully reloaded slash commands for ${guildId}`)
|
||||
} catch (error) {
|
||||
// TODO Winston should handle this
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
5
src/utilties/index.ts
Normal file
5
src/utilties/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as command_utils from "./discord/command_utils"
|
||||
|
||||
export const utilities = {
|
||||
command_utils
|
||||
}
|
||||
Reference in New Issue
Block a user