Skip to content

Commit c8bc1c5

Browse files
committed
fix: port example changes
1 parent d62182a commit c8bc1c5

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

examples/audio_recording.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
import discord
3-
from discord.commands import Option
3+
from discord.commands import Option, ApplicationContext
44

55
bot = discord.Bot(debug_guilds=[...])
66
bot.connections = {}
77

88

99
@bot.command()
10-
async def start(ctx, encoding: Option(str, choices=["mp3", "wav", "pcm"])):
10+
async def start(ctx: ApplicationContext, encoding: Option(str, choices=["mp3", "wav", "pcm", "ogg", "mka", "mkv", "mp4", "m4a",])):
1111
"""
1212
Record your voice!
1313
"""
@@ -20,8 +20,25 @@ async def start(ctx, encoding: Option(str, choices=["mp3", "wav", "pcm"])):
2020
vc = await voice.channel.connect()
2121
bot.connections.update({ctx.guild.id: vc})
2222

23+
if encoding == "mp3":
24+
sink = discord.sinks.MP4Sink()
25+
elif encoding == "wav":
26+
sink = discord.sinks.WaveSink()
27+
elif encoding == "pcm":
28+
sink = discord.sinks.PCMSink()
29+
elif encoding == "ogg":
30+
sink = discord.sinks.OGGSink()
31+
elif encoding == "mka":
32+
sink = discord.sinks.MKASink()
33+
elif encoding == "mkv":
34+
sink = discord.sinks.MKVSink()
35+
elif encoding == "mp4":
36+
sink = discord.sinks.MP4Sink()
37+
elif encoding == "m4a":
38+
sink = discord.sinks.M4ASink()
39+
2340
vc.start_recording(
24-
discord.Sink(encoding=encoding),
41+
sink,
2542
finished_callback,
2643
ctx.channel,
2744
)

0 commit comments

Comments
 (0)