DisnakeDev / disnake

An API wrapper for Discord written in Python.
https://docs.disnake.dev
MIT License
721 stars 137 forks source link

Unable to send messages in StageChannel #1042

Closed SeraphimRP closed 1 year ago

SeraphimRP commented 1 year ago

Summary

StageChannels seem to be just VoiceChannels with extra steps. Both have the ability for users to send chat messages there, but bots can't seem to send messages in there.

Reproduction Steps

We use disnake.abc.Messageable to identify sources we can respond to. StageChannel isn't one, and so we aren't able to run _get_channel() on it. We can't use send() directly on the StageChannel we get either.

Minimal Reproducible Code

No response

Expected Results

The ability to send messages in text channels in response to command interactions and other invocations of the bot.

Actual Results

If we continue our usual Messageable route, an error is thrown because StageChannel doesn't inherit that class. If we try handling those channels uniquely, there is no send() capacity despite that option seeming to exist?

Traceback with Messageable:

Ignoring exception in slash command 'stats':                                                                                           
Traceback (most recent call last):                                                                                                     
  File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 681, in invoke                                                                                                                                   
    await call_param_func(self.callback, inter, self.cog, **kwargs)                                                                    
  File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/ext/commands/params.py", line 827, in call_param_func                                                                                                                               
    return await maybe_coroutine(safe_call, function, **kwargs)                                                                        
  File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/utils.py", line 580, in maybe_coroutine    
    return await value                                                                                                                 
  File "/home/srp/biblebot/src/BibleBot.Frontend/cogs/info.py", line 35, in stats                                                      
    resp = await backend.submit_command(inter.channel, inter.author, "+stats")                                                         
  File "/home/srp/biblebot/src/BibleBot.Frontend/utils/backend.py", line 21, in submit_command                                         
    ch = await rch._get_channel()                                                                                                      
AttributeError: 'StageChannel' object has no attribute '_get_channel'                                                                   

The above exception was the direct cause of the following exception:                                     

Traceback (most recent call last):                                                                                                      
  File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1262, in process_application_commands                                                                                                  
    await app_command.invoke(interaction)                                                                                              
  File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 690, in invoke                                                                                                                                   
    raise CommandInvokeError(exc) from exc                                                                                             
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'StageChannel' object has no attribute '_get_channel'

Traceback with send():

Ignoring exception in on_message                                                                                                       
Traceback (most recent call last):                                                                                                        
File "/home/srp/biblebot/src/BibleBot.Frontend/venv/lib64/python3.9/site-packages/disnake/client.py", line 612, in _run_event
    await coro(*args, **kwargs)                                                                                                        
  File "/home/srp/biblebot/src/BibleBot.Frontend/cogs/events.py", line 85, in on_message                                               
    await backend.submit_verse(msg.channel, msg.author, clean_msg)                                                                     
  File "/home/srp/biblebot/src/BibleBot.Frontend/utils/backend.py", line 236, in submit_verse     
    await ch.send(embed=create_embed_from_verse(verse))                                                                                 
AttributeError: 'StageChannel' object has no attribute 'send'

Intents

Default + message_content

System Information

- Python v3.9.16-final
- disnake v2.8.1-final
    - disnake importlib.metadata: v2.8.1
- aiohttp v3.8.1
- system info: Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64

Checklist

Additional Context

No response

shiftinv commented 1 year ago

Text-in-stage will be supported in the next version, it was implemented in #942. You can either use the current master branch (changelog) or PartialMessageables for now, if that works for you.

SeraphimRP commented 1 year ago

Thank you much! Apologies for the duplicate, my search-fu wasn't up to par. :)