Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup audio_recording_merged example #2093

Merged
merged 2 commits into from
Jun 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions examples/audio_recording_merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from discord.sinks import MP3Sink

bot = discord.Bot()
connections: dict[int, discord.VoiceClient] = {}


@bot.event
Expand Down Expand Up @@ -55,8 +54,7 @@ async def join(ctx: discord.ApplicationContext):
if not voice:
return await ctx.respond("You're not in a vc right now")

vc = await voice.channel.connect()
connections.update({ctx.guild.id: vc})
await voice.channel.connect()

await ctx.respond("Joined!")

Expand All @@ -69,7 +67,7 @@ async def start(ctx: discord.ApplicationContext):
if not voice:
return await ctx.respond("You're not in a vc right now")

vc = connections.get(ctx.guild.id)
vc: discord.VoiceClient = ctx.voice_client

if not vc:
return await ctx.respond(
Expand All @@ -80,7 +78,7 @@ async def start(ctx: discord.ApplicationContext):
MP3Sink(),
finished_callback,
ctx.channel,
sync_start=True,
sync_start=True, # WARNING: This feature is very unstable and may break at any time.
)

await ctx.respond("The recording has started!")
Expand All @@ -89,7 +87,7 @@ async def start(ctx: discord.ApplicationContext):
@bot.command()
async def stop(ctx: discord.ApplicationContext):
"""Stop the recording"""
vc = connections.get(ctx.guild.id)
vc: discord.VoiceClient = ctx.voice_client

if not vc:
return await ctx.respond("There's no recording going on right now")
Expand All @@ -102,7 +100,7 @@ async def stop(ctx: discord.ApplicationContext):
@bot.command()
async def leave(ctx: discord.ApplicationContext):
"""Leave the voice channel!"""
vc = connections.get(ctx.guild.id)
vc: discord.VoiceClient = ctx.voice_client

if not vc:
return await ctx.respond("I'm not in a vc right now")
Expand Down