Skip to content

Commit

Permalink
[Discord] Invoke audio join command in audio command
Browse files Browse the repository at this point in the history
Harmon758 committed Nov 20, 2023
1 parent 2efa149 commit 2eee39d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Discord/cogs/audio.py
Original file line number Diff line number Diff line change
@@ -62,13 +62,16 @@ async def audio(self, ctx, *, song: Optional[str]): #elif options[0] == "full":
# Note: spotify command invokes this command
# Note: youtube command invokes this command
if not ctx.guild.voice_client:
if ctx.guild.id not in self.players:
self.players[ctx.guild.id] = AudioPlayer.from_context(ctx)
if ctx.author.voice and ctx.author.voice.channel:
await ctx.author.voice.channel.connect()
await ctx.embed_reply(":headphones: I've joined the voice channel")
if command := ctx.bot.get_command("audio join"):
joined = await ctx.invoke(
command, channel = parameters.default_voice_channel(ctx)
)
if not joined:
return
else:
raise errors.PermittedVoiceNotConnected
raise RuntimeError(
"audo join command not found when audio command invoked"
)
if not song:
await ctx.embed_reply(":grey_question: What would you like to play?")
return
@@ -192,13 +195,14 @@ async def audio_join(
Voice channel for me to join
(Defaults to the/your current channel)
'''
# Note: audio command invokes this command
# Note: join command invokes this command
# TODO: Permit all when not in voice channel?
if ctx.guild.id not in self.players:
self.players[ctx.guild.id] = AudioPlayer.from_context(ctx)
if not channel:
await ctx.embed_reply(":no_entry: Voice channel not found")
return
return False
try:
if ctx.guild.voice_client:
await ctx.guild.voice_client.move_to(channel)
@@ -210,11 +214,13 @@ async def audio_join(
await ctx.embed_reply(
":headphones: I've joined the voice channel"
)
return True
except concurrent.futures.TimeoutError:
await ctx.embed_reply(
":no_entry: Error joining the voice channel\n"
"Please check that I'm permitted to join"
)
return False

@commands.command(aliases = ["summon", "move"])
@commands.check_any(

0 comments on commit 2eee39d

Please sign in to comment.