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 asyncio
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@@ -118,6 +118,14 @@ class Banking(commands.Cog):
|
|||||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
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):
|
async def fetch_warchest_ids(self):
|
||||||
"""Fetch nation IDs from the warchest table."""
|
"""Fetch nation IDs from the warchest table."""
|
||||||
try:
|
try:
|
||||||
@@ -149,6 +157,21 @@ class Banking(commands.Cog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise 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()
|
@commands.command()
|
||||||
async def offkey(self, ctx: CustomCtx):
|
async def offkey(self, ctx: CustomCtx):
|
||||||
"""set offshore key"""
|
"""set offshore key"""
|
||||||
@@ -630,6 +653,8 @@ class Banking(commands.Cog):
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def bank(self, ctx: CustomCtx):
|
async def bank(self, ctx: CustomCtx):
|
||||||
"""sends bank resources"""
|
"""sends bank resources"""
|
||||||
|
|
||||||
|
await self.update_okit()
|
||||||
m_resources = await self.kit.query(
|
m_resources = await self.kit.query(
|
||||||
"alliances",
|
"alliances",
|
||||||
{"id": MILF_ID, "first": 1},
|
{"id": MILF_ID, "first": 1},
|
||||||
@@ -684,6 +709,7 @@ class Banking(commands.Cog):
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def transfer(self, ctx: CustomCtx):
|
async def transfer(self, ctx: CustomCtx):
|
||||||
"""transfer resources"""
|
"""transfer resources"""
|
||||||
|
|
||||||
if ctx.author.id not in [
|
if ctx.author.id not in [
|
||||||
367740727624466433,
|
367740727624466433,
|
||||||
322156710590676993,
|
322156710590676993,
|
||||||
@@ -692,6 +718,7 @@ class Banking(commands.Cog):
|
|||||||
]:
|
]:
|
||||||
return await ctx.send("-# You are not in list of authorized users")
|
return await ctx.send("-# You are not in list of authorized users")
|
||||||
|
|
||||||
|
await self.update_okit()
|
||||||
milf = await self.get_kit_alliance(self.kit)
|
milf = await self.get_kit_alliance(self.kit)
|
||||||
|
|
||||||
alliances = {MILF_ID: "Man I Love Frogs", DILF_ID: "Damn I Love Frogs"}
|
alliances = {MILF_ID: "Man I Love Frogs", DILF_ID: "Damn I Love Frogs"}
|
||||||
|
|||||||
Reference in new issue
Block a user