mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
Add commands dir import to examples register commands (#3848)
This commit is contained in:
@@ -1,7 +1,16 @@
|
|||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
import { bot } from './bot.js'
|
import { bot } from './bot.js'
|
||||||
|
import importDirectory from './utils/loader.js'
|
||||||
import { updateApplicationCommands } from './utils/updateCommands.js'
|
import { updateApplicationCommands } from './utils/updateCommands.js'
|
||||||
|
|
||||||
|
bot.logger.info('Loading commands...')
|
||||||
|
await importDirectory('./dist/commands')
|
||||||
|
|
||||||
bot.logger.info('Updating commands...')
|
bot.logger.info('Updating commands...')
|
||||||
await updateApplicationCommands()
|
await updateApplicationCommands()
|
||||||
|
|
||||||
|
bot.logger.info('Done!')
|
||||||
|
|
||||||
|
// We need to manually exit as the REST Manager has timeouts that will keep NodeJS alive
|
||||||
|
process.exit()
|
||||||
|
|||||||
@@ -2,6 +2,15 @@ import 'dotenv/config'
|
|||||||
|
|
||||||
import { bot } from './bot.js'
|
import { bot } from './bot.js'
|
||||||
import { updateCommands } from './utils/helpers.js'
|
import { updateCommands } from './utils/helpers.js'
|
||||||
|
import importDirectory from './utils/loader.js'
|
||||||
|
|
||||||
|
bot.logger.info('Loading commands...')
|
||||||
|
await importDirectory('./dist/commands')
|
||||||
|
|
||||||
bot.logger.info('Updating commands...')
|
bot.logger.info('Updating commands...')
|
||||||
await updateCommands()
|
await updateCommands()
|
||||||
|
|
||||||
|
bot.logger.info('Done!')
|
||||||
|
|
||||||
|
// We need to manually exit as the REST Manager has timeouts that will keep NodeJS alive
|
||||||
|
process.exit()
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
|
import { join as joinPath } from 'node:path'
|
||||||
|
import { getDirnameFromFileUrl } from '../util.js'
|
||||||
|
import { bot } from './bot.js'
|
||||||
|
import importDirectory from './utils/loader.js'
|
||||||
import { updateCommands } from './utils/updateCommands.js'
|
import { updateCommands } from './utils/updateCommands.js'
|
||||||
|
|
||||||
|
// The importDirectory function uses 'readdir' that requires either a relative path compared to the process CWD or an absolute one, so to get one relative we need to use import.meta.url
|
||||||
|
const currentDirectory = getDirnameFromFileUrl(import.meta.url)
|
||||||
|
|
||||||
|
await importDirectory(joinPath(currentDirectory, './commands'))
|
||||||
|
|
||||||
await updateCommands()
|
await updateCommands()
|
||||||
|
|
||||||
|
bot.logger.info('Done!')
|
||||||
|
|
||||||
|
// We need to manually exit as the REST Manager has timeouts that will keep NodeJS alive
|
||||||
|
process.exit()
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
|
import importDirectory from './utils/loader.js'
|
||||||
import logger from './utils/logger.js'
|
import logger from './utils/logger.js'
|
||||||
import { updateApplicationCommands } from './utils/updateCommands.js'
|
import { updateApplicationCommands } from './utils/updateCommands.js'
|
||||||
|
|
||||||
|
logger.info('Loading commands...')
|
||||||
|
await importDirectory('./dist/commands')
|
||||||
|
|
||||||
logger.info('Updating commands...')
|
logger.info('Updating commands...')
|
||||||
await updateApplicationCommands()
|
await updateApplicationCommands()
|
||||||
|
|
||||||
|
logger.info('Done!')
|
||||||
|
|
||||||
|
// We need to manually exit as the REST Manager has timeouts that will keep NodeJS alive
|
||||||
|
process.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user