DiscordBot_Nyan9000/src/deploy-commands.js

17 lines
670 B
JavaScript
Raw Normal View History

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 = []
const CommandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWith(".js"))
CommandFiles.forEach(CommandFile => {
const command = require(`./commands/${CommandFile}`)
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})
.then(() => console.log("Successully registerd commands"))