Base structure #2

This commit is contained in:
2022-11-24 02:12:52 +01:00
parent 261627570d
commit d8365128fc
20 changed files with 1528 additions and 41 deletions

33
ci/deploy.ts Normal file
View File

@ -0,0 +1,33 @@
// 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 globally");
const data = await API.put(
Routes.applicationCommands(CLIENT_ID),
{ body: commands },
);
console.log(`Successfully deployed ${(data as any).length} commands`);
}
catch (e) {
console.error(e);
}
})();

33
ci/devDeploy.ts Normal file
View File

@ -0,0 +1,33 @@
// 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);
}
})();