6
6
from discord .sinks import MP3Sink
7
7
8
8
bot = discord .Bot ()
9
- connections : dict [int , discord .VoiceClient ] = {}
10
9
11
10
12
11
@bot .event
@@ -55,8 +54,7 @@ async def join(ctx: discord.ApplicationContext):
55
54
if not voice :
56
55
return await ctx .respond ("You're not in a vc right now" )
57
56
58
- vc = await voice .channel .connect ()
59
- connections .update ({ctx .guild .id : vc })
57
+ await voice .channel .connect ()
60
58
61
59
await ctx .respond ("Joined!" )
62
60
@@ -69,7 +67,7 @@ async def start(ctx: discord.ApplicationContext):
69
67
if not voice :
70
68
return await ctx .respond ("You're not in a vc right now" )
71
69
72
- vc = connections . get ( ctx .guild . id )
70
+ vc : discord . VoiceClient = ctx .voice_client
73
71
74
72
if not vc :
75
73
return await ctx .respond (
@@ -80,7 +78,7 @@ async def start(ctx: discord.ApplicationContext):
80
78
MP3Sink (),
81
79
finished_callback ,
82
80
ctx .channel ,
83
- sync_start = True ,
81
+ sync_start = True , # WARNING: This feature is very unstable and may break at any time.
84
82
)
85
83
86
84
await ctx .respond ("The recording has started!" )
@@ -89,7 +87,7 @@ async def start(ctx: discord.ApplicationContext):
89
87
@bot .command ()
90
88
async def stop (ctx : discord .ApplicationContext ):
91
89
"""Stop the recording"""
92
- vc = connections . get ( ctx .guild . id )
90
+ vc : discord . VoiceClient = ctx .voice_client
93
91
94
92
if not vc :
95
93
return await ctx .respond ("There's no recording going on right now" )
@@ -102,7 +100,7 @@ async def stop(ctx: discord.ApplicationContext):
102
100
@bot .command ()
103
101
async def leave (ctx : discord .ApplicationContext ):
104
102
"""Leave the voice channel!"""
105
- vc = connections . get ( ctx .guild . id )
103
+ vc : discord . VoiceClient = ctx .voice_client
106
104
107
105
if not vc :
108
106
return await ctx .respond ("I'm not in a vc right now" )
0 commit comments