sir-lancebot icon indicating copy to clipboard operation
sir-lancebot copied to clipboard

XKCD Failed to catches an error if ran too early

Open Shivansh-007 opened this issue 4 years ago • 0 comments

Description

If no arguments are provided for the XKCD command, it finds the latest comic it fetched within the current half an hour and sends it to the user. There is no error handling if we run the command just as the bot starts i.e. the task won't be able to get finished and we won't be able to get the latest, thereby raising the below error:

image

Steps to Reproduce

  1. Run the bot and unload .ext unload xkcd.
  2. Now load the cog .ext load xkcd and as soon as it got loaded run .xkcd.

Expected Behaviour

It should get the latest comic it fetched and send it to the user.

Actual Behaviour

While fetching the latest comic for the user, it catches an error as the latest comic dict is empty and it couldn't complete any comic fetch tasks as it was called the moment it got loaded giving it no time :(

Possible Solutions

Before indexing the dict to get the latest comic check whether it contains a comic or not, if not tell the user to run the command again after sometime.

Relevant lines of code: https://github.com/python-discord/sir-lancebot/blob/210a97a4eee9a4babc26366f71d13edcd21b6f9c/bot/exts/fun/xkcd.py#L56

https://github.com/python-discord/sir-lancebot/blob/210a97a4eee9a4babc26366f71d13edcd21b6f9c/bot/exts/fun/xkcd.py#L31-L38

Would you like to implement a fix?

Note: For high-priority or critical bugs, fixes may be implemented by staff.

  • [ ] I'd like to implement the bug fix
  • [X] Anyone can implement the bug fix

Shivansh-007 avatar Oct 15 '21 00:10 Shivansh-007