Vexed01 / Vex-Cogs

My cogs for Red.
https://cogdocs.vexcodes.com
GNU General Public License v3.0
27 stars 20 forks source link

[buttonpoll] Add permissions check for polls in other channels #126

Closed ThatOneRoadie closed 8 months ago

ThatOneRoadie commented 8 months ago

What cog is this feature request for?

buttonpoll

Describe the feature request in as much detail as possible

If a channel does not have the appropriate permissions (Attach Files), polls with pie charts will fail when the poll attempts to close and discord kicks back the following permissions error:

[DATETIME] [ERROR] red.vex.buttonpoll: Something went wrong with the ButtonPoll loop. Please report this to Vexed.
Traceback (most recent call last):
   File "buttonpoll/buttonpoll.py", line 494, in buttonpoll_loop
     await self.check_for_finished_polls()
   File "buttonpoll/buttonpoll.py", line 511, in check_for_finished_polls
     await poll.finish()
   File "buttonpoll/poll.py", line 234, in finish
     message = await channel.send(embed=embed, file=plot, view=view)
   File "lib/python3.8/site-packages/discord/abc.py", line 1561, in send
     data = await state.http.send_message(channel.id, params=params)
   File "lib/python3.8/site-packages/discord/http.py", line 739, in request
     raise Forbidden(response, data)
 discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

Maybe a permissions check similar to bdset when creating the initial poll message can be implemented?

Vexed01 commented 8 months ago

Thanks for letting me know. At the moment I only check for send messages permission. I'll add some extra checks.