dronefly-garden / dronefly

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

Unchecked access to guild config breaks in DM to the bot #45

Closed synrg closed 5 years ago

synrg commented 5 years ago

If you DM the bot a request that causes an unchecked access to a guild config, as in the new feature added to the inat obs command that places emojis for certain project IDs on the observation title line, then an exception is raised:

[2019-11-03 19:54:12] [ERROR] red: Exception in command 'inat obs'
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Ben\work\quaggagriff\inatcog\inatcog.py", line 145, in obs
    embed=await self.make_obs_embed(ctx, obs, url, preview=False)
  File "C:\Users\Ben\work\quaggagriff\inatcog\inat_embeds.py", line 77, in make_obs_embed
    project_emojis = await self.config.guild(ctx.guild).project_emojis()
  File "C:\Python37\lib\site-packages\redbot\core\config.py", line 881, in guild
    return self._get_base_group(self.GUILD, str(guild.id))
AttributeError: 'NoneType' object has no attribute 'id'
  1. There needs to be a global config if this feature is also supposed to work in DM to the bot.
  2. The guild config should not be checked in a direct message.

Ben

synrg commented 5 years ago

Closed by 82ae03854999f04b33c1f89766205adf9c51e18b .