add rss command
This commit is contained in:
1 parent
9dfa2c1ec9
commit
f7e8037bf5
2 files changed
+49
-2
No files matched your search
@@ -351,6 +351,54 @@ class Banking(commands.Cog):
|
|||||||
await paginator.start(
|
await paginator.start(
|
||||||
ctx=ctx, custom_items=[ConfirmButton(bot=self.bot, p=paginator)]
|
ctx=ctx, custom_items=[ConfirmButton(bot=self.bot, p=paginator)]
|
||||||
)
|
)
|
||||||
|
@commands.has_role(987770837627187250)
|
||||||
|
@commands.command()
|
||||||
|
async def rss(self, ctx: CustomCtx, ids: commands.Greedy[int] = []):
|
||||||
|
"""get resources of a nation in alliance
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ids (commands.Greedy[int]): ids of nations
|
||||||
|
"""
|
||||||
|
d_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),
|
||||||
|
)
|
||||||
|
embeds = []
|
||||||
|
for id in ids:
|
||||||
|
kit = self.kit if (id != 103764) else d_kit
|
||||||
|
nation = await kit.query(
|
||||||
|
"nations",
|
||||||
|
{"id": id, "first": 1},
|
||||||
|
"id, nation_name, discord,money, flag, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel, num_cities",
|
||||||
|
)
|
||||||
|
nation = nation.nations[0]
|
||||||
|
e = discord.Embed(
|
||||||
|
title=f"Resources for {nation.nation_name} c({nation.num_cities})",
|
||||||
|
color=ctx.author.color,
|
||||||
|
timestamp=datetime.datetime.utcnow(),
|
||||||
|
url=f"https://politicsandwar.com/nation/id={nation.id}",
|
||||||
|
)
|
||||||
|
e.set_thumbnail(url=nation.flag)
|
||||||
|
e.description = (
|
||||||
|
f"{Emojis.money} {nation.money:,}\n"
|
||||||
|
f"{Emojis.food} {nation.food:,}\n"
|
||||||
|
f"{Emojis.uranium} {nation.uranium:,}\n"
|
||||||
|
f"{Emojis.coal} {nation.coal:,}\n"
|
||||||
|
f"{Emojis.iron} {nation.iron:,}\n"
|
||||||
|
f"{Emojis.oil} {nation.oil:,}\n"
|
||||||
|
f"{Emojis.bauxite} {nation.bauxite:,}\n"
|
||||||
|
f"{Emojis.lead} {nation.lead:,}\n"
|
||||||
|
f"{Emojis.munitions} {nation.munitions:,}\n"
|
||||||
|
f"{Emojis.gasoline} {nation.gasoline:,}\n"
|
||||||
|
f"{Emojis.aluminum} {nation.aluminum:,}\n"
|
||||||
|
f"{Emojis.steel} {nation.steel:,}"
|
||||||
|
)
|
||||||
|
embeds.append(e)
|
||||||
|
|
||||||
|
await ctx.paginate(pages=embeds)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot: Brahmos):
|
async def setup(bot: Brahmos):
|
||||||
|
|||||||
+1
-2
@@ -1,8 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import List, Literal, Optional, Union
|
from typing import List, Literal, Optional, Union
|
||||||
|
|
||||||
from discord import (ButtonStyle, Embed, Interaction, Message, TextStyle,
|
from discord import ButtonStyle, Embed, Interaction, Message, TextStyle, Webhook
|
||||||
Webhook)
|
|
||||||
from discord.ext.commands import Bot, Context, errors
|
from discord.ext.commands import Bot, Context, errors
|
||||||
from discord.ui import Button, Item, Modal, Select, TextInput, button
|
from discord.ui import Button, Item, Modal, Select, TextInput, button
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user