From 51b868268ad63e0cd44c2766a373ec24b1eabc58 Mon Sep 17 00:00:00 2001 From: indifferentketchup <159190319+indifferentketchup@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:44:45 -0500 Subject: [PATCH] command --- commands/register.js | 7 +++++++ handlers/commands.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/commands/register.js b/commands/register.js index da4ec13..cf75c7f 100644 --- a/commands/register.js +++ b/commands/register.js @@ -365,6 +365,13 @@ async function registerCommands() { .setIntegrationTypes([ApplicationIntegrationType.GuildInstall]) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + new SlashCommandBuilder() + .setName('ids') + .setDescription('List all channel and role IDs in this server') + .setContexts([InteractionContextType.Guild]) + .setIntegrationTypes([ApplicationIntegrationType.GuildInstall]) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), + new SlashCommandBuilder() .setName('accountinfo') .setDescription('Look up website account info by email or Discord user') diff --git a/handlers/commands.js b/handlers/commands.js index b4b05f0..c116166 100644 --- a/handlers/commands.js +++ b/handlers/commands.js @@ -967,6 +967,49 @@ async function handleCommand(interaction) { await interaction.editReply('❌ An error occurred while fetching statistics.'); } } + + // /ids – list channel and role IDs (like discord.py guild.channels / guild.roles) + if (interaction.commandName === 'ids') { + trackInteraction('commands', 'ids', interaction.user.tag); + await interaction.deferReply({ ephemeral: true }); + const guild = interaction.guild; + if (!guild) { + await interaction.editReply('This command can only be used in a server.'); + return; + } + try { + await guild.channels.fetch().catch(() => {}); + + const channelTypeName = type => + Object.entries(ChannelType).find(([, v]) => v === type)?.[0] ?? String(type); + + const lines = ['**Channels:**']; + const channels = [...guild.channels.cache.values()].sort((a, b) => a.rawPosition - b.rawPosition); + for (const ch of channels) { + lines.push(`\`${ch.id}\` — ${ch.name} (${channelTypeName(ch.type)})`); + } + lines.push(''); + lines.push('**Roles:**'); + const roles = [...guild.roles.cache.values()].sort((a, b) => b.position - a.position); + for (const role of roles) { + lines.push(`\`${role.id}\` — ${role.name}`); + } + + const text = lines.join('\n'); + if (text.length <= 1900) { + await interaction.editReply(text); + } else { + const buf = Buffer.from(text, 'utf8'); + await interaction.editReply({ + content: 'List is long; sent as a file.', + files: [new AttachmentBuilder(buf, { name: `guild-ids-${guild.id}.txt` })] + }); + } + } catch (err) { + trackError('ids-command', err, interaction); + await interaction.editReply('Failed to build ID list.'); + } + } } /**