diff --git a/exts/banking.py b/exts/banking.py index 59430ea..d7d8af2 100644 --- a/exts/banking.py +++ b/exts/banking.py @@ -66,6 +66,12 @@ class Banking(commands.Cog): bot_key_api_key=os.getenv("pnwACCKEY"), aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop), ) + self.dkit = pnwkit.QueryKit( + api_key=os.getenv("pnwDILFKEY"), + bot_key=os.getenv("pnwBOTKEY"), + bot_key_api_key=os.getenv("pnwACCKEY"), + aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop), + ) @commands.has_role(987770837627187250) @commands.command() @@ -149,7 +155,7 @@ class Banking(commands.Cog): await ctx.send(embed=e, view=View(kit=self.kit)) @commands.has_role(987770837627187250) - @commands.command(aliases=['wc']) + @commands.command(aliases=["wc"]) async def warchest(self, ctx: CustomCtx): """ refill warchest of all members @@ -163,12 +169,7 @@ class Banking(commands.Cog): nations = alliance.nations resource_delta = [] - kit = pnwkit.QueryKit( - api_key=os.getenv("pnwDILFKEY"), - bot_key=os.getenv("pnwBOTKEY"), - bot_key_api_key=os.getenv("pnwACCKEY"), - aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop), - ) + kit = self.dkit gator = await kit.query( "nations", {"id": 103764, "first": 1}, @@ -351,9 +352,16 @@ class Banking(commands.Cog): await paginator.start( ctx=ctx, custom_items=[ConfirmButton(bot=self.bot, p=paginator)] ) + @commands.has_role(987770837627187250) @commands.command() - async def rss(self, ctx: CustomCtx, ids: commands.Greedy[int] = None, *, nation_names: str|None =None): + async def rss( + self, + ctx: CustomCtx, + ids: commands.Greedy[int] = None, + *, + nation_names: str | None = None, + ): """get resources of a nation in alliance Args: @@ -361,26 +369,19 @@ class Banking(commands.Cog): """ if ids is None: ids = [] - d_kit = pnwkit.QueryKit( - api_key=os.getenv("pnwDILFKEY"), - bot_key=os.getenv("pnwBOTKEY"), - bot_key_api_key=os.getenv("pnwACCKEY"), - aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop), - ) + embeds = [] if nation_names: - nation_names = nation_names.split(',') + nation_names = nation_names.split(",") for n in nation_names: result = await self.kit.query( - "nations", - {"nation_name": n, "first": 1}, - "id" - ) + "nations", {"nation_name": n, "first": 1}, "id" + ) ids.append(result.nations[0].id) if not ids: ids = FILL for id in ids: - kit = self.kit if (id != 103764) else d_kit + kit = self.kit if (id != 103764) else self.dkit nation = await kit.query( "nations", {"id": id, "first": 1}, @@ -409,11 +410,52 @@ class Banking(commands.Cog): f"{Emojis.steel} {nation.steel:,}\n" f"{Emojis.credits} {nation.credits}\n" ) - e.set_footer(text=nation.leader_name, icon_url=self.bot.user.avatar) + e.set_footer(text=nation.leader_name, icon_url=self.bot.user.avatar) embeds.append(e) - + await ctx.paginate(pages=embeds) - + + @commands.has_role(987770837627187250) + @commands.command() + async def bank(self, ctx: CustomCtx): + """sends bank resources""" + m_resources = await self.kit.query( + "alliances", + {"id": 10177, "first": 1}, + "name, flag, money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel", + ) + m_resources = m_resources.alliances[0] + d_resources = await self.dkit.query( + "alliances", + {"id": 10198, "first": 1}, + "name,flag, money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel", + ) + d_resources = d_resources.alliances[0] + + embeds = [] + for resources in [m_resources, d_resources]: + e = discord.Embed( + title=f"Resources for {resources.name}", + timestamp=datetime.datetime.utcnow(), + color=ctx.author.color, + ) + e.description = ( + f"{Emojis.money} {resources.money:,}\n" + f"{Emojis.food} {resources.food:,}\n" + f"{Emojis.uranium} {resources.uranium:,}\n" + f"{Emojis.coal} {resources.coal:,}\n" + f"{Emojis.iron} {resources.iron:,}\n" + f"{Emojis.oil} {resources.oil:,}\n" + f"{Emojis.bauxite} {resources.bauxite:,}\n" + f"{Emojis.lead} {resources.lead:,}\n" + f"{Emojis.munitions} {resources.munitions:,}\n" + f"{Emojis.gasoline} {resources.gasoline:,}\n" + f"{Emojis.aluminum} {resources.aluminum:,}\n" + f"{Emojis.steel} {resources.steel:,}" + ) + e.set_footer(icon_url=resources.flag) + embeds.append(e) + await ctx.paginate(embeds=embeds) async def setup(bot: Brahmos):