Skip to content

Commit 0e98bc3

Browse files
authored
feat: add get audio functions (#837)
* feat: add audio function * feat: `get_user_audio` * chore: make `user` a snowflake
1 parent eb6e4d9 commit 0e98bc3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

discord/sinks/core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import sys
2828
import threading
2929
import time
30+
from ..types import snowflake
3031

3132
from .errors import SinkException
3233

@@ -210,4 +211,12 @@ def cleanup(self):
210211
self.finished = True
211212
for file in self.audio_data.values():
212213
file.cleanup()
213-
self.format_audio(file)
214+
self.format_audio(file)
215+
216+
def get_all_audio(self):
217+
"""Gets all audio files."""
218+
return [os.path.realpath(x.file) for x in self.audio_data.values()]
219+
220+
def get_user_audio(self, user: snowflake.Snowflake):
221+
"""Gets the audio file(s) of one specific user."""
222+
return os.path.realpath(self.audio_data.pop(user))

examples/audio_recording.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ async def start(ctx: ApplicationContext, encoding: Option(str, choices=["mp3", "
4646
await ctx.respond("The recording has started!")
4747

4848

49-
async def finished_callback(sink, channel, *args):
49+
async def finished_callback(sink, channel: discord.TextChannel, *args):
5050

5151
recorded_users = [
5252
f" <@{user_id}> ({os.path.split(audio.file)[1]}) "
5353
for user_id, audio in sink.audio_data.items()
5454
]
5555
await sink.vc.disconnect()
56-
await channel.send(f"Finished! Recorded audio for {', '.join(recorded_users)}.")
56+
files = sink.get_all_audio()
57+
await channel.send(f"Finished! Recorded audio for {', '.join(recorded_users)}.", files=files)
5758

5859
@bot.command()
5960
async def stop(ctx):

0 commit comments

Comments
 (0)