Updated scripts to use esm syntax

Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
2024-09-08 22:46:19 +02:00
parent a6a328d124
commit a6f7cf78dc
3 changed files with 39 additions and 46 deletions

View File

@@ -3,16 +3,13 @@ import env from "../src/utils/Env"
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken)
async function deleteCommands() {
try {
try {
console.log("Started deleting application (/) commands.")
await rest.put(
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
{ body: [] }
)
console.log("Successfully deleted application (/) commands.")
} catch (error) {
} catch (error) {
console.error(error)
}
}
deleteCommands()

View File

@@ -10,16 +10,15 @@ const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWi
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 }
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 }
commands.push(command.data.toJSON())
}
;(async () => {
try {
try {
console.log(color(`Started refreshing ${commands.length} application (/) commands.`, "green"))
const commandsString = commands.map(command => " " + command.name)
@@ -32,7 +31,6 @@ for (const file of contentMenuCommands) {
console.log(color(`Successfully reloaded ${commands.length} application (/) commands.`, "green"))
process.exit(0)
})
} catch (error) {
} catch (error) {
console.error(error)
}
})()
}

View File

@@ -9,20 +9,19 @@ 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 {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`)
await rest.put(
@@ -32,7 +31,6 @@ for (const file of contentMenuCommands) {
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
process.exit(0)
})
} catch (error) {
} catch (error) {
console.error(error)
}
})()
}