rewrite (core): Split and refactor Lion and config.
This commit is contained in:
@@ -15,7 +15,7 @@ async def get_goals_card(
|
||||
):
|
||||
data: StatsData = bot.get_cog('StatsCog').data
|
||||
|
||||
lion = await bot.core.lions.fetch(guildid, userid)
|
||||
lion = await bot.core.lions.fetch_member(guildid, userid)
|
||||
today = lion.today
|
||||
|
||||
# Calculate periodid and select the correct model
|
||||
@@ -63,7 +63,7 @@ async def get_goals_card(
|
||||
sessions_complete = 0.5
|
||||
|
||||
# Get member profile
|
||||
if member := await lion.get_member():
|
||||
if member := await lion.fetch_member():
|
||||
username = (member.display_name, member.discriminator)
|
||||
avatar = member.avatar.key
|
||||
else:
|
||||
|
||||
@@ -14,7 +14,7 @@ from ..lib import apply_month_offset
|
||||
async def get_monthly_card(bot: LionBot, userid: int, guildid: int, offset: int, mode: CardMode) -> MonthlyStatsCard:
|
||||
data: StatsData = bot.get_cog('StatsCog').data
|
||||
|
||||
lion = await bot.core.lions.fetch(guildid, userid)
|
||||
lion = await bot.core.lions.fetch_member(guildid, userid)
|
||||
today = lion.today
|
||||
month_start = today.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
target = apply_month_offset(month_start, offset)
|
||||
@@ -77,7 +77,7 @@ async def get_monthly_card(bot: LionBot, userid: int, guildid: int, offset: int,
|
||||
monthly[i][day.day - 1] = stat / 3600
|
||||
|
||||
# Get member profile
|
||||
if member := await lion.get_member():
|
||||
if member := await lion.fetch_member():
|
||||
username = (member.display_name, member.discriminator)
|
||||
else:
|
||||
username = (lion.data.display_name, '#????')
|
||||
|
||||
@@ -16,7 +16,7 @@ async def get_stats_card(bot: LionBot, userid: int, guildid: int):
|
||||
# TODO: Leaderboard rankings
|
||||
guildid = guildid or 0
|
||||
|
||||
lion = await bot.core.lions.fetch(guildid, userid)
|
||||
lion = await bot.core.lions.fetch_member(guildid, userid)
|
||||
|
||||
# Calculate the period timestamps, i.e. start time for each summary period
|
||||
# TODO: Don't do the alltime one like this, not efficient anymore
|
||||
|
||||
@@ -12,7 +12,7 @@ from ..data import StatsData
|
||||
async def get_weekly_card(bot: LionBot, userid: int, guildid: int, offset: int, mode: CardMode) -> WeeklyStatsCard:
|
||||
data: StatsData = bot.get_cog('StatsCog').data
|
||||
|
||||
lion = await bot.core.lions.fetch(guildid, userid)
|
||||
lion = await bot.core.lions.fetch_member(guildid, userid)
|
||||
today = lion.today
|
||||
week_start = today - timedelta(days=today.weekday()) - timedelta(weeks=offset)
|
||||
days = [week_start + timedelta(i) for i in range(-7, 7 if offset else (today.weekday() + 1))]
|
||||
@@ -34,7 +34,7 @@ async def get_weekly_card(bot: LionBot, userid: int, guildid: int, offset: int,
|
||||
day_stats.append(0)
|
||||
|
||||
# Get member profile
|
||||
if member := await lion.get_member():
|
||||
if member := await lion.fetch_member():
|
||||
username = (member.display_name, member.discriminator)
|
||||
else:
|
||||
username = (lion.data.display_name, '#????')
|
||||
|
||||
Reference in New Issue
Block a user