Solar-Helix-Independent-Transport / allianceauth-discordbot

allianceauth-discordbot
MIT License
6 stars 18 forks source link

[Feature Request] Add Exceptions to Tasks #73

Open ppfeufer opened 1 year ago

ppfeufer commented 1 year ago

Add exceptions with error messages to the API functions like send_channel_message_by_discord_id, send_direct_message_by_discord_id and send_direct_message_by_user_id so app devs can implement proper error handling when calling these tasks.

Thank you!

pvyParts commented 1 year ago

Happy to take thoughts on how the logging can be extended. It is currently pretty loud.

Processing tasks from queue to happens here: https://github.com/Solar-Helix-Independent-Transport/allianceauth-discordbot/blob/master/aadiscordbot/bot.py#L185-L217

Running of tasks happens here: https://github.com/Solar-Helix-Independent-Transport/allianceauth-discordbot/blob/master/aadiscordbot/bot_tasks.py#L33-L37

The tasks the bot actually runs are defined round here: https://github.com/Solar-Helix-Independent-Transport/allianceauth-discordbot/blob/master/aadiscordbot/bot_tasks.py#L43 https://github.com/Solar-Helix-Independent-Transport/allianceauth-discordbot/blob/master/aadiscordbot/bot_tasks.py#L68

ppfeufer commented 1 year ago

I meant exceptions we as dev can catch in our apps when using the discordbot-tasks.

For issues like this:

image

To allow us to do something like this:

try:
    aadiscordbot.tasks.send_channel_message_by_discord_id.delay(
        rss_feed.discord_channel.channel,
        discord_message,
        embed=False,
    )
except DiscordbotException as ex:
    logger.debug(f"Something went wrong. {ex.message}")
pvyParts commented 1 year ago

This can't be done with the current way we run tasks. The tasks you call in auth are simple shims. So the bot can manage it's rate limits 100% separately to auth.

pvyParts commented 1 year ago

I can, and will add more logging tho.