Feat: Show member count in soundboard channel dropdown

Add voice channel member count (non-bot users) to soundboard
channel API response and display it in the dropdown, matching
the radio plugin's existing behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-06 20:02:00 +01:00
parent 9aefc3d470
commit dd71d763cd
2 changed files with 8 additions and 4 deletions

View file

@ -14,7 +14,7 @@ import {
} from '@discordjs/voice';
import sodium from 'libsodium-wrappers';
import nacl from 'tweetnacl';
import { ChannelType, Events, type VoiceState, type Message } from 'discord.js';
import { ChannelType, Events, type VoiceBasedChannel, type VoiceState, type Message } from 'discord.js';
import type { Plugin, PluginContext } from '../../core/plugin.js';
import { sseBroadcast } from '../../core/sse.js';
@ -773,7 +773,10 @@ const soundboardPlugin: Plugin = {
for (const [, ch] of guild.channels.cache) {
if (ch?.type === ChannelType.GuildVoice || ch?.type === ChannelType.GuildStageVoice) {
const sel = persistedState.selectedChannels?.[guild.id];
result.push({ guildId: guild.id, guildName: guild.name, channelId: ch.id, channelName: ch.name, selected: sel === ch.id });
const members = ('members' in ch)
? (ch as VoiceBasedChannel).members.filter(m => !m.user.bot).size
: 0;
result.push({ guildId: guild.id, guildName: guild.name, channelId: ch.id, channelName: ch.name, members, selected: sel === ch.id });
}
}
}

View file

@ -27,6 +27,7 @@ type VoiceChannelInfo = {
guildName: string;
channelId: string;
channelName: string;
members?: number;
selected?: boolean;
};
@ -869,7 +870,7 @@ export default function SoundboardTab({ data }: SoundboardTabProps) {
>
<span className="material-icons cb-icon">headset</span>
{selected && <span className="channel-status" />}
<span className="channel-label">{selectedChannel?.channelName || 'Channel...'}</span>
<span className="channel-label">{selectedChannel ? `${selectedChannel.channelName}${selectedChannel.members ? ` (${selectedChannel.members})` : ''}` : 'Channel...'}</span>
<span className={`material-icons chevron`}>expand_more</span>
</button>
{channelOpen && (
@ -884,7 +885,7 @@ export default function SoundboardTab({ data }: SoundboardTabProps) {
onClick={() => handleChannelSelect(ch)}
>
<span className="material-icons co-icon">volume_up</span>
{ch.channelName}
{ch.channelName}{ch.members ? ` (${ch.members})` : ''}
</div>
))}
</React.Fragment>