add alliance cmd
This commit is contained in:
1 parent
90740244d3
commit
b5863b9e27
3 files changed
+151
-6
No files matched your search
+92
-4
@@ -89,9 +89,11 @@ class Banking(commands.Cog):
|
||||
async with self.bot.db_pool.acquire() as conn:
|
||||
query = "SELECT id FROM warchest"
|
||||
rows = await conn.fetch(query)
|
||||
self.FILL = [row[0] for row in rows]
|
||||
self.WARCHEST_IDS = [row[0] for row in rows]
|
||||
return self.WARCHEST_IDS
|
||||
except Exception as e:
|
||||
self.WARCHEST_IDS = []
|
||||
self.WARCHEST_IDS = []
|
||||
raise e
|
||||
|
||||
@commands.has_any_role("Government", "The Croak Council")
|
||||
@commands.command()
|
||||
@@ -292,7 +294,7 @@ class Banking(commands.Cog):
|
||||
f"{Emojis.aluminum} {total.get('aluminum'):,}\n"
|
||||
f"{Emojis.steel} {total.get('steel100'):,}"
|
||||
)
|
||||
embeds.append(e)
|
||||
embeds.insert(0, e)
|
||||
|
||||
class ConfirmButton(discord.ui.Button):
|
||||
def __init__(
|
||||
@@ -390,7 +392,7 @@ class Banking(commands.Cog):
|
||||
ctx=ctx, custom_items=[ConfirmButton(bot=self.bot, p=paginator)]
|
||||
)
|
||||
|
||||
@commands.has_role(1353931003365691392)
|
||||
@commands.has_any_role("Government", "The Croak Council")
|
||||
@commands.command()
|
||||
async def rss(
|
||||
self,
|
||||
@@ -828,6 +830,92 @@ class Banking(commands.Cog):
|
||||
v.message = m
|
||||
|
||||
|
||||
@commands.has_any_role("The Croak Council", "Government")
|
||||
@commands.command(aliases=["wca"])
|
||||
async def wcadd(self, ctx: CustomCtx, ids: commands.Greedy[int]):
|
||||
"""
|
||||
add ids to warchest.
|
||||
"""
|
||||
if not ids:
|
||||
return await ctx.send("no ids provided")
|
||||
await self.fetch_warchest_ids()
|
||||
in_list = []
|
||||
notin_list = []
|
||||
for nation in ids:
|
||||
if nation in self.WARCHEST_IDS:
|
||||
in_list.append(nation)
|
||||
else:
|
||||
notin_list.append(nation)
|
||||
if in_list:
|
||||
await ctx.send(f"> nations already in warchest refill list : `{in_list}`")
|
||||
if not notin_list:
|
||||
await ctx.send("> nation ids provided are already in list.")
|
||||
return
|
||||
async with self.bot.db_pool.acquire() as conn:
|
||||
async with conn.transaction():
|
||||
for nation in notin_list:
|
||||
await conn.execute(
|
||||
"INSERT INTO warchest (id) VALUES ($1)",
|
||||
nation
|
||||
)
|
||||
|
||||
await ctx.send(f"> inserted nations in war refill list: {notin_list}")
|
||||
await ctx.invoke(discord.utils.get(self.bot.commands, name='wclist'))
|
||||
|
||||
|
||||
|
||||
@commands.has_any_role("The Croak Council", "Government")
|
||||
@commands.command(aliases=["wcl"])
|
||||
async def wclist(self, ctx: CustomCtx):
|
||||
await self.fetch_warchest_ids()
|
||||
result = await self.kit.query(
|
||||
"nations",
|
||||
{"id": self.WARCHEST_IDS},
|
||||
"id, nation_name"
|
||||
)
|
||||
i = 0
|
||||
content = "Nations in warchest refill list\n"
|
||||
for nation in result.nations:
|
||||
i+=1
|
||||
content += f"{i:>3}. {nation.id} {nation.nation_name}\n"
|
||||
await ctx.cbsend(content=content)
|
||||
|
||||
|
||||
@commands.has_any_role("The Croak Council", "Government")
|
||||
@commands.command(aliases=["wcr"])
|
||||
async def wcremove(self, ctx: commands.Context, ids: commands.Greedy[int]):
|
||||
"""
|
||||
Remove ids from warchest.
|
||||
"""
|
||||
if not ids:
|
||||
return await ctx.send("No ids provided.")
|
||||
await self.fetch_warchest_ids()
|
||||
removed_list = []
|
||||
not_in_list = []
|
||||
|
||||
for nation in ids:
|
||||
if nation in self.WARCHEST_IDS:
|
||||
removed_list.append(nation)
|
||||
else:
|
||||
not_in_list.append(nation)
|
||||
|
||||
if not_in_list:
|
||||
await ctx.send(f"> Nations not found in warchest refill list: `{not_in_list}`")
|
||||
|
||||
if removed_list:
|
||||
async with self.bot.db_pool.acquire() as conn:
|
||||
async with conn.transaction():
|
||||
for nation in removed_list:
|
||||
await conn.execute(
|
||||
"DELETE FROM warchest WHERE id = ($1)",
|
||||
nation
|
||||
)
|
||||
await ctx.send(f"> Removed nations from warchest refill list: `{removed_list}`")
|
||||
await ctx.invoke(discord.utils.get(self.bot.commands, name='wclist'))
|
||||
else:
|
||||
await ctx.send("> None of the provided nations were in the warchest refill list.")
|
||||
|
||||
|
||||
|
||||
async def setup(bot: Brahmos):
|
||||
await bot.add_cog(Banking(bot))
|
||||
Reference in new issue
Block a user