command
This commit is contained in:
@@ -365,6 +365,13 @@ async function registerCommands() {
|
|||||||
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
.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()
|
new SlashCommandBuilder()
|
||||||
.setName('accountinfo')
|
.setName('accountinfo')
|
||||||
.setDescription('Look up website account info by email or Discord user')
|
.setDescription('Look up website account info by email or Discord user')
|
||||||
|
|||||||
@@ -967,6 +967,49 @@ async function handleCommand(interaction) {
|
|||||||
await interaction.editReply('❌ An error occurred while fetching statistics.');
|
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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user