update warchest cmd
This commit is contained in:
1 parent
a764288394
commit
13dc675173
1 file changed
+68
-2
+68
-2
@@ -1,6 +1,8 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
import io
|
||||
import os
|
||||
import pprint
|
||||
import random
|
||||
from typing import List, Literal, Optional
|
||||
|
||||
@@ -12,7 +14,7 @@ from discord.ext import commands
|
||||
from botclass import Brahmos, CustomCtx
|
||||
from utils.base import BasicView
|
||||
from utils.emojis import Emojis
|
||||
|
||||
from utils.paginator import Paginator
|
||||
|
||||
class BaseMul:
|
||||
money = 1000000
|
||||
@@ -140,6 +142,7 @@ class Banking(commands.Cog):
|
||||
|
||||
await ctx.send(embed=e, view=View(kit=self.kit))
|
||||
|
||||
@commands.has_role(987770837627187250)
|
||||
@commands.command()
|
||||
async def warchest(self, ctx: CustomCtx):
|
||||
"""
|
||||
@@ -196,7 +199,70 @@ class Banking(commands.Cog):
|
||||
if count > 0:
|
||||
embeds.append(e)
|
||||
|
||||
await ctx.paginate(embeds)
|
||||
class ConfirmButton(discord.ui.Button):
|
||||
def __init__(self, *, style = discord.ButtonStyle.green, label= "confirm", bot: Brahmos, p: Paginator):
|
||||
super.__init__(style=style, label=label)
|
||||
self.bot = bot
|
||||
self.v = p
|
||||
|
||||
|
||||
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
||||
return interaction.user == ctx.author
|
||||
|
||||
async def callback(self, interaction: discord.Interaction) -> io.Any:
|
||||
|
||||
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)
|
||||
)
|
||||
logmsg = ""
|
||||
logstream = io.StringIO
|
||||
await interaction.response.defer()
|
||||
self.label = "processing"
|
||||
self.emoji = "<a:load:1275827052909432887>"
|
||||
self.style= discord.ButtonStyle.blurple
|
||||
self.v.clear_items()
|
||||
self.v.add_item(self)
|
||||
e = discord.Embed(color=discord.Color.blurple, timestamp=datetime.datetime.utcnow(), title="Transferring resources")
|
||||
await interaction.message.edit(embed=e, view=v)
|
||||
for rd in resource_delta:
|
||||
for k in rd: # remove negatives
|
||||
if (isinstance(rd[k]), int) and (rd[k] < 0):
|
||||
rd[k] = 0
|
||||
try:
|
||||
await kit.mutation(
|
||||
"bankWithdraw",
|
||||
{
|
||||
"receiver" : rd.get("id"),
|
||||
"receiver_type": 1,
|
||||
"money": rd.get("money"),
|
||||
"food": rd.get("food"),
|
||||
"uranium": rd.get("uranium"),
|
||||
"gasoline": rd.get("gasoline"),
|
||||
"steel": rd.get("steel00"),
|
||||
"munitions": rd.get("munitions"),
|
||||
"aluminum": rd.get("aluminum"),
|
||||
"note": "warchest"
|
||||
},
|
||||
"id"
|
||||
)
|
||||
pprint.pprint(rd, stream=logstream, indent=3)
|
||||
logmsg += f"{rd.get("name")} <:tick:1275824967522717707>\n"
|
||||
e.description = logmsg
|
||||
await interaction.message.edit(embed=e)
|
||||
await asyncio.sleep(1)
|
||||
except Exception as e:
|
||||
pprint.pprint(f"{rd.get('name')} -> {e}", stream=logstream, indent=3)
|
||||
logmsg += f"{rd.get("name")} <:cross:1275824989131505779>\n"
|
||||
e.description = logmsg
|
||||
await interaction.message.edit(embed=e)
|
||||
await asyncio.sleep(1)
|
||||
await interaction.message.edit(view=None)
|
||||
await ctx.send(file=discord.File(logstream, filename="log.txt"))
|
||||
paginator = ctx.Paginator(pages=embeds)
|
||||
paginator.start(ctx=ctx, custom_items=[ConfirmButton(bot=self.bot, p=paginator)])
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user