-
Notifications
You must be signed in to change notification settings - Fork 188
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
Update voice recording example #1605
base: stable
Are you sure you want to change the base?
Conversation
The existing example does not work due to missing deferral and missing message body, this fixes both. Signed-off-by: Jason Dilworth <hello@jasondilworth.co.uk>
voice_state = await ctx.author.voice.channel.connect() | ||
|
||
# Start recording | ||
await voice_state.start_recording() | ||
await asyncio.sleep(10) | ||
await voice_state.stop_recording() | ||
await ctx.send(files=[interactions.File(file, file_name="user_id.mp3") for user_id, file in voice_state.recorder.output.items()]) | ||
await ctx.send("Here are your recordings", files=[interactions.File(file, file_name="user_id.mp3") for user_id, file in voice_state.recorder.output.items()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content here shouldn't be needed. What error are you getting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot test again until a bit later, but there was an error about the message not being empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because you didn't actually send/capture any audio. You need to talk and should visually see that your microphone is activating. Without any text or file attachments, the message was empty, hence the error.
files=[interactions.File(file, file_name=f"{user_id}.mp3") for user_id, file in voice_state.recorder.output.items()]
if len(files) > 0:
await ctx.send(files=files)
else:
await ctx.send("No audio was recorded.")
Putting on hold until requests are met and satisfied |
Pull Request Type
Description
The existing example does not work due to missing deferral and missing message body, this fixes both.
Changes
ctx.defer()
at beginning of exampleRelated Issues
Test Scenarios
Python Compatibility
3.10.x
3.11.x
Checklist
pre-commit
code linter over all edited files