You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running examples/audio_recording.py with @bot.command but AttributeError occurs -- 'NoneType' object has no attribute 'expandtabs'
Reproduction Steps
Run examples/audio_recording.py
Minimal Reproducible Code
Run examples/audio_recording.py as below:
importosfromenumimportEnumfromdiscord.extimportcommandsfromdotenvimportload_dotenvimportdiscordload_dotenv()
bot=discord.Bot(intents=discord.Intents.all())
connections= {}
classSinks(Enum):
mp3=discord.sinks.MP3Sink()
wav=discord.sinks.WaveSink()
pcm=discord.sinks.PCMSink()
ogg=discord.sinks.OGGSink()
mka=discord.sinks.MKASink()
mkv=discord.sinks.MKVSink()
mp4=discord.sinks.MP4Sink()
m4a=discord.sinks.M4ASink()
asyncdeffinished_callback(sink, channel: discord.TextChannel, *args):
recorded_users= [f"<@{user_id}>"foruser_id, audioinsink.audio_data.items()]
awaitsink.vc.disconnect()
files= [
discord.File(audio.file, f"{user_id}.{sink.encoding}")
foruser_id, audioinsink.audio_data.items()
]
awaitchannel.send(
f"Finished! Recorded audio for {', '.join(recorded_users)}.", files=files
)
@bot.command()asyncdefstart(ctx: discord.ApplicationContext, sink: Sinks):
"""Record your voice!"""voice=ctx.author.voiceifnotvoice:
returnawaitctx.respond("You're not in a vc right now")
vc=awaitvoice.channel.connect()
connections.update({ctx.guild.id: vc})
vc.start_recording(
sink.value,
finished_callback,
ctx.channel,
)
awaitctx.respond("The recording has started!")
@bot.command()asyncdefstop(ctx: discord.ApplicationContext):
"""Stop recording."""ifctx.guild.idinconnections:
vc=connections[ctx.guild.id]
vc.stop_recording()
delconnections[ctx.guild.id]
awaitctx.delete()
else:
awaitctx.respond("Not recording in this guild.")
bot.run(os.getenv('DISCORD_BOT_TOKEN'))
Expected Results
Slash command registered
No error, the bot is running
Actual Results
Traceback (most recent call last):
File "/Users/johnnypan/Projects/WSA-Utopia-Discord-Bot-AI-Agent/speech/app/services/discord/record_voice.py", line 38, in <module>
@bot.command()
^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/bot.py", line 953, in decorator
result = command(**kwargs)(func)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 2026, in decorator
return cls(func, **attrs)
^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 762, in __init__
self._validate_parameters()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 780, in _validate_parameters
self.options = self._parse_options(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 838, in _parse_options
option = Option(option)
^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/options.py", line 202, in __init__
description = inspect.cleandoc(input_type.__doc__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 869, in cleandoc
lines = doc.expandtabs().split('\n')
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'expandtabs'
Intents
all
System Information
macos
py-cord==2.6.0
python 3.11
Checklist
I have searched the open issues for duplicates.
I have shown the entire traceback, if possible.
I have removed my token from display, if visible.
Additional Context
What happened? Please help!
The text was updated successfully, but these errors were encountered:
Johnny850807
changed the title
Running @bot.command but AttributeError occurs -- 'NoneType' object has no attribute 'expandtabs'
Running examples/audio_recording.py with @bot.command but AttributeError occurs -- 'NoneType' object has no attribute 'expandtabs'
Aug 21, 2024
plun1331
changed the title
Running examples/audio_recording.py with @bot.command but AttributeError occurs -- 'NoneType' object has no attribute 'expandtabs'
Declaring an enum option with no docstring causes an error
Sep 16, 2024
Summary
Running examples/audio_recording.py with @bot.command but AttributeError occurs -- 'NoneType' object has no attribute 'expandtabs'
Reproduction Steps
Run
examples/audio_recording.py
Minimal Reproducible Code
Run
examples/audio_recording.py
as below:Expected Results
Actual Results
Intents
all
System Information
macos
py-cord==2.6.0
python 3.11
Checklist
Additional Context
What happened? Please help!
The text was updated successfully, but these errors were encountered: