command deploy stucked

Hello I was creating a Discord bot using https://github.com/OfficialDelta/TypeScript-Discord.js-v14-Template . It worked normally until a day ago, but after a day, I'm waiting for the Slash Command DeFlow to infinity. Did I do something wrong? P.S. Never touched a slash command or a deployment code
GitHub
GitHub - OfficialDelta/TypeScript-Discord.js-v14-Template: A quick-...
A quick-start template for Discord.js v14 in TypeScript that contains handling for commands, events, and interactions! - GitHub - OfficialDelta/TypeScript-Discord.js-v14-Template: A quick-start tem...
No description
5 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
lunaticboy
lunaticboyOP11mo ago
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { REST } from '@discordjs/rest'
import { RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js'
import { readdirSync } from 'fs'
import type ApplicationCommand from './templates/ApplicationCommand.js'
const { TOKEN, CLIENT_ID } = process.env

export default async function deployGlobalCommands() {
const commands: RESTPostAPIApplicationCommandsJSONBody[] = []
const commandFiles: string[] = readdirSync('./commands').filter(
(file) => file.endsWith('.js') || file.endsWith('.ts')
)

for (const file of commandFiles) {
const command: ApplicationCommand = (await import(`./commands/${file}`))
.default as ApplicationCommand
const commandData = command.data.toJSON()
commands.push(commandData)
}

const rest = new REST({ version: '10' }).setToken(TOKEN as string)

try {
console.log('Started refreshing application (/) commands.')

await rest.put(Routes.applicationCommands(CLIENT_ID as string), {
body: []
})

await rest.put(Routes.applicationCommands(CLIENT_ID as string), {
body: commands
})

console.log('Successfully reloaded application (/) commands.')
} catch (error) {
console.error(error)
}
}
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { REST } from '@discordjs/rest'
import { RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js'
import { readdirSync } from 'fs'
import type ApplicationCommand from './templates/ApplicationCommand.js'
const { TOKEN, CLIENT_ID } = process.env

export default async function deployGlobalCommands() {
const commands: RESTPostAPIApplicationCommandsJSONBody[] = []
const commandFiles: string[] = readdirSync('./commands').filter(
(file) => file.endsWith('.js') || file.endsWith('.ts')
)

for (const file of commandFiles) {
const command: ApplicationCommand = (await import(`./commands/${file}`))
.default as ApplicationCommand
const commandData = command.data.toJSON()
commands.push(commandData)
}

const rest = new REST({ version: '10' }).setToken(TOKEN as string)

try {
console.log('Started refreshing application (/) commands.')

await rest.put(Routes.applicationCommands(CLIENT_ID as string), {
body: []
})

await rest.put(Routes.applicationCommands(CLIENT_ID as string), {
body: commands
})

console.log('Successfully reloaded application (/) commands.')
} catch (error) {
console.error(error)
}
}
deploy code
treble/luna
treble/luna11mo ago
dont refresh your commands every time your bot start Because you're probably ratelimited
lunaticboy
lunaticboyOP11mo ago
Thanks! I think you're right. I restarted the bot more than 50 times today to fix the FeelsBadMan
treble/luna
treble/luna11mo ago
The deploy script should be a separate file
Want results from more Discord servers?
Add your server