Skip to content

Commit

Permalink
fix tests on <3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Aug 2, 2024
1 parent ddbbb7d commit 96afc04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
23 changes: 10 additions & 13 deletions aadiscordbot/bot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import logging
import sys
import time
import traceback
from datetime import datetime
from socket import timeout
from typing import Dict

import aiohttp
import discord
Expand All @@ -26,8 +24,7 @@
import aadiscordbot
from aadiscordbot import app_settings
from aadiscordbot.app_settings import (
DISCORD_BOT_ACCESS_DENIED_REACT, DISCORD_BOT_MESSAGE_INTENT,
DISCORD_BOT_PREFIX,
DISCORD_BOT_ACCESS_DENIED_REACT, DISCORD_BOT_PREFIX,
)
from aadiscordbot.cogs.utils.exceptions import NotAuthenticated, NotManaged

Expand Down Expand Up @@ -85,7 +82,7 @@ def bucket_for_task(self, task):
def check_rate_limit(self, task):
if task not in self.rate_buckets:
self.rate_buckets[task] = self.bucket_for_task(task)
#logger.debug(f" {self.rate_buckets[task].capacity} {self.rate_buckets[task].fill_rate} {self.rate_buckets[task].expected_time()}")
# logger.debug(f" {self.rate_buckets[task].capacity} {self.rate_buckets[task].fill_rate} {self.rate_buckets[task].expected_time()}")
return self.rate_buckets[task].can_consume()

def to_string(self):
Expand Down Expand Up @@ -178,7 +175,7 @@ def __init__(self):
try:
self.load_extension(cog)
self.cog_names_loaded.append(cog)
except Exception as e:
except Exception:
logger.exception(f"Failed to load cog {cog}")
self.cog_names_failed.append(cog)

Expand Down Expand Up @@ -319,7 +316,7 @@ async def poll_queue(self):
with self.message_consumer:
self.message_connection.drain_events(timeout=0.01)
except timeout as e:
# logging.exception(e)
logging.exception(e)
message_avail = False

next_task = self.pending_tasks.pop_next()
Expand Down Expand Up @@ -384,7 +381,7 @@ async def on_application_command_error(self, context: ApplicationContext, except
message = [f"`{context.command}` failed for `{context.author}`\n",
f"**Exception:** ```{exception}```",
f"\n**Interaction:** ```{context.interaction.data}```",
f"\n**Trace:**```"]
"\n**Trace:**```"]
message += traceback.format_tb(
exception.original.__traceback__)
message.append("\n```")
Expand All @@ -399,7 +396,7 @@ def run(self):

logger.info(
"******************************************************")
logger.info(f" ## Alliance Auth 'AuthBot'")
logger.info(" ## Alliance Auth 'AuthBot'")
logger.info(
f" #### Version : {aadiscordbot.__version__}")
logger.info(
Expand All @@ -410,13 +407,13 @@ def run(self):
f" ######## (( Prefix : {app_settings.DISCORD_BOT_PREFIX}")
logger.info(
f" ###### (((((( Bot Join Link : {INVITE_URL}")
logger.info(f" ### (((( Starting up...")
logger.info(f" ## ((")
logger.info(f" [Cogs Loaded]")
logger.info(" ### (((( Starting up...")
logger.info(" ## ((")
logger.info(" [Cogs Loaded]")
for c in self.cog_names_loaded:
logger.info(f" - {c}")
if len(self.cog_names_failed):
logger.info(f" [Cog Failures]")
logger.info(" [Cog Failures]")
for c in self.cog_names_failed:
logger.info(f" - {c}")
logger.info(
Expand Down
3 changes: 2 additions & 1 deletion aadiscordbot/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import logging
import warnings
from typing import Union

from discord import Guild, User

Expand Down Expand Up @@ -170,7 +171,7 @@ def is_user_authenticated(user: User, guild: Guild):
return False


def get_auth_user(user: User | int, guild: Guild | int = None):
def get_auth_user(user: Union[User, int], guild: Union[Guild, int] = None):
"""
Get auth user from any service module
"""
Expand Down

0 comments on commit 96afc04

Please sign in to comment.