aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/moderation.py
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-09-16 16:59:21 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-09-16 17:17:28 +0200
commit70b7ef7ae65888da3e5a36fad76f51726b03fc7e (patch)
tree01f0632c692598769e3de72bb10f7b5dd02be20b /bot/cogs/moderation.py
parentMerge pull request #430 from python-discord/bot-cogs-security-tests (diff)
Update discord.py version to 1.2.3
I have updated the discord.py version to 1.2.3. This includes changes throughout the entire code base, including: - All cogs now inherit from `discord.ext.commands.Cog`; - All of our ABCs now have `bot.utils.CogABCMeta` as a metaclass; - All event handlers in cogs are now decorated with `Cog.listener()`; - Some method names have changes, including: - get_message => fetch_message - get_webhook_info => fetch_webhook - A few occurences of `get_channel` have been replaced by the new coroutine `fetch_channel`; - I've had to patch a few lines of code to account for small differences between the versions, like `on_member_update` attribute names in ModLog and the fact the way we used `Context.invoke` a couple of times has stopped working. In addition, I've added a patch for a bug in discord.py (with the help of @Scragly). This discord.py version has a bug which causes the edited timestamp not to be processed for edited messages. It's already fixed on GitHub, but a bug fix release has not been released to PyPI. In the meantime, I've added a patch in `bot.patches.message_edited_at` and included conditional loading in `__main__`. Finally, I noticed a small bug in `bot.cogs.filtering` that I fixed; I replaces `return` with `continue` to make sure filtering for edited messages doesn't stop after the `rich_embed_filter`.
Diffstat (limited to '')
-rw-r--r--bot/cogs/moderation.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index 532a44f4d..fcbadd235 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -8,7 +8,7 @@ from discord import (
Colour, Embed, Forbidden, Guild, HTTPException, Member, NotFound, Object, User
)
from discord.ext.commands import (
- BadArgument, BadUnionArgument, Bot, Context, command, group
+ BadArgument, BadUnionArgument, Bot, Cog, Context, command, group
)
from bot import constants
@@ -46,7 +46,7 @@ def proxy_user(user_id: str) -> Object:
UserTypes = Union[Member, User, proxy_user]
-class Moderation(Scheduler):
+class Moderation(Scheduler, Cog):
"""
Server moderation tools.
"""
@@ -60,6 +60,7 @@ class Moderation(Scheduler):
def mod_log(self) -> ModLog:
return self.bot.get_cog("ModLog")
+ @Cog.listener()
async def on_ready(self):
# Schedule expiration for previous infractions
infractions = await self.bot.api_client.get(
@@ -1348,7 +1349,7 @@ class Moderation(Scheduler):
"""
# sometimes `user` is a `discord.Object`, so let's make it a proper user.
- user = await self.bot.get_user_info(user.id)
+ user = await self.bot.fetch_user(user.id)
try:
await user.send(embed=embed)