Fix deploy
This commit is contained in:
parent
16ddd8b388
commit
c908a524aa
1 changed files with 10 additions and 18 deletions
|
@ -9,16 +9,20 @@ const { clientId, guildId, token } = process.env;
|
|||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const commands = [];
|
||||
|
||||
const categoryPath = fs.readdirSync(`${__dirname}/../commands`);
|
||||
categoryPath.forEach(category => {
|
||||
loadCommandFromDir(category);
|
||||
});
|
||||
commands.map(command => command.toJSON());
|
||||
for (let i = 0; i < categoryPath.length; i++) {
|
||||
const commandsPath = path.join(`${__dirname}/../commands`, categoryPath[i]);
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = await import(filePath);
|
||||
commands.push(command.default.data.toJSON());
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '9' }).setToken(token);
|
||||
|
||||
if (process.argv[2] === 'global') {
|
||||
rest.put(Routes.applicationCommands(clientId), { body: commands })
|
||||
.then(() => console.log('Successfully registered application commands globally.'))
|
||||
|
@ -33,15 +37,3 @@ else if (process.argv[2] === 'delete') {
|
|||
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
|
||||
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
|
||||
.catch(console.error);
|
||||
|
||||
async function loadCommandFromDir(dir) {
|
||||
const commandsPath = path.join(`${__dirname}/../commands`, dir);
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
let command = await import(filePath);
|
||||
command = command.default;
|
||||
commands.push(command.data);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue