Updated scripts to use esm syntax
Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
@@ -3,16 +3,13 @@ import env from "../src/utils/Env"
|
|||||||
|
|
||||||
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken)
|
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken)
|
||||||
|
|
||||||
async function deleteCommands() {
|
try {
|
||||||
try {
|
console.log("Started deleting application (/) commands.")
|
||||||
console.log("Started deleting application (/) commands.")
|
await rest.put(
|
||||||
await rest.put(
|
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
||||||
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
{ body: [] }
|
||||||
{ body: [] }
|
)
|
||||||
)
|
console.log("Successfully deleted application (/) commands.")
|
||||||
console.log("Successfully deleted application (/) commands.")
|
} catch (error) {
|
||||||
} catch (error) {
|
console.error(error)
|
||||||
console.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
deleteCommands()
|
|
||||||
|
|||||||
@@ -10,29 +10,27 @@ const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWi
|
|||||||
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu").filter(file => file.endsWith(".ts"))
|
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu").filter(file => file.endsWith(".ts"))
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
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())
|
commands.push(command.data.toJSON())
|
||||||
}
|
}
|
||||||
for (const file of contentMenuCommands) {
|
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())
|
commands.push(command.data.toJSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
try {
|
||||||
try {
|
console.log(color(`Started refreshing ${commands.length} application (/) commands.`, "green"))
|
||||||
console.log(color(`Started refreshing ${commands.length} application (/) commands.`, "green"))
|
|
||||||
|
|
||||||
const commandsString = commands.map(command => " " + command.name)
|
const commandsString = commands.map(command => " " + command.name)
|
||||||
console.log(color(commandsString.join("\n"), "lavender"))
|
console.log(color(commandsString.join("\n"), "lavender"))
|
||||||
|
|
||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationCommands(env.dev.clientid),
|
Routes.applicationCommands(env.dev.clientid),
|
||||||
{ body: commands }
|
{ body: commands }
|
||||||
).then(() => {
|
).then(() => {
|
||||||
console.log(color(`Successfully reloaded ${commands.length} application (/) commands.`, "green"))
|
console.log(color(`Successfully reloaded ${commands.length} application (/) commands.`, "green"))
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
})()
|
|
||||||
|
|||||||
@@ -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"))
|
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(".ts"))
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
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) {
|
if (command.dev) {
|
||||||
commands.push(command.data.toJSON())
|
commands.push(command.data.toJSON())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const file of contentMenuCommands) {
|
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) {
|
if (command.dev) {
|
||||||
commands.push(command.data.toJSON())
|
commands.push(command.data.toJSON())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
try {
|
||||||
try {
|
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
|
||||||
|
|
||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
|
||||||
{ body: commands }
|
{ body: commands }
|
||||||
).then(() => {
|
).then(() => {
|
||||||
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
|
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
})()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user