add cmd tp update offshore key
This commit is contained in:
1 parent
84fce7f885
commit
5288baa5cf
1 file changed
+28
-1
+28
-1
@@ -1,10 +1,10 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import pprint
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
import aiohttp
|
||||
@@ -118,6 +118,14 @@ class Banking(commands.Cog):
|
||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
||||
)
|
||||
|
||||
async def update_okit(self):
|
||||
self.okit = pnwkit.QueryKit(
|
||||
api_key=await self.get_offshore_key(),
|
||||
bot_key=os.getenv("pnwBOTKEY"),
|
||||
bot_key_api_key=os.getenv("pnwACCKEY"),
|
||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
||||
)
|
||||
|
||||
async def fetch_warchest_ids(self):
|
||||
"""Fetch nation IDs from the warchest table."""
|
||||
try:
|
||||
@@ -149,6 +157,21 @@ class Banking(commands.Cog):
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
@commands.command()
|
||||
async def offshore(self, ctx: CustomCtx):
|
||||
await self.update_okit()
|
||||
data: ApiKeyDetails = await self.get_kit_alliance(self.okit, True)
|
||||
embed = discord.Embed(
|
||||
title="current offshore",
|
||||
description="run offkey to set new api key for offshore.",
|
||||
color=0x2D3236,
|
||||
timestamp=datetime.datetime.now(),
|
||||
url=f"https://politicsandwar.com/alliance/id={data.nation.alliance.id}",
|
||||
)
|
||||
embed.add_field(name="Alliance", value=data.nation.alliance.name)
|
||||
embed.set_thumbnail(url=data.nation.alliance.flag)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command()
|
||||
async def offkey(self, ctx: CustomCtx):
|
||||
"""set offshore key"""
|
||||
@@ -630,6 +653,8 @@ class Banking(commands.Cog):
|
||||
@commands.command()
|
||||
async def bank(self, ctx: CustomCtx):
|
||||
"""sends bank resources"""
|
||||
|
||||
await self.update_okit()
|
||||
m_resources = await self.kit.query(
|
||||
"alliances",
|
||||
{"id": MILF_ID, "first": 1},
|
||||
@@ -684,6 +709,7 @@ class Banking(commands.Cog):
|
||||
@commands.command()
|
||||
async def transfer(self, ctx: CustomCtx):
|
||||
"""transfer resources"""
|
||||
|
||||
if ctx.author.id not in [
|
||||
367740727624466433,
|
||||
322156710590676993,
|
||||
@@ -692,6 +718,7 @@ class Banking(commands.Cog):
|
||||
]:
|
||||
return await ctx.send("-# You are not in list of authorized users")
|
||||
|
||||
await self.update_okit()
|
||||
milf = await self.get_kit_alliance(self.kit)
|
||||
|
||||
alliances = {MILF_ID: "Man I Love Frogs", DILF_ID: "Damn I Love Frogs"}
|
||||
|
||||
Reference in new issue
Block a user