wow-token-app-bot/token_bot/core.py

48 lines
1.5 KiB
Python
Raw Normal View History

import logging
import aiohttp
from interactions import Extension
from interactions import slash_command, listen
from interactions.api.events import Startup
from token_bot.token_database import database as pdb
from token_bot.token_database import database as tdb
VERSION = "0.1.0"
class Core(Extension):
def __init__(self, bot):
self._tdb: tdb.Database | None = None
self._pdb: pdb.Database | None = None
@listen(Startup)
async def on_start(self):
self.bot.logger.log(logging.INFO,"TokenBot Core ready")
self.bot.logger.log(logging.INFO,f"This is bot version {VERSION}")
self._tdb = tdb.Database(aiohttp.ClientSession())
@slash_command()
async def version(self, ctx):
await ctx.send(f"This is bot version {VERSION}", ephemeral=True)
@slash_command()
async def help(self, ctx):
await ctx.send(f"This is bot help command", ephemeral=True)
@slash_command(
description="The current retail token cost"
)
async def current(self, ctx):
current = await self._tdb.current(tdb.Flavor.RETAIL)
await ctx.send(f"us: {current['us']}\neu: {current['eu']}\ntw: {current['tw']}\nkr: {current['kr']}",
ephemeral=True)
@slash_command(
description="The current classic token cost"
)
async def current_classic(self, ctx):
current = await self._tdb.current(tdb.Flavor.CLASSIC)
await ctx.send(f"us: {current['us']}\neu: {current['eu']}\ntw: {current['tw']}\nkr: {current['kr']}",
ephemeral=True)