33 lines
973 B
TypeScript
33 lines
973 B
TypeScript
|
// Dotenv initialization
|
||
|
import path from "path";
|
||
|
import dotenv from "dotenv";
|
||
|
dotenv.config({ path: path.join(__dirname, "../.env") });
|
||
|
|
||
|
// Environment checking
|
||
|
const TOKEN = process.env["TOKEN"];
|
||
|
const CLIENT_ID = process.env["CLIENT_ID"];
|
||
|
|
||
|
if (!TOKEN) throw new ReferenceError("Environment variable TOKEN is missing");
|
||
|
if (!CLIENT_ID) throw new ReferenceError("Environment variable CLIENT_ID is missing");
|
||
|
|
||
|
// Deployment
|
||
|
import { REST, Routes } from "discord.js";
|
||
|
import { array as commands } from "../src/commands/ci";
|
||
|
|
||
|
const API = new REST({ version: "10" }).setToken(TOKEN);
|
||
|
|
||
|
(async () => {
|
||
|
try {
|
||
|
console.log("Start deploying slash commands for Dev guild");
|
||
|
|
||
|
const data = await API.put(
|
||
|
Routes.applicationGuildCommands(CLIENT_ID, "853049355984437269"),
|
||
|
{ body: commands },
|
||
|
);
|
||
|
|
||
|
console.log(`Successfully deployed ${(data as any).length} commands`);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
})();
|