From d15bdc4ce88b35757a11f87c3a570bf07269ebb9 Mon Sep 17 00:00:00 2001 From: "William C." Date: Mon, 11 Mar 2024 17:22:51 -0400 Subject: [PATCH] fix: remove prefix and role timeout --- cogs/moderation.py | 18 +++++++++++------- cogs/utility.py | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cogs/moderation.py b/cogs/moderation.py index 97b50dc..825eb67 100644 --- a/cogs/moderation.py +++ b/cogs/moderation.py @@ -36,13 +36,17 @@ def setup(client) -> commands.Cog: @limiter(20, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please wait `{round(delay, 2)}s`!")) async def nickname(ctx, member: voltage.User, *, nick:str): if ctx.author.permissions.manage_nicknames or ctx.author.id == ctx.server.owner.id: - async with aiohttp.ClientSession() as s: - await s.patch( - url=f"https://api.revolt.chat/servers/{ctx.server.id}/members/{member.id}", - headers={"x-bot-token": config['TOKEN']}, - json={"nickname": nick} - ) - await s.close() + try: + async with aiohttp.ClientSession() as s: + await s.patch( + url=f"https://api.revolt.chat/servers/{ctx.server.id}/members/{member.id}", + headers={"x-bot-token": config['TOKEN']}, + json={"nickname": nick}, + timeout=10 + ) + await s.close() + except aiohttp.ClientTimeout: + return embed = voltage.SendableEmbed( title="Nickname", description=f"Changed {member.display_name}'s nickname to `{nick}`!", diff --git a/cogs/utility.py b/cogs/utility.py index 3a8bfe2..961a9b7 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -389,7 +389,7 @@ async def addprefix(ctx, *, prefix): ) async def removeprefix(ctx, *, prefix): if (await userdb.find_one({'userid':ctx.author.id})): - if len((await userdb.find_one({'userid':ctx.author.id})['prefixes'])) > 1 : + if len((await userdb.find_one({'userid':ctx.author.id}))['prefixes']) > 1 : if prefix in (await userdb.find_one({'userid':ctx.author.id}))['prefixes']: await userdb.update_one({'userid':ctx.author.id}, {'$pull':{'prefixes':prefix}}) prefixes = (await userdb.find_one({'userid':ctx.author.id}))['prefixes']