Add unspent XP to deck status text
This commit is contained in:
parent
e535eb6bcf
commit
c6503b91af
15
ahtcg_bot.py
15
ahtcg_bot.py
@ -7,7 +7,7 @@ import re
|
||||
import discord
|
||||
from discord.ext import commands, tasks
|
||||
|
||||
from arkhamdb import ArkhamDBClient
|
||||
from arkhamdb import ArkhamDBClient, ArkhamDBDeck
|
||||
from secret import TOKEN
|
||||
|
||||
|
||||
@ -77,6 +77,14 @@ class ArkhamDBUpdater(commands.Bot):
|
||||
and len(message.embeds) == 1:
|
||||
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:
|
||||
print(f'Running update in channel {channel.guild} - {channel.name}')
|
||||
async with channel.typing():
|
||||
@ -90,9 +98,8 @@ class ArkhamDBUpdater(commands.Bot):
|
||||
except discord.NotFound:
|
||||
last_message = None
|
||||
|
||||
message_text = '\n'.join(
|
||||
f"{prefix}[{deck['name']}]({self.arkhamdb_client.origin}/deck/view/{deck['id']}) [{deck['id']}]"
|
||||
for prefix, deck in latest_decks.values())
|
||||
message_text = '\n'.join(self.status_for_deck(prefix, deck)
|
||||
for prefix, deck in latest_decks.values())
|
||||
message_embed = discord.Embed(
|
||||
title=f'Updated as of {datetime.now()}',
|
||||
description=message_text)
|
||||
|
Loading…
Reference in New Issue
Block a user