diff --git a/setup.cfg b/setup.cfg index d3b6ba70..b2651dda 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ zip_safe = yes include_package_data = True install_requires = colored==1.4.2 - discord.py==1.5.1 + discord.py==2.1.0 appdirs==1.4.3 toml==0.10.0 numpy==1.23.1 diff --git a/sizebot/cogs/admin.py b/sizebot/cogs/admin.py index 05f2ea91..47129512 100644 --- a/sizebot/cogs/admin.py +++ b/sizebot/cogs/admin.py @@ -50,5 +50,5 @@ async def sudo(self, ctx, victim: discord.Member, *, command): await self.bot.process_commands(new_message) -def setup(bot): - bot.add_cog(AdminCog(bot)) +async def setup(bot): + await bot.add_cog(AdminCog(bot)) diff --git a/sizebot/cogs/change.py b/sizebot/cogs/change.py index ab5e1617..7a996d0b 100644 --- a/sizebot/cogs/change.py +++ b/sizebot/cogs/change.py @@ -248,5 +248,5 @@ async def changeTask(self): logger.error(e) -def setup(bot): - bot.add_cog(ChangeCog(bot)) +async def setup(bot): + await bot.add_cog(ChangeCog(bot)) diff --git a/sizebot/cogs/edge.py b/sizebot/cogs/edge.py index 8d4e1bda..21f94fce 100644 --- a/sizebot/cogs/edge.py +++ b/sizebot/cogs/edge.py @@ -193,5 +193,5 @@ async def on_message(self, m): await nickmanager.nick_update(m.author) -def setup(bot): - bot.add_cog(EdgeCog(bot)) +async def setup(bot): + await bot.add_cog(EdgeCog(bot)) diff --git a/sizebot/cogs/eval.py b/sizebot/cogs/eval.py index 3d6115eb..09ccdee0 100644 --- a/sizebot/cogs/eval.py +++ b/sizebot/cogs/eval.py @@ -73,5 +73,5 @@ async def evil(self, ctx, *, evalStr): await ctx.author.send(emojis.warning + f" ` {utils.formatError(err)} `") -def setup(bot): - bot.add_cog(EvalCog(bot)) +async def setup(bot): + await bot.add_cog(EvalCog(bot)) diff --git a/sizebot/cogs/fun.py b/sizebot/cogs/fun.py index d797db61..d414ec77 100644 --- a/sizebot/cogs/fun.py +++ b/sizebot/cogs/fun.py @@ -89,5 +89,5 @@ async def on_message(self, message): await cont.invoke(self.bot.get_command("digipee")) -def setup(bot): - bot.add_cog(FunCog(bot)) +async def setup(bot): + await bot.add_cog(FunCog(bot)) diff --git a/sizebot/cogs/help.py b/sizebot/cogs/help.py index f6fa1b06..b8b5e4fd 100644 --- a/sizebot/cogs/help.py +++ b/sizebot/cogs/help.py @@ -5,7 +5,7 @@ from datetime import datetime from packaging import version -from discord import Embed, Webhook, AsyncWebhookAdapter +from discord import Embed, Webhook from discord.ext import commands from sizebot import __version__ @@ -41,7 +41,7 @@ async def post_report(report_type, message, report_text): async with aiohttp.ClientSession() as session: - webhook = Webhook.from_url(conf.bugwebhookurl, adapter=AsyncWebhookAdapter(session)) + webhook = Webhook.from_url(conf.bugwebhookurl, session = session) guild_name = "DM" if not message.channel.guild else message.channel.guild.name await webhook.send( f"**{report_type}** from <@{message.author.id}> in {guild_name}:\n" @@ -110,7 +110,7 @@ async def send_summary_help(self, ctx): embed = Embed(title=f"Help [SizeBot {__version__}]") embed.set_footer(text = "Select an emoji to see details about a category.") - embed.set_author(name = f"requested by {ctx.author.name}", icon_url = ctx.author.avatar_url) + embed.set_author(name = f"requested by {ctx.author.name}", icon_url = ctx.author.avatar) # Add each category to a field for cat in categories: @@ -145,7 +145,7 @@ async def send_summary_help(self, ctx): async def send_category_help(self, ctx, category, cmds): # Prepare the embed for the category embed = Embed(title=f"{category.name} Help [SizeBot {__version__}]") - embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar_url) + embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar) command_texts = [f"`{c.name}` {c.alias_string}\n{c.short_doc}" for c in cmds] embed.add_field(value=f"**{category.emoji}{category.name}**", inline=False) @@ -412,5 +412,5 @@ def __init__(self, cid: str, name: str, description: str, emoji: str): ] -def setup(bot): - bot.add_cog(HelpCog(bot)) +async def setup(bot): + await bot.add_cog(HelpCog(bot)) diff --git a/sizebot/cogs/holiday.py b/sizebot/cogs/holiday.py index 0ff685ed..3975d20b 100644 --- a/sizebot/cogs/holiday.py +++ b/sizebot/cogs/holiday.py @@ -134,5 +134,5 @@ async def secretsanta(self, ctx): alreadyclaimed.add(userid) -def setup(bot): - bot.add_cog(HolidayCog(bot)) +async def setup(bot): + await bot.add_cog(HolidayCog(bot)) diff --git a/sizebot/cogs/keypad.py b/sizebot/cogs/keypad.py index a8143612..c2703410 100644 --- a/sizebot/cogs/keypad.py +++ b/sizebot/cogs/keypad.py @@ -66,5 +66,5 @@ def check(reaction, reacter): await outputmsg.clear_reactions() -def setup(bot): - bot.add_cog(KeypadCog(bot)) +async def setup(bot): + await bot.add_cog(KeypadCog(bot)) diff --git a/sizebot/cogs/limits.py b/sizebot/cogs/limits.py index 8aa56662..2834c2e5 100644 --- a/sizebot/cogs/limits.py +++ b/sizebot/cogs/limits.py @@ -11,7 +11,7 @@ logger = logging.getLogger("sizebot") -class EdgeCog(commands.Cog): +class LimitCog(commands.Cog): """Commands to create or clear edge users.""" def __init__(self, bot): @@ -116,5 +116,5 @@ async def on_message(self, m): await nickmanager.nick_update(m.author) -def setup(bot): - bot.add_cog(EdgeCog(bot)) +async def setup(bot): + await bot.add_cog(LimitCog(bot)) diff --git a/sizebot/cogs/loop.py b/sizebot/cogs/loop.py index de896019..b71201a8 100644 --- a/sizebot/cogs/loop.py +++ b/sizebot/cogs/loop.py @@ -126,5 +126,5 @@ async def sofar(self, ctx, *, who = None): await ctx.send(out) -def setup(bot): - bot.add_cog(LoopCog(bot)) +async def setup(bot): + await bot.add_cog(LoopCog(bot)) diff --git a/sizebot/cogs/multiplayer.py b/sizebot/cogs/multiplayer.py index 7a64f3ed..ae57cdf7 100644 --- a/sizebot/cogs/multiplayer.py +++ b/sizebot/cogs/multiplayer.py @@ -143,5 +143,5 @@ async def steal(self, ctx, amount: Union[SV, WV], victim: discord.Member, thief: await ctx.send(embed = e) -def setup(bot): - bot.add_cog(MPCog(bot)) +async def setup(bot): + await bot.add_cog(MPCog(bot)) diff --git a/sizebot/cogs/naptime.py b/sizebot/cogs/naptime.py index 7f470700..9b0ff996 100644 --- a/sizebot/cogs/naptime.py +++ b/sizebot/cogs/naptime.py @@ -82,5 +82,5 @@ async def nannyTask(self): logger.error(e) -def setup(bot): - bot.add_cog(NaptimeCog(bot)) +async def setup(bot): + await bot.add_cog(NaptimeCog(bot)) diff --git a/sizebot/cogs/objects.py b/sizebot/cogs/objects.py index ea01f9e2..5cf942ad 100644 --- a/sizebot/cogs/objects.py +++ b/sizebot/cogs/objects.py @@ -400,5 +400,5 @@ async def tags(self, ctx): await ctx.send(out) -def setup(bot): - bot.add_cog(ObjectsCog(bot)) +async def setup(bot): + await bot.add_cog(ObjectsCog(bot)) diff --git a/sizebot/cogs/pokemon.py b/sizebot/cogs/pokemon.py index c1d92f59..d64b40db 100644 --- a/sizebot/cogs/pokemon.py +++ b/sizebot/cogs/pokemon.py @@ -64,5 +64,5 @@ async def lookatpokemon(self, ctx, pkmn: typing.Union[int, str] = None, *, who: await ctx.send(embed = e) -def setup(bot): - bot.add_cog(PokemonCog(bot)) +async def setup(bot): + await bot.add_cog(PokemonCog(bot)) diff --git a/sizebot/cogs/profile.py b/sizebot/cogs/profile.py index b73d36f6..e5b893a8 100644 --- a/sizebot/cogs/profile.py +++ b/sizebot/cogs/profile.py @@ -87,5 +87,5 @@ async def profile(self, ctx, member: discord.Member = None): await ctx.send(embed = profileembed) -def setup(bot): - bot.add_cog(ProfileCog(bot)) +async def setup(bot): + await bot.add_cog(ProfileCog(bot)) diff --git a/sizebot/cogs/rainbow.py b/sizebot/cogs/rainbow.py index d2276eb6..98f100f5 100644 --- a/sizebot/cogs/rainbow.py +++ b/sizebot/cogs/rainbow.py @@ -48,5 +48,5 @@ async def before_rainbower(self): await self.bot.wait_until_ready() -def setup(bot): - bot.add_cog(RainbowCog(bot)) +async def setup(bot): + await bot.add_cog(RainbowCog(bot)) diff --git a/sizebot/cogs/register.py b/sizebot/cogs/register.py index af235b12..5ea3653a 100644 --- a/sizebot/cogs/register.py +++ b/sizebot/cogs/register.py @@ -426,5 +426,5 @@ def check(reaction, reacter): await ctx.send(f"Successfully copied profile from *{self.bot.get_guild(int(chosenguildid)).name}* to here!") -def setup(bot): - bot.add_cog(RegisterCog(bot)) +async def setup(bot): + await bot.add_cog(RegisterCog(bot)) diff --git a/sizebot/cogs/roll.py b/sizebot/cogs/roll.py index 158e7464..8b8bda22 100644 --- a/sizebot/cogs/roll.py +++ b/sizebot/cogs/roll.py @@ -64,5 +64,5 @@ async def r(self, ctx, *, dString): await ctx.send(f"{ctx.author.display_name} rolled `{dString}` = **{result.total}**") -def setup(bot): - bot.add_cog(RollCog(bot)) +async def setup(bot): + await bot.add_cog(RollCog(bot)) diff --git a/sizebot/cogs/run.py b/sizebot/cogs/run.py index 221c26cb..b79e9485 100644 --- a/sizebot/cogs/run.py +++ b/sizebot/cogs/run.py @@ -101,5 +101,5 @@ async def runTask(self): logger.error(e) -def setup(bot): - bot.add_cog(RunCog(bot)) +async def setup(bot): + await bot.add_cog(RunCog(bot)) diff --git a/sizebot/cogs/say.py b/sizebot/cogs/say.py index 44f1f08e..6b2000b9 100644 --- a/sizebot/cogs/say.py +++ b/sizebot/cogs/say.py @@ -320,5 +320,5 @@ async def sayto(self, ctx, memberOrHeight: typing.Union[discord.Member, SV], *, await ctx.send(f"{nick} {verb} to {othernick}: \n> {m}") -def setup(bot): - bot.add_cog(SayCog(bot)) +async def setup(bot): + await bot.add_cog(SayCog(bot)) diff --git a/sizebot/cogs/scaletalk.py b/sizebot/cogs/scaletalk.py index 60ec2d58..46efa103 100644 --- a/sizebot/cogs/scaletalk.py +++ b/sizebot/cogs/scaletalk.py @@ -126,5 +126,5 @@ async def on_message(self, message): userdb.save(userdata) -def setup(bot): - bot.add_cog(ScaleTypeCog(bot)) +async def setup(bot): + await bot.add_cog(ScaleTypeCog(bot)) diff --git a/sizebot/cogs/scalewalk.py b/sizebot/cogs/scalewalk.py index d51c061c..b482a57e 100644 --- a/sizebot/cogs/scalewalk.py +++ b/sizebot/cogs/scalewalk.py @@ -289,5 +289,5 @@ async def step(self, ctx, steps = None): userdb.save(userdata) -def setup(bot): - bot.add_cog(ScaleWalkCog(bot)) +async def setup(bot): + await bot.add_cog(ScaleWalkCog(bot)) diff --git a/sizebot/cogs/set.py b/sizebot/cogs/set.py index 01531cd7..c70cbed2 100644 --- a/sizebot/cogs/set.py +++ b/sizebot/cogs/set.py @@ -756,5 +756,5 @@ async def clearview(self, ctx, *, user: discord.Member): await ctx.send(f"Cleared {userdata.nickname}'s view.") -def setup(bot): - bot.add_cog(SetCog(bot)) +async def setup(bot): + await bot.add_cog(SetCog(bot)) diff --git a/sizebot/cogs/setbase.py b/sizebot/cogs/setbase.py index ba06d92b..57daebf8 100644 --- a/sizebot/cogs/setbase.py +++ b/sizebot/cogs/setbase.py @@ -281,5 +281,5 @@ async def setbaseswim(self, ctx, *, newswim: ParseableRate): await showNextStep(ctx, userdata) -def setup(bot): - bot.add_cog(SetBaseCog(bot)) +async def setup(bot): + await bot.add_cog(SetBaseCog(bot)) diff --git a/sizebot/cogs/stats.py b/sizebot/cogs/stats.py index 1696ee17..9d0efd6e 100644 --- a/sizebot/cogs/stats.py +++ b/sizebot/cogs/stats.py @@ -704,5 +704,5 @@ async def gravitycompare(self, ctx, memberOrHeight: typing.Union[discord.Member, await ctx.send(f"Standing on {larger_person.nickname}, {smaller_person.nickname} would experience **{gs:.3}**g of gravitational force.") -def setup(bot): - bot.add_cog(StatsCog(bot)) +async def setup(bot): + await bot.add_cog(StatsCog(bot)) diff --git a/sizebot/cogs/test.py b/sizebot/cogs/test.py index 487e3535..4202e0bf 100644 --- a/sizebot/cogs/test.py +++ b/sizebot/cogs/test.py @@ -34,5 +34,5 @@ async def test(self, ctx): await reactionmenu.message.edit(content = reactionmenu.message.content + f"\nYou pressed {answer}. Good job!") -def setup(bot): - bot.add_cog(TestCog(bot)) +async def setup(bot): + await bot.add_cog(TestCog(bot)) diff --git a/sizebot/cogs/thistracker.py b/sizebot/cogs/thistracker.py index 63e74bb4..c726def2 100644 --- a/sizebot/cogs/thistracker.py +++ b/sizebot/cogs/thistracker.py @@ -109,7 +109,7 @@ async def on_message(self, m): return if isAgreementMessage(m.content): channel = m.channel - messages = await channel.history(limit=100).flatten() + messages = [m async for m in channel.history(limit=100)] if findLatestNonThis(messages).author.id == m.author.id: return tracker = ThisTracker.load() @@ -128,5 +128,5 @@ async def on_reaction_add(self, r, u): tracker.save() -def setup(bot): - bot.add_cog(ThisCog(bot)) +async def setup(bot): + await bot.add_cog(ThisCog(bot)) diff --git a/sizebot/cogs/trigger.py b/sizebot/cogs/trigger.py index 24126de8..bfe02944 100644 --- a/sizebot/cogs/trigger.py +++ b/sizebot/cogs/trigger.py @@ -159,5 +159,5 @@ async def clearalltriggers(self, ctx): await ctx.send("Removed all trigger words.") -def setup(bot): - bot.add_cog(TriggerCog(bot)) +async def setup(bot): + await bot.add_cog(TriggerCog(bot)) diff --git a/sizebot/cogs/weird.py b/sizebot/cogs/weird.py index a83d2ac8..d901b54e 100644 --- a/sizebot/cogs/weird.py +++ b/sizebot/cogs/weird.py @@ -156,5 +156,5 @@ async def math(self, ctx, *, equation): await ctx.send("Math failed.") -def setup(bot): - bot.add_cog(WeirdCog(bot)) +async def setup(bot): + await bot.add_cog(WeirdCog(bot)) diff --git a/sizebot/cogs/winks.py b/sizebot/cogs/winks.py index 3172e1ae..f9b01838 100644 --- a/sizebot/cogs/winks.py +++ b/sizebot/cogs/winks.py @@ -90,5 +90,5 @@ async def winkcount(self, ctx): logger.info(f"Wink count requested by {ctx.author.nickname}! Current count: {winkcount} times!") -def setup(bot): - bot.add_cog(WinksCog(bot)) +async def setup(bot): + await bot.add_cog(WinksCog(bot)) diff --git a/sizebot/extensions/banned.py b/sizebot/extensions/banned.py index 5e99b639..c5386531 100644 --- a/sizebot/extensions/banned.py +++ b/sizebot/extensions/banned.py @@ -10,5 +10,5 @@ def denyGuildBan(ctx): return not isGuildBanned -def setup(bot): +async def setup(bot): bot.add_check(denyGuildBan) diff --git a/sizebot/extensions/errorhandler.py b/sizebot/extensions/errorhandler.py index 2d5394a6..fe505d80 100644 --- a/sizebot/extensions/errorhandler.py +++ b/sizebot/extensions/errorhandler.py @@ -11,7 +11,7 @@ logger = logging.getLogger("sizebot") -def setup(bot): +async def setup(bot): @bot.event async def on_command_error(ctx, error): # Get actual error diff --git a/sizebot/extensions/telemetry.py b/sizebot/extensions/telemetry.py index b3e1c697..d91853a3 100644 --- a/sizebot/extensions/telemetry.py +++ b/sizebot/extensions/telemetry.py @@ -3,7 +3,7 @@ from sizebot.lib import telemetry -def setup(bot): +async def setup(bot): @bot.listen def on_command(ctx): # Log command runs to telemetry diff --git a/sizebot/extensions/tupperbox.py b/sizebot/extensions/tupperbox.py index 248cad58..5517b37c 100644 --- a/sizebot/extensions/tupperbox.py +++ b/sizebot/extensions/tupperbox.py @@ -3,5 +3,5 @@ def ignoreTupperbox(ctx): return not (ctx.message.content.startswith(ctx.prefix) and ctx.message.content.endswith(ctx.prefix)) -def setup(bot): +async def setup(bot): bot.add_check(ignoreTupperbox) diff --git a/sizebot/lib/userdb.py b/sizebot/lib/userdb.py index 2979c996..3fe25489 100644 --- a/sizebot/lib/userdb.py +++ b/sizebot/lib/userdb.py @@ -673,7 +673,7 @@ def load(guildid, userid, *, member=None, allow_unreg=False) -> User: if member: if not user.gender: user.soft_gender = member.gender - user.avatar_url = member.avatar_url + user.avatar_url = member.avatar if (not allow_unreg) and (not user.registered): raise errors.UserNotFoundException(guildid, userid, unreg=True) diff --git a/sizebot/main.py b/sizebot/main.py index 71a12719..3013c902 100644 --- a/sizebot/main.py +++ b/sizebot/main.py @@ -110,11 +110,14 @@ def main(): objs.init() pokemon.init() - for extension in initial_extensions: - bot.load_extension("sizebot.extensions." + extension) - for cog in initial_cogs: - bot.load_extension("sizebot.cogs." + cog) - bot.load_extension("sizeroyale.cogs.royale") + @bot.event + async def setup_hook(): + logger.info("Setup hook called!") + for extension in initial_extensions: + await bot.load_extension("sizebot.extensions." + extension) + for cog in initial_cogs: + await bot.load_extension("sizebot.cogs." + cog) + # await bot.load_extension("sizeroyale.cogs.royale") @bot.event async def on_first_ready():