add db
This commit is contained in:
1 parent
799dc4f7cb
commit
43ca775fb0
8 files changed
+65
-44
No files matched your search
+20
-8
@@ -9,6 +9,7 @@ from typing import List, Literal, Optional
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
import asyncpg
|
||||
import pnwkit
|
||||
from discord.ext import commands
|
||||
from discord.utils import format_dt
|
||||
@@ -20,8 +21,6 @@ from utils.emojis import Emojis
|
||||
from utils.paginator import Paginator
|
||||
|
||||
|
||||
FILL: list = json.load(open("refill.json"))
|
||||
|
||||
|
||||
class BaseMul:
|
||||
money = 1000000
|
||||
@@ -75,6 +74,23 @@ class Banking(commands.Cog):
|
||||
bot_key_api_key=os.getenv("pnwACCKEY"),
|
||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
||||
)
|
||||
self.FILL = None
|
||||
|
||||
|
||||
async def cog_load(self):
|
||||
"""Called when the cog is loaded."""
|
||||
await self.fetch_refill_ids()
|
||||
|
||||
|
||||
async def fetch_refill_ids(self):
|
||||
"""Fetch nation IDs from the refill table."""
|
||||
try:
|
||||
async with self.bot.db_pool.acquire() as conn:
|
||||
query = "SELECT id FROM refill"
|
||||
rows = await conn.fetch(query)
|
||||
self.FILL = [row[0] for row in rows]
|
||||
except Exception as e:
|
||||
self.FILL = []
|
||||
|
||||
@commands.has_any_role("Government", "The Croak Council")
|
||||
@commands.command()
|
||||
@@ -184,7 +200,7 @@ class Banking(commands.Cog):
|
||||
nations.append(gator)
|
||||
|
||||
for nation in nations:
|
||||
if nation.id not in FILL:
|
||||
if nation.id not in self.FILL:
|
||||
continue
|
||||
cities = len(nation.cities)
|
||||
delta = BaseMul.calc(cities, nation)
|
||||
@@ -401,7 +417,7 @@ class Banking(commands.Cog):
|
||||
for nation in result.nations:
|
||||
ids.append(nation.id)
|
||||
if not ids:
|
||||
ids = FILL
|
||||
ids = self.FILL
|
||||
nations = []
|
||||
if 103764 in ids:
|
||||
ids.remove(103764)
|
||||
@@ -809,10 +825,6 @@ class Banking(commands.Cog):
|
||||
v.author = ctx.message.author
|
||||
m = await ctx.send(embed=e, view=v)
|
||||
v.message = m
|
||||
|
||||
# @commands.has_role(987770837627187250)
|
||||
# @commands.command()
|
||||
# async def refill(self, ctx: CustomCtx, option: str, commands.Greedy[Int] = None, *, names: str = None):
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user