Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.74k stars 3.75k forks source link

Commit 862d509d2e39f9d550ec3dff1e7d08fc6b3b5b8d breaks if strip_after_prefix does not exist #6612

Closed JamesZoft closed 3 years ago

JamesZoft commented 3 years ago

Summary

When requiring discord.py/master and trying to use the get_context, it errors because strip_after_prefix doesn't exist

Reproduction Steps

Use self.bot.get_context(message)

Minimal Reproducible Code

self.bot.get_context(message)

Expected Results

It would return without an error

Actual Results

[Cluster 1] Traceback (most recent call last): [Cluster 1] File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 343, in _run_event [Cluster 1] await coro(*args, **kwargs) [Cluster 1] File "/modmail/modmail/cogs/events.py", line 129, in on_message [Cluster 1] ctx = await self.bot.get_context(message) [Cluster 1] File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 915, in get_context [Cluster 1] if self.strip_after_prefix: [Cluster 1] AttributeError: 'ModMail' object has no attribute 'strip_after_prefix'

Intents

32767

System Information

Checklist

I have searched the open issues for duplicates. I have shown the entire traceback, if possible. I have removed my token from display, if visible.

Rapptz commented 3 years ago

Did you forget to call super() inside __init__?

Rapptz commented 3 years ago

I couldn't reproduce this with or without the option so I'm closing this.

JamesZoft commented 3 years ago

Hi, I’m not sure, sorry. It’s a problem I’m having whilst trying to run the latest version of modmail https://github.com/chamburr/modmail and send the ‘=help’ command - modmail depends on discord.py@master. If I revert to before the commit I’ve specified the problem goes away.

Rapptz commented 3 years ago

Whoever wrote that bot decided that writing all the attributes by hand was a good idea. So whenever the library updates, the code used in the bot will break which is what happened here. Unfortunately this is not an issue with the library but with the bot itself. You're better off opening an issue there -- and hopefully get them to avoid all the duplication of library code since it's fragile.

JamesZoft commented 3 years ago

I see, I’ll pass it on, thanks!

chamburr commented 3 years ago

Developer of the mentioned bot here. Since my bot does not use the built-in gateway, and neither does it use the built-in state cache, patching the methods is the best option for me.