mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-06-07 15:39:30 +00:00
chore: add option to undeploy commands and not deploy on start
This commit is contained in:
parent
072c34d778
commit
14667ad69f
5 changed files with 113 additions and 12 deletions
|
@ -17,7 +17,7 @@ const rest = new REST({ version: '10' }).setToken(token);
|
|||
* @param directory - The directory to get files from
|
||||
* @returns - An array of file paths
|
||||
*/
|
||||
const getFilesRecursively = (directory: string): string[] => {
|
||||
export const getFilesRecursively = (directory: string): string[] => {
|
||||
const files: string[] = [];
|
||||
const filesInDirectory = fs.readdirSync(directory);
|
||||
|
||||
|
|
36
src/util/undeployCommands.ts
Normal file
36
src/util/undeployCommands.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { REST, Routes } from 'discord.js';
|
||||
import { loadConfig } from './configLoader.js';
|
||||
|
||||
const config = loadConfig();
|
||||
const { token, clientId, guildId } = config;
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(token);
|
||||
|
||||
/**
|
||||
* Undeploys all commands from the Discord API
|
||||
*/
|
||||
export const undeployCommands = async () => {
|
||||
try {
|
||||
console.log('Undeploying all commands from the Discord API...');
|
||||
|
||||
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
|
||||
body: [],
|
||||
});
|
||||
|
||||
console.log('Successfully undeployed all commands');
|
||||
} catch (error) {
|
||||
console.error('Error undeploying commands:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
if (import.meta.url.endsWith(process.argv[1].replace(/\\/g, '/'))) {
|
||||
undeployCommands()
|
||||
.then(() => {
|
||||
console.log('Undeploy process completed successfully');
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Undeploy process failed:', err);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue