2021-12-16 00:58:46 +01:00
|
|
|
require("dotenv").config()
|
|
|
|
const fs = require("fs")
|
|
|
|
const {REST} = require("@discordjs/rest")
|
|
|
|
const {Routes} = require("discord-api-types/v9")
|
|
|
|
const commands = []
|
|
|
|
|
2022-01-31 17:54:45 +01:00
|
|
|
const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWith(".js"))
|
2021-12-16 00:58:46 +01:00
|
|
|
|
2022-01-31 17:54:45 +01:00
|
|
|
commandFiles.forEach(commandFile => {
|
|
|
|
const command = require(`./commands/${commandFile}`)
|
2021-12-16 00:58:46 +01:00
|
|
|
commands.push(command.data.toJSON())
|
|
|
|
})
|
|
|
|
|
|
|
|
const restClient = new REST({version: "9"}).setToken(process.env.DISCORD_BOT_TOKEN)
|
|
|
|
restClient.put(Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, process.env.DISCORD_GUILD_ID),
|
|
|
|
{body: commands})
|
2022-01-31 17:56:47 +01:00
|
|
|
.then(() => console.log("Successully registerd commands"))
|
|
|
|
.catch(console.error)
|