Discord.py dep update 3.1 (#2587)

* Dependency update

discord.py==1.0.1
websockets<7

[style]
black==19.3b0

[Docs]
jinja==2.10.1
urllib3==1.24.2

Changes related to breaking changes from discord.py have also been made
to match

As of this commit, help formatter is back to discord.py's default
This commit is contained in:
Michael H
2019-04-23 21:40:38 -04:00
committed by GitHub
parent 0ff7259bc3
commit ad114295e7
83 changed files with 231 additions and 22307 deletions

View File

@@ -8,7 +8,7 @@ from redbot.core.bot import Red
class MixinMeta(ABC):
"""
Metaclass for well behaved type hint detection with composite class.
Base class for well behaved type hint detection with composite class.
Basically, to keep developers sane when not all attributes are defined in each mixin.
"""

View File

@@ -2,7 +2,7 @@ from datetime import datetime
from collections import defaultdict, deque
import discord
from redbot.core import i18n, modlog
from redbot.core import i18n, modlog, commands
from redbot.core.utils.mod import is_mod_or_superior
from . import log
from .abc import MixinMeta
@@ -73,6 +73,7 @@ class Events(MixinMeta):
return True
return False
@commands.Cog.listener()
async def on_message(self, message):
author = message.author
if message.guild is None or self.bot.user == author:
@@ -92,6 +93,7 @@ class Events(MixinMeta):
if not deleted:
await self.check_mention_spam(message)
@commands.Cog.listener()
async def on_member_ban(self, guild: discord.Guild, member: discord.Member):
if (guild.id, member.id) in self.ban_queue:
self.ban_queue.remove((guild.id, member.id))
@@ -112,6 +114,7 @@ class Events(MixinMeta):
except RuntimeError as e:
print(e)
@commands.Cog.listener()
async def on_member_unban(self, guild: discord.Guild, user: discord.User):
if (guild.id, user.id) in self.unban_queue:
self.unban_queue.remove((guild.id, user.id))
@@ -130,8 +133,8 @@ class Events(MixinMeta):
except RuntimeError as e:
print(e)
@staticmethod
async def on_modlog_case_create(case: modlog.Case):
@commands.Cog.listener()
async def on_modlog_case_create(self, case: modlog.Case):
"""
An event for modlog case creation
"""
@@ -147,8 +150,8 @@ class Events(MixinMeta):
msg = await mod_channel.send(case_content)
await case.edit({"message": msg})
@staticmethod
async def on_modlog_case_edit(case: modlog.Case):
@commands.Cog.listener()
async def on_modlog_case_edit(self, case: modlog.Case):
"""
Event for modlog case edits
"""
@@ -161,6 +164,7 @@ class Events(MixinMeta):
else:
await case.message.edit(content=case_content)
@commands.Cog.listener()
async def on_member_update(self, before: discord.Member, after: discord.Member):
if before.name != after.name:
async with self.settings.user(before).past_names() as name_list:

View File

@@ -131,7 +131,7 @@ class KickBanMixin(MixinMeta):
)
now = datetime.utcnow()
if now > unban_time: # Time to unban the user
user = await self.bot.get_user_info(uid)
user = await self.bot.fetch_user(uid)
queue_entry = (guild.id, user.id)
self.unban_queue.append(queue_entry)
try:
@@ -335,7 +335,7 @@ class KickBanMixin(MixinMeta):
else:
banned.append(user_id)
user_info = await self.bot.get_user_info(user_id)
user_info = await self.bot.fetch_user(user_id)
try:
await modlog.create_case(
@@ -508,7 +508,7 @@ class KickBanMixin(MixinMeta):
click the user and select 'Copy ID'."""
guild = ctx.guild
author = ctx.author
user = await self.bot.get_user_info(user_id)
user = await self.bot.fetch_user(user_id)
if not user:
await ctx.send(_("Couldn't find a user with that ID!"))
return

View File

@@ -1,5 +1,6 @@
from collections import defaultdict
from typing import List, Tuple
from abc import ABC
import discord
from redbot.core import Config, modlog, commands
@@ -18,8 +19,26 @@ _ = T_ = Translator("Mod", __file__)
__version__ = "1.0.0"
class CompositeMetaClass(type(commands.Cog), type(ABC)):
"""
This allows the metaclass used for proper type detection to
coexist with discord.py's metaclass
"""
pass
@cog_i18n(_)
class Mod(ModSettings, Events, KickBanMixin, MoveToCore, MuteMixin, ModInfo, commands.Cog):
class Mod(
ModSettings,
Events,
KickBanMixin,
MoveToCore,
MuteMixin,
ModInfo,
commands.Cog,
metaclass=CompositeMetaClass,
):
"""Moderation tools."""
default_global_settings = {"version": ""}
@@ -60,7 +79,7 @@ class Mod(ModSettings, Events, KickBanMixin, MoveToCore, MuteMixin, ModInfo, com
async def initialize(self):
await self._maybe_update_config()
def __unload(self):
def cog_unload(self):
self.registration_task.cancel()
self.tban_expiry_task.cancel()
@@ -87,7 +106,7 @@ class Mod(ModSettings, Events, KickBanMixin, MoveToCore, MuteMixin, ModInfo, com
# TODO: Move this to core.
# This would be in .movetocore , but the double-under name here makes that more trouble
async def __global_check(self, ctx):
async def bot_check(self, ctx):
"""Global check to see if a channel or server is ignored.
Any users who have permission to use the `ignore` or `unignore` commands

View File

@@ -16,10 +16,12 @@ class MoveToCore(MixinMeta):
Mixin for things which should really not be in mod, but have not been moved out yet.
"""
@commands.Cog.listener()
async def on_command_completion(self, ctx: commands.Context):
await self._delete_delay(ctx)
# noinspection PyUnusedLocal
@commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error):
await self._delete_delay(ctx)