Add unspent XP to deck status text

This commit is contained in:
Adam Goldsmith 2022-03-14 00:46:20 -04:00
parent e535eb6bcf
commit c6503b91af
1 changed files with 11 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import re
import discord import discord
from discord.ext import commands, tasks from discord.ext import commands, tasks
from arkhamdb import ArkhamDBClient from arkhamdb import ArkhamDBClient, ArkhamDBDeck
from secret import TOKEN from secret import TOKEN
@ -77,6 +77,14 @@ class ArkhamDBUpdater(commands.Bot):
and len(message.embeds) == 1: and len(message.embeds) == 1:
await message.delete() await message.delete()
def status_for_deck(self, prefix: str, deck: ArkhamDBDeck) -> str:
unspent_xp = deck['xp'] - deck['xp_spent']
status = f"{prefix}[{deck['name']}]({self.arkhamdb_client.origin}/deck/view/{deck['id']}) [{deck['id']}]"
if unspent_xp > 0:
status += f" {{{unspent_xp} unspent XP}}"
return status
async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None: async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None:
print(f'Running update in channel {channel.guild} - {channel.name}') print(f'Running update in channel {channel.guild} - {channel.name}')
async with channel.typing(): async with channel.typing():
@ -90,9 +98,8 @@ class ArkhamDBUpdater(commands.Bot):
except discord.NotFound: except discord.NotFound:
last_message = None last_message = None
message_text = '\n'.join( message_text = '\n'.join(self.status_for_deck(prefix, deck)
f"{prefix}[{deck['name']}]({self.arkhamdb_client.origin}/deck/view/{deck['id']}) [{deck['id']}]" for prefix, deck in latest_decks.values())
for prefix, deck in latest_decks.values())
message_embed = discord.Embed( message_embed = discord.Embed(
title=f'Updated as of {datetime.now()}', title=f'Updated as of {datetime.now()}',
description=message_text) description=message_text)