generated from nhcarrigan/template
feat: merge forward-to-owner context command (#13)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @copyright NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Teklu Abayneh
|
||||
*/
|
||||
|
||||
import { REST, Routes } from "discord.js";
|
||||
import { forwardOwnerDM } from "../commands/forwardToOwner.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
|
||||
const commands = [ forwardOwnerDM.data.toJSON() ];
|
||||
const token = process.env.BOT_TOKEN;
|
||||
const clientId = process.env.GH_CLIENT_ID;
|
||||
|
||||
if (token === undefined) {
|
||||
throw new Error("BOT_TOKEN is missing from environment variables!");
|
||||
}
|
||||
if (clientId === undefined) {
|
||||
throw new Error("CLIENT_ID is missing from environment variables!");
|
||||
}
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(token);
|
||||
const requestCommand = async(): Promise<void> => {
|
||||
try {
|
||||
await rest.put(Routes.applicationCommands(clientId), { body: commands });
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
await logger.error("operation", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
void requestCommand();
|
||||
Reference in New Issue
Block a user