Red 3.2 changes and cleanup
This commit is contained in:
@@ -5,16 +5,8 @@ import discord
|
||||
|
||||
from redbot.core import commands, checks, Config
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
listener = getattr(commands.Cog, "listener", None) # Trusty + Sinbad
|
||||
if listener is None:
|
||||
|
||||
def listener(name=None):
|
||||
return lambda x: x
|
||||
|
||||
|
||||
class AntiPhoneClapper(BaseCog):
|
||||
class AntiPhoneClapper(commands.Cog):
|
||||
"""This cog deletes bad GIFs that will crash phone clients."""
|
||||
|
||||
def __init__(self, bot):
|
||||
@@ -73,7 +65,7 @@ class AntiPhoneClapper(BaseCog):
|
||||
tile_sizes.append(im.tile[0][1][2:])
|
||||
return any([x[0] > limit[0] or x[1] > limit[1] for x in tile_sizes])
|
||||
|
||||
@listener()
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, m):
|
||||
if not m.attachments:
|
||||
return
|
||||
|
||||
12
away/away.py
12
away/away.py
@@ -6,16 +6,8 @@ import re
|
||||
|
||||
IMAGE_LINKS = re.compile(r"(http[s]?:\/\/[^\"\']*\.(?:png|jpg|jpeg|gif|png))")
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
listener = getattr(commands.Cog, "listener", None) # Trusty + Sinbad
|
||||
if listener is None:
|
||||
|
||||
def listener(name=None):
|
||||
return lambda x: x
|
||||
|
||||
|
||||
class Away(BaseCog):
|
||||
class Away(commands.Cog):
|
||||
"""Le away cog"""
|
||||
|
||||
default_global_settings = {"ign_servers": []}
|
||||
@@ -189,7 +181,7 @@ class Away(BaseCog):
|
||||
return True
|
||||
return False
|
||||
|
||||
@listener()
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
tmp = {}
|
||||
guild = message.guild
|
||||
|
||||
@@ -450,7 +450,7 @@ class CardsAgainstHumanity(BaseCog):
|
||||
member["Task"] = None
|
||||
continue
|
||||
# not enough members - send the embed
|
||||
prefix = await self.bot.db.prefix()
|
||||
prefix = await self.bot.get_valid_prefixes()
|
||||
stat_embed = discord.Embed(color=discord.Color.red())
|
||||
stat_embed.set_author(
|
||||
name="Not enough players to continue! ({}/{})".format(
|
||||
|
||||
@@ -16,9 +16,7 @@ plt.switch_backend("agg")
|
||||
from redbot.core import commands
|
||||
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
class Chatchart(BaseCog):
|
||||
class Chatchart(commands.Cog):
|
||||
"""Show activity."""
|
||||
|
||||
def __init__(self, bot):
|
||||
|
||||
@@ -41,7 +41,10 @@ class Dungeon(commands.Cog):
|
||||
dungeon_role_obj = discord.utils.get(ctx.guild.roles, id=dungeon_role_id)
|
||||
|
||||
if blacklist:
|
||||
async with self.bot.db.blacklist() as blacklist_list:
|
||||
# if you are reading this to learn, DON'T do this, there will be a real way
|
||||
# to interact with bot-owned data without touching config directly at some
|
||||
# point in the future after Red 3.2
|
||||
async with self.bot._config.blacklist() as blacklist_list:
|
||||
if user.id not in blacklist_list:
|
||||
blacklist_list.append(user.id)
|
||||
|
||||
|
||||
@@ -3,15 +3,7 @@ import re
|
||||
from redbot.core import Config, commands, checks
|
||||
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
listener = getattr(commands.Cog, "listener", None) # Trusty + Sinbad
|
||||
if listener is None:
|
||||
|
||||
def listener(name=None):
|
||||
return lambda x: x
|
||||
|
||||
class NoLinks(BaseCog):
|
||||
class NoLinks(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.config = Config.get_conf(self, 2740131001, force_registration=True)
|
||||
@@ -110,7 +102,7 @@ class NoLinks(BaseCog):
|
||||
await self.config.guild(ctx.guild).watching.set(channel_list)
|
||||
await ctx.send(f"{self.bot.get_channel(channel.id).mention} will not have links removed.")
|
||||
|
||||
@listener()
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
if isinstance(message.channel, discord.abc.PrivateChannel):
|
||||
return
|
||||
|
||||
@@ -2,15 +2,7 @@ import discord
|
||||
from redbot.core import commands, checks, Config
|
||||
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
listener = getattr(commands.Cog, "listener", None) # Trusty + Sinbad
|
||||
if listener is None:
|
||||
|
||||
def listener(name=None):
|
||||
return lambda x: x
|
||||
|
||||
class Otherbot(BaseCog):
|
||||
class Otherbot(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.config = Config.get_conf(self, 2730321001, force_registration=True)
|
||||
@@ -86,7 +78,7 @@ class Otherbot(BaseCog):
|
||||
f"Reporting channel set to: {ctx.message.channel.mention}. Use `{ctx.prefix}otherbot channel` to change this."
|
||||
)
|
||||
|
||||
@listener()
|
||||
@commands.Cog.listener()
|
||||
async def on_member_update(self, before, after):
|
||||
if after.guild is None or not after.bot:
|
||||
return
|
||||
|
||||
@@ -4,9 +4,7 @@ from redbot.core.utils.chat_formatting import box, pagify
|
||||
import asyncio
|
||||
|
||||
|
||||
BaseCog = getattr(commands, "Cog", object)
|
||||
|
||||
class PartyCrash(BaseCog):
|
||||
class PartyCrash(commands.Cog):
|
||||
"""Partycrash inspired by v2 Admin by Will
|
||||
Does not generate invites, only lists existing invites."""
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class RndStatus(commands.Cog):
|
||||
current_game = None
|
||||
statuses = await self.config.statuses()
|
||||
botstats = await self.config.botstats()
|
||||
prefix = await self.bot.db.prefix()
|
||||
prefix = await self.bot.get_valid_prefixes()
|
||||
streamer = await self.config.streamer()
|
||||
url = "https://www.twitch.tv/" + streamer
|
||||
|
||||
|
||||
@@ -3,16 +3,11 @@ import datetime
|
||||
import discord
|
||||
import random
|
||||
import math
|
||||
from typing import Union # <- Remove this at 3.2
|
||||
from babel.numbers import format_decimal # <- Remove this at 3.2
|
||||
from redbot.core import commands, checks, Config, bank
|
||||
from redbot.core.utils.chat_formatting import box, pagify #, humanize_number <- Will be for 3.2
|
||||
from redbot.core.utils.chat_formatting import box, pagify, humanize_number
|
||||
from redbot.core.utils.menus import menu, DEFAULT_CONTROLS
|
||||
|
||||
__version__ = "0.0.6a"
|
||||
|
||||
def humanize_number(val: Union[int, float]): # <- Remove this at 3.2
|
||||
return format_decimal(val, locale="en_US")
|
||||
__version__ = "0.0.7"
|
||||
|
||||
|
||||
class TrickOrTreat(commands.Cog):
|
||||
|
||||
Reference in New Issue
Block a user