Updated scripts to use esm syntax
Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
@@ -9,30 +9,28 @@ const commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsW
|
||||
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(".ts"))
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command: ICommand = require(`../src/commands/${file}`)
|
||||
const { default: command } = await import(`../src/commands/${file}`) as { default: ICommand }
|
||||
if (command.dev) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
}
|
||||
for (const file of contentMenuCommands) {
|
||||
const command: ICommand = require(`../src/commands-contextmenu/${file}`)
|
||||
const { default: command } = await import(`../src/commands-contextmenu/${file}`) as { default: ICommand }
|
||||
if (command.dev) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
||||
{ body: commands }
|
||||
).then(() => {
|
||||
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
|
||||
process.exit(0)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})()
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
||||
{ body: commands }
|
||||
).then(() => {
|
||||
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
|
||||
process.exit(0)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user