Skip to content

Commit 8791b6b

Browse files
authored
chore: cleanup audio_recording_merged example (#2093)
* Cleanup example * move warning
1 parent 7f192fe commit 8791b6b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

examples/audio_recording_merged.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from discord.sinks import MP3Sink
77

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

1110

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

58-
vc = await voice.channel.connect()
59-
connections.update({ctx.guild.id: vc})
57+
await voice.channel.connect()
6058

6159
await ctx.respond("Joined!")
6260

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

72-
vc = connections.get(ctx.guild.id)
70+
vc: discord.VoiceClient = ctx.voice_client
7371

7472
if not vc:
7573
return await ctx.respond(
@@ -80,7 +78,7 @@ async def start(ctx: discord.ApplicationContext):
8078
MP3Sink(),
8179
finished_callback,
8280
ctx.channel,
83-
sync_start=True,
81+
sync_start=True, # WARNING: This feature is very unstable and may break at any time.
8482
)
8583

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

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

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

0 commit comments

Comments
 (0)