dronefly-garden / dronefly

Red Discord Bot V3 cogs for naturalists.
Other
16 stars 3 forks source link

taxon: Reasonable response if bot does not have embed permission #134

Closed synrg closed 4 years ago

synrg commented 4 years ago

If the bot does not have embed permission, a text message response or error message is appropriate. Otherwise an exception is triggered:

image

[2020-10-18 11:19:49] [ERROR] red: Exception in command 'taxon'
Traceback (most recent call last):
  File "/home/redbot/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/redbot/.local/share/Red-DiscordBot/data/Dronefly/cogs/CogManager/cogs/inatcog/commands/taxon.py", line 55, in taxon
    await self.send_embed_for_taxon(ctx, filtered_taxon)
  File "/home/redbot/.local/share/Red-DiscordBot/data/Dronefly/cogs/CogManager/cogs/inatcog/inat_embeds.py", line 711, in send_embed_for_taxon
    msg = await ctx.send(
  File "/home/redbot/.local/lib/python3.8/site-packages/redbot/core/commands/context.py", line 93, in send
    return await super().send(content=content, **kwargs)
  File "/home/redbot/.local/lib/python3.8/site-packages/discord/abc.py", line 890, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/home/redbot/.local/lib/python3.8/site-packages/discord/http.py", line 241, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
synrg commented 4 years ago

While a local fix for send_embed_for_taxon() would address this one case, the problem is widespread throughout the cog, as there are many direct invocations of ctx.send(embed=...) without using a helper from embed.py or inat_embed.py.

Therefore, after fixing this very commonly executed command response, the issue should also be addressed systematically across all other commands.

synrg commented 4 years ago

bd6d4c6643bf4090a0b7685c3625bbf8cb875e00 adds a check for ,taxon and this will apply to all subcommands. Other taxon commands outside this group need similar attention, and while we're at it, we should check the other sending permissions, such as attach_files (probably only relevant for preview of sound recordings).

synrg commented 4 years ago

Fixed as of d08f650b30ecb602b69c8776d42f5d3c995faaae