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:
parent
9aefc3d470
commit
dd71d763cd
2 changed files with 8 additions and 4 deletions
|
|
@ -14,7 +14,7 @@ import {
|
||||||
} from '@discordjs/voice';
|
} from '@discordjs/voice';
|
||||||
import sodium from 'libsodium-wrappers';
|
import sodium from 'libsodium-wrappers';
|
||||||
import nacl from 'tweetnacl';
|
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 type { Plugin, PluginContext } from '../../core/plugin.js';
|
||||||
import { sseBroadcast } from '../../core/sse.js';
|
import { sseBroadcast } from '../../core/sse.js';
|
||||||
|
|
||||||
|
|
@ -773,7 +773,10 @@ const soundboardPlugin: Plugin = {
|
||||||
for (const [, ch] of guild.channels.cache) {
|
for (const [, ch] of guild.channels.cache) {
|
||||||
if (ch?.type === ChannelType.GuildVoice || ch?.type === ChannelType.GuildStageVoice) {
|
if (ch?.type === ChannelType.GuildVoice || ch?.type === ChannelType.GuildStageVoice) {
|
||||||
const sel = persistedState.selectedChannels?.[guild.id];
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ type VoiceChannelInfo = {
|
||||||
guildName: string;
|
guildName: string;
|
||||||
channelId: string;
|
channelId: string;
|
||||||
channelName: string;
|
channelName: string;
|
||||||
|
members?: number;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -869,7 +870,7 @@ export default function SoundboardTab({ data }: SoundboardTabProps) {
|
||||||
>
|
>
|
||||||
<span className="material-icons cb-icon">headset</span>
|
<span className="material-icons cb-icon">headset</span>
|
||||||
{selected && <span className="channel-status" />}
|
{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>
|
<span className={`material-icons chevron`}>expand_more</span>
|
||||||
</button>
|
</button>
|
||||||
{channelOpen && (
|
{channelOpen && (
|
||||||
|
|
@ -884,7 +885,7 @@ export default function SoundboardTab({ data }: SoundboardTabProps) {
|
||||||
onClick={() => handleChannelSelect(ch)}
|
onClick={() => handleChannelSelect(ch)}
|
||||||
>
|
>
|
||||||
<span className="material-icons co-icon">volume_up</span>
|
<span className="material-icons co-icon">volume_up</span>
|
||||||
{ch.channelName}
|
{ch.channelName}{ch.members ? ` (${ch.members})` : ''}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue