mikeshardmind / SinbadCogs

A set of community resources
Apache License 2.0
50 stars 47 forks source link

Red >= 3.3.6 alias cog removes on_message & breaks scheduler #213

Closed synrg closed 4 years ago

synrg commented 4 years ago

When a scheduled task is executed and Alias cog is loaded, scheduler finds the Alias cog and attempts to call on_message on it. However, Red 3.3.6 replaced on_message with on_message_without_command in this commit:

https://github.com/Cog-Creators/Red-DiscordBot/commit/6f6c536236e1218f6c24d4d2fd3e2aaace7ca5cc#diff-7cd91590ea12ce9b86e7159d9795d53bL447-R312

When the command to execute is not an alias, the scheduled task still executes, producing output, but this traceback is thrown into the log.

[2020-04-29 06:47:27] [ERROR] red.sinbadcogs.scheduler: Dead task
Traceback (most recent call last):
  File "/home/synrg/.local/share/Appledore/cogs/CogManager/cogs/scheduler/scheduler.py", line 128, in schedule_upcoming
    v.result()
  File "/home/synrg/.local/share/Appledore/cogs/CogManager/cogs/scheduler/scheduler.py", line 112, in delayed_wrap_and_invoke
    await cog.on_message(message)
AttributeError: 'Alias' object has no attribute 'on_message'

Scheduling an alias to execute does not work. There is no expected output from the command into the channel & the above traceback occurs.

Debug Info for Red
Red version
3.3.7
Python version
3.8.1 (32bit)
Discord.py version
1.3.3
Pip version
20.1
System arch
i686
User
synrg
OS version
Debian GNU/Linux 9
Python executable
/usr/local/bin/python3.8
Storage type
JSON
mikeshardmind commented 4 years ago

This has been fixed... kind of.

I'm aware of the lack of guarantees around core cogs. This has been made less fragile to changes, but ideally would not be necessary at all at some later point when CCs and aliases register themselves as commands on the bot.