Redjumpman / Jumper-Plugins

Python Modules for Discord bot
GNU General Public License v3.0
131 stars 95 forks source link

[Raffle] Catch missing channel in raffle teardown #237

Closed kpopdev closed 3 years ago

kpopdev commented 3 years ago

[13:45:03] ERROR Error in raffle_worker task. [red.jumper-plugins.raffle] ┌───────────────── Traceback (most recent call last) ─────────────────┐ │ C:\Users\Administrator\AppData\Local\Red-DiscordBot\Red-DiscordBot\ │ │ Data\candy\cogs\CogManager\cogs\raffle\raffle.py:412 in │ │ raffle_teardown │ │ │ │ 409 │ │ │ │ 410 │ │ errored = False │ │ 411 │ │ try: │ │ ❱ 412 │ │ │ msg = await channel.get_message(raffles[str(messa │ │ 413 │ │ except AttributeError: │ │ 414 │ │ │ try: │ │ 415 │ │ │ │ msg = await channel.fetch_message(raffles[str │ └─────────────────────────────────────────────────────────────────────┘ AttributeError: 'NoneType' object has no attribute 'get_message'

                During handling of the above exception, another exception occurred:

                ┌───────────────── Traceback (most recent call last) ─────────────────┐
                │ C:\Users\Administrator\AppData\Local\Red-DiscordBot\Red-DiscordBot\ │
                │ Data\candy\cogs\CogManager\cogs\raffle\raffle.py:376 in             │
                │ raffle_worker                                                       │
                │                                                                     │
                │   373 │   │   │   │   │   for key, value in raffles.items():        │
                │   374 │   │   │   │   │   │   remaining = raffles[key]["Timestamp"] │
                │   375 │   │   │   │   │   │   if remaining <= 0:                    │
                │ ❱ 376 │   │   │   │   │   │   │   await self.raffle_teardown(guild, │
                │   377 │   │   │   │   │   │   else:                                 │
                │   378 │   │   │   │   │   │   │   coros.append(self.raffle_timer(gu │
                │       remaining))                                                   │
                │   379 │   │   │   await asyncio.gather(*coros)                      │
                │                                                                     │
                │ C:\Users\Administrator\AppData\Local\Red-DiscordBot\Red-DiscordBot\ │
                │ Data\candy\cogs\CogManager\cogs\raffle\raffle.py:415 in             │
                │ raffle_teardown                                                     │
                │                                                                     │
                │   412 │   │   │   msg = await channel.get_message(raffles[str(messa │
                │   413 │   │   except AttributeError:                                │
                │   414 │   │   │   try:                                              │
                │ ❱ 415 │   │   │   │   msg = await channel.fetch_message(raffles[str │
                │   416 │   │   │   except discord.NotFound:                          │
                │   417 │   │   │   │   errored = True                                │
                │   418 │   │   except discord.errors.NotFound:                       │
                └─────────────────────────────────────────────────────────────────────┘
                AttributeError: 'NoneType' object has no attribute 'fetch_message'
aikaterna commented 3 years ago

Fixed in https://github.com/Redjumpman/Jumper-Plugins/commit/9d3ced6cfd93704f1d94f0befe1c61a4ff27ff1b