Skip to content

Commit 13068a1

Browse files
committed
feat: debug command IDs flag
1 parent 5bb6c45 commit 13068a1

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/data/dms/active-role-granted.embed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const data: EmbedData = {
77
'You are now permitted to upload images and share links in our community.',
88
'Please use this privilege responsibly, abuse will result in removal of this role.',
99
'',
10-
'– Modrinth Moderation Team',
10+
'– Modrinth Discord Moderation Team',
1111
].join('\n'),
1212
}
1313

src/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { db } from './db'
1111
import { createMessageHandlers, createReactionHandlers } from './types/listeners'
1212
import { startWebServer } from './web'
1313

14+
const DEBUG_COMMAND_IDS = process.argv.includes('--debug-command-ids')
15+
1416
// Handle CLI flags before booting the bot
1517
if (process.argv.includes('--deploy-commands')) {
1618
await deployCommands()
@@ -31,6 +33,38 @@ const client = new Client({
3133

3234
client.once(Events.ClientReady, async (readyClient) => {
3335
console.log(`Bot is ready, logged in as ${readyClient.user.tag}`)
36+
37+
// Optionally list all registered application commands and their IDs
38+
if (DEBUG_COMMAND_IDS) {
39+
try {
40+
// Global application commands
41+
const global = await readyClient.application!.commands.fetch()
42+
console.log(`[Debug][Commands] Global commands: ${global.size}`)
43+
for (const [, cmd] of global) {
44+
console.log(` - /${cmd.name} (${cmd.id})`)
45+
}
46+
47+
// Guild-scoped commands per guild
48+
for (const [, guild] of readyClient.guilds.cache) {
49+
try {
50+
const guildCmds = await guild.commands.fetch()
51+
console.log(
52+
`[Debug][Commands] Guild ${guild.name} (${guild.id}) commands: ${guildCmds.size}`,
53+
)
54+
for (const [, cmd] of guildCmds) {
55+
console.log(` - /${cmd.name} (${cmd.id})`)
56+
}
57+
} catch (err) {
58+
console.warn(
59+
`[Debug][Commands] Failed to fetch guild commands for ${guild.name} (${guild.id})`,
60+
err,
61+
)
62+
}
63+
}
64+
} catch (err) {
65+
console.warn('[Debug][Commands] Failed to fetch application commands', err)
66+
}
67+
}
3468
for (const [, guild] of client.guilds.cache) {
3569
try {
3670
const active = await guild.channels.fetchActiveThreads()

0 commit comments

Comments
 (0)