From e525f8da10469faaa85fe6293da0c3d4088598f9 Mon Sep 17 00:00:00 2001 From: osmarks Date: Wed, 31 Mar 2021 22:45:27 +0100 Subject: [PATCH] somewhat hacky "stage" support (requires accursed patch to d.py channel factory, channeltypes enum) --- src/voice.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/voice.py b/src/voice.py index 9d8a27a..37e4426 100644 --- a/src/voice.py +++ b/src/voice.py @@ -7,7 +7,6 @@ import requests import io from discord.ext import commands - class HTTPSource(discord.AudioSource): def __init__(self, url): self.url = url @@ -24,15 +23,20 @@ def setup(bot): async def radio(ctx): pass @radio.command() - async def connect(ctx, thing="main"): - voice = ctx.author.voice - if not voice: return await ctx.send(embed=util.error_embed("You are not in a voice channel.")) - if voice.mute: return await ctx.send(embed=util.error_embed("You are muted.")) + async def connect(ctx, thing="main", channel_id: int = None): thing_url = util.config["radio_urls"].get(thing, None) if thing_url == None: return await ctx.send(embed=util.error_embed("No such radio thing.")) + if channel_id: + channel = await bot.fetch_channel(channel_id) + if not channel: return await ctx.send(embed=util.error_embed("No such channel.")) + else: + voice = ctx.author.voice + if not voice: return await ctx.send(embed=util.error_embed("You are not in a voice channel.")) + if voice.mute: return await ctx.send(embed=util.error_embed("You are muted.")) + channel = voice.channel existing = ctx.guild.voice_client if existing: await existing.disconnect() - vc = await voice.channel.connect() + vc = await channel.connect() src = HTTPSource(thing_url) await src.start() vc.play(src)