3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Allow companion_channels to take category ID

This commit is contained in:
Dark 2020-09-21 18:11:18 +02:00
parent 205f7721ea
commit ff053d2f05
5 changed files with 24 additions and 19 deletions

View file

@ -1,3 +1,4 @@
import { VoiceChannel } from "eris";
import { PluginData } from "knub";
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
@ -8,10 +9,13 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
export function getCompanionChannelOptsForVoiceChannelId(
pluginData: PluginData<CompanionChannelsPluginType>,
userId: string,
voiceChannelId: string,
voiceChannel: VoiceChannel,
): TCompanionChannelOpts[] {
const config = pluginData.config.getMatchingConfig({ userId, channelId: voiceChannelId });
const config = pluginData.config.getMatchingConfig({ userId, channelId: voiceChannel.id });
return Object.values(config.entries)
.filter(opts => opts.voice_channel_ids.includes(voiceChannelId))
.filter(
opts =>
opts.voice_channel_ids.includes(voiceChannel.id) || opts.voice_channel_ids.includes(voiceChannel.parentID),
)
.map(opts => Object.assign({}, defaultCompanionChannelOpts, opts));
}