TrustyJAID / Trusty-cogs

A variety of utility cogs and fun cogs including Hockey information from the NHL, badge creation from discord user information, starboard for use on Redbot, twitch follow notifications and more.
MIT License
164 stars 120 forks source link

TB on roletools message sendbutton #320

Closed wohali closed 1 year ago

wohali commented 1 year ago

Describe the bug After creating a roletools button, then using the roletools message sendbutton command, the message appears to be sent correctly, but a KeyError traceback appears on the bot console:

Jun 10 17:48:19 botserver python[603675]: [2023-06-10 17:48:19] [ERROR] red: Exception in command 'roletools message sendbutton'
Jun 10 17:48:19 botserver python[603675]: Traceback (most recent call last):
Jun 10 17:48:19 botserver python[603675]:   File "/home/redbot/.pyenv/versions/Red-venv-3.11.3/lib/python3.11/site-packages/discord/ext/commands/core.py", line 229, in wrapped
Jun 10 17:48:19 botserver python[603675]:     ret = await coro(*args, **kwargs)
Jun 10 17:48:19 botserver python[603675]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 10 17:48:19 botserver python[603675]:   File "/home/redbot/Red-DiscordBot/cogs/CogManager/cogs/roletools/messages.py", line 270, in send_buttons
Jun 10 17:48:19 botserver python[603675]:     await self.save_settings(ctx.guild, message_key, buttons=buttons, select_menus=[])
Jun 10 17:48:19 botserver python[603675]:   File "/home/redbot/Red-DiscordBot/cogs/CogManager/cogs/roletools/messages.py", line 102, in save_settings
Jun 10 17:48:19 botserver python[603675]:     messages = set(saved_buttons[button_name]["messages"])
Jun 10 17:48:19 botserver python[603675]:                    ~~~~~~~~~~~~~^^^^^^^^^^^^^
Jun 10 17:48:19 botserver python[603675]: KeyError: <ButtonRole style=<ButtonStyle.secondary: 2> url=None disabled=False label='Silica' emoji=<PartialEmoji animated=False name='silica' id=1101691083253088326> row=None>

To Reproduce Steps to reproduce the behavior:

  1. roletools button create ...
  2. roletools message sendbutton #channel This is a message.
  3. Message appears, but so does Error in command 'roletools message sendbutton'. Check your console or logs for details., with the pasted traceback.

Expected behavior No traceback.