DevSkyOne / OpenGPT

OpenGPT is a open-source chatgpt api discord bot
MIT License
12 stars 3 forks source link

Error on SendMessage if missing permissions #9

Open CoasterFreakDE opened 1 year ago

CoasterFreakDE commented 1 year ago
Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 451, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/opengpt.py", line 313, in on_message
    thinking_message = await send_thinking_message(message)
  File "/home/container/opengpt.py", line 252, in send_thinking_message
    return await message.channel.send("Let me think for a moment... (this may take a while)", reference=message)
  File "/home/container/.local/lib/python3.10/site-packages/discord/abc.py", line 1140, in send
    data = await state.http.send_message(channel.id, params=params)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 590, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
ozgvr commented 1 year ago

what is the expected behaviour? catch the exception and print an error?

mccoderpy commented 1 year ago

Well checking the permissions before responding would also be an option.

CoasterFreakDE commented 1 year ago

Good question. If the bot has no permission to send a message, there is no way of letting them know. (Only option is to use slashcommands for new conversations)