@getsolara/solara.js
Version:
A lightweight and modular Discord bot framework built on discord.js v14, with truly optional feature packages.
26 lines • 1.45 kB
JavaScript
const { ChannelType } = require('discord.js');
module.exports = {
name: "$channelIDs",
description: "Returns a semicolon-separated list of channel IDs in the current guild. Args: [type=text/voice/category/any]",
takesBrackets: true,
execute: async (context, args) => {
if (!context.guild) return "[Error: $channelIDs requires a guild context]";
const typeFilter = args[0]?.toLowerCase();
let targetType = null;
if (typeFilter) {
switch(typeFilter) {
case 'text': targetType = ChannelType.GuildText; break; case 'voice': targetType = ChannelType.GuildVoice; break;
case 'category': targetType = ChannelType.GuildCategory; break; case 'news': targetType = ChannelType.GuildAnnouncement; break;
case 'stage': targetType = ChannelType.GuildStageVoice; break; case 'forum': targetType = ChannelType.GuildForum; break;
case 'any': break;
default: return `[Error: Invalid channel type filter "${args[0]}"]`;
}
}
try {
await context.guild.channels.fetch();
const channels = context.guild.channels.cache;
const filtered = targetType ? channels.filter(c => c.type === targetType) : channels;
return filtered.map(c => c.id).join(';');
} catch (e) { return "[Error: Failed to fetch channels]"; }
}
};