reformat
This commit is contained in:
1 parent
783b38e28d
commit
32ee918415
10 files changed
+56
-39
No files matched your search
+1
-1
@@ -7,6 +7,7 @@ import aiohttp
|
|||||||
import discord
|
import discord
|
||||||
import jishaku
|
import jishaku
|
||||||
from discord.ext.commands import Bot, Context
|
from discord.ext.commands import Bot, Context
|
||||||
|
|
||||||
from utils.paginator import Paginator, WebhookPaginator
|
from utils.paginator import Paginator, WebhookPaginator
|
||||||
|
|
||||||
OWNER = json.load(open("store/cfg.json"))["ReplOwners"]
|
OWNER = json.load(open("store/cfg.json"))["ReplOwners"]
|
||||||
@@ -28,7 +29,6 @@ class CustomCtx(Context):
|
|||||||
await self.Paginator(pages=pages, pagetype=pagetype).start(ctx=self, **kwargs)
|
await self.Paginator(pages=pages, pagetype=pagetype).start(ctx=self, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Brahmos(Bot):
|
class Brahmos(Bot):
|
||||||
"""
|
"""
|
||||||
Custom bot class
|
Custom bot class
|
||||||
|
|||||||
+2
-4
@@ -11,11 +11,12 @@ from typing import List, Literal, Optional, Union
|
|||||||
import aiofiles
|
import aiofiles
|
||||||
import discord
|
import discord
|
||||||
import pytz
|
import pytz
|
||||||
from botclass import CustomCtx, Brahmos
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from jishaku.codeblocks import codeblock_converter
|
from jishaku.codeblocks import codeblock_converter
|
||||||
from psutil import Process
|
from psutil import Process
|
||||||
|
|
||||||
|
from botclass import Brahmos, CustomCtx
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uvloop
|
import uvloop
|
||||||
except:
|
except:
|
||||||
@@ -105,7 +106,6 @@ class Main(commands.Cog):
|
|||||||
pass
|
pass
|
||||||
await ctx.send(content)
|
await ctx.send(content)
|
||||||
|
|
||||||
|
|
||||||
@commands.command(name="reload", hidden=True)
|
@commands.command(name="reload", hidden=True)
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def reloadexts(self, ctx: commands.Context):
|
async def reloadexts(self, ctx: commands.Context):
|
||||||
@@ -234,8 +234,6 @@ class Main(commands.Cog):
|
|||||||
await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")
|
await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with bot:
|
async with bot:
|
||||||
await bot.add_cog(Main(bot))
|
await bot.add_cog(Main(bot))
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import aiofiles
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from utils.paginator import Paginator
|
from utils.paginator import Paginator
|
||||||
|
|
||||||
ownerid = json.load(open("store/cfg.json"))["ReplOwners"]
|
ownerid = json.load(open("store/cfg.json"))["ReplOwners"]
|
||||||
|
|||||||
+26
-22
@@ -1,16 +1,18 @@
|
|||||||
import aiohttp
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from typing import List, Literal, Optional
|
from typing import List, Literal, Optional
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
from botclass import CustomCtx, Brahmos
|
|
||||||
from discord.ext import commands
|
|
||||||
import pnwkit
|
import pnwkit
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
from botclass import Brahmos, CustomCtx
|
||||||
from utils.base import BasicView
|
from utils.base import BasicView
|
||||||
from utils.emojis import Emojis
|
from utils.emojis import Emojis
|
||||||
|
|
||||||
|
|
||||||
class Banking(commands.Cog):
|
class Banking(commands.Cog):
|
||||||
def __init__(self, bot: Brahmos):
|
def __init__(self, bot: Brahmos):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@@ -18,7 +20,7 @@ class Banking(commands.Cog):
|
|||||||
api_key=os.getenv("pnwAPIKEY"),
|
api_key=os.getenv("pnwAPIKEY"),
|
||||||
bot_key=os.getenv("pnwBOTKEY"),
|
bot_key=os.getenv("pnwBOTKEY"),
|
||||||
bot_key_api_key=os.getenv("pnwACCKEY"),
|
bot_key_api_key=os.getenv("pnwACCKEY"),
|
||||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop)
|
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
||||||
)
|
)
|
||||||
|
|
||||||
@commands.has_role(987770837627187250)
|
@commands.has_role(987770837627187250)
|
||||||
@@ -31,15 +33,16 @@ class Banking(commands.Cog):
|
|||||||
resources = await self.kit.query(
|
resources = await self.kit.query(
|
||||||
"alliances",
|
"alliances",
|
||||||
{"id": 10177, "first": 1},
|
{"id": 10177, "first": 1},
|
||||||
"money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel"
|
"money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel",
|
||||||
)
|
)
|
||||||
resources = resources.alliances[0]
|
resources = resources.alliances[0]
|
||||||
e = discord.Embed(
|
e = discord.Embed(
|
||||||
color=discord.Color.yellow(),
|
color=discord.Color.yellow(),
|
||||||
timestamp=datetime.datetime.utcnow(),
|
timestamp=datetime.datetime.utcnow(),
|
||||||
title="Approve Transaction"
|
title="Approve Transaction",
|
||||||
)
|
)
|
||||||
e.description = ("Transferring resources to **Damn I Love Frogs**\n"
|
e.description = (
|
||||||
|
"Transferring resources to **Damn I Love Frogs**\n"
|
||||||
f"{Emojis.money} {resources.money:,}\n"
|
f"{Emojis.money} {resources.money:,}\n"
|
||||||
f"{Emojis.food} {resources.food:,}\n"
|
f"{Emojis.food} {resources.food:,}\n"
|
||||||
f"{Emojis.uranium} {resources.uranium:,}\n"
|
f"{Emojis.uranium} {resources.uranium:,}\n"
|
||||||
@@ -54,32 +57,32 @@ class Banking(commands.Cog):
|
|||||||
f"{Emojis.steel} {resources.steel:,}"
|
f"{Emojis.steel} {resources.steel:,}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class View(BasicView):
|
class View(BasicView):
|
||||||
def __init__(self, timeout: float | None = 60, clear: bool | None = False, kit: pnwkit.QueryKit = None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
timeout: float | None = 60,
|
||||||
|
clear: bool | None = False,
|
||||||
|
kit: pnwkit.QueryKit = None,
|
||||||
|
):
|
||||||
super().__init__(timeout, clear)
|
super().__init__(timeout, clear)
|
||||||
self.kit = kit
|
self.kit = kit
|
||||||
|
|
||||||
|
@discord.ui.button(label="cancel", style=discord.ButtonStyle.red)
|
||||||
@discord.ui.button(
|
|
||||||
label="cancel",
|
|
||||||
style=discord.ButtonStyle.red
|
|
||||||
)
|
|
||||||
async def cancel(self, i: discord.Interaction, _):
|
async def cancel(self, i: discord.Interaction, _):
|
||||||
await i.message.edit(content="> transaction cancelled", embed=None, view=None)
|
await i.message.edit(
|
||||||
|
content="> transaction cancelled", embed=None, view=None
|
||||||
|
)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@discord.ui.button(
|
@discord.ui.button(label="confirm", style=discord.ButtonStyle.green)
|
||||||
label="confirm",
|
|
||||||
style=discord.ButtonStyle.green
|
|
||||||
)
|
|
||||||
async def confirm(self, i: discord.Interaction, _):
|
async def confirm(self, i: discord.Interaction, _):
|
||||||
e.title = "Transaction Approved"
|
e.title = "Transaction Approved"
|
||||||
e.description = e.description.replace("Transferring", "Transferred")
|
e.description = e.description.replace("Transferring", "Transferred")
|
||||||
e.color = discord.Color.green()
|
e.color = discord.Color.green()
|
||||||
await self.kit.mutation(
|
await self.kit.mutation(
|
||||||
"bankWithdraw",
|
"bankWithdraw",
|
||||||
{"receiver": 10198,
|
{
|
||||||
|
"receiver": 10198,
|
||||||
"receiver_type": 2,
|
"receiver_type": 2,
|
||||||
"money": resources.money,
|
"money": resources.money,
|
||||||
"food": resources.food,
|
"food": resources.food,
|
||||||
@@ -92,12 +95,13 @@ class Banking(commands.Cog):
|
|||||||
"munitions": resources.munitions,
|
"munitions": resources.munitions,
|
||||||
"gasoline": resources.gasoline,
|
"gasoline": resources.gasoline,
|
||||||
"aluminum": resources.aluminum,
|
"aluminum": resources.aluminum,
|
||||||
"steel" : resources.steel
|
"steel": resources.steel,
|
||||||
},
|
},
|
||||||
"id"
|
"id",
|
||||||
)
|
)
|
||||||
await i.message.edit(embed=e, view=None)
|
await i.message.edit(embed=e, view=None)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
await ctx.send(embed=e, view=View(kit=self.kit))
|
await ctx.send(embed=e, view=View(kit=self.kit))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -3,9 +3,10 @@ import random
|
|||||||
from typing import List, Literal, Optional
|
from typing import List, Literal, Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from botclass import CustomCtx, Brahmos
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
|
from botclass import Brahmos, CustomCtx
|
||||||
|
|
||||||
|
|
||||||
class Misc(commands.Cog):
|
class Misc(commands.Cog):
|
||||||
def __init__(self, bot: Brahmos):
|
def __init__(self, bot: Brahmos):
|
||||||
@@ -28,7 +29,7 @@ class Misc(commands.Cog):
|
|||||||
"yes",
|
"yes",
|
||||||
"not with u lmao",
|
"not with u lmao",
|
||||||
"in your dreams",
|
"in your dreams",
|
||||||
"no"
|
"no",
|
||||||
]
|
]
|
||||||
|
|
||||||
num = random.randint(1, 10)
|
num = random.randint(1, 10)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from utils.base import BasicView
|
from utils.base import BasicView
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
class Emojis:
|
class Emojis:
|
||||||
food = "<:food:1220371848789753926>"
|
food = "<:food:1220371848789753926>"
|
||||||
aluminum = "<:aluminum:1220371851692343397>"
|
aluminum = "<:aluminum:1220371851692343397>"
|
||||||
|
|||||||
+1
-9
@@ -6,19 +6,11 @@ from typing import List, Union
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
TESTID = 356099868638445578
|
|
||||||
ID = int(base64.b64decode(os.getenv("TOKEN").split(".")[0]))
|
|
||||||
|
|
||||||
|
|
||||||
async def get_webhook(
|
async def get_webhook(
|
||||||
channel: Union[discord.TextChannel, discord.ForumChannel, discord.VoiceChannel]
|
channel: Union[discord.TextChannel, discord.ForumChannel, discord.VoiceChannel]
|
||||||
) -> discord.Webhook:
|
) -> discord.Webhook:
|
||||||
"""Get a webhook created by bot in the channel"""
|
"""Get a webhook created by bot in the channel"""
|
||||||
if ID != TESTID:
|
wname = "brahmos"
|
||||||
wname = "ゼロ"
|
|
||||||
else:
|
|
||||||
wname = "ゼロ~"
|
|
||||||
|
|
||||||
hooks: List[discord.Webhook] = await channel.webhooks()
|
hooks: List[discord.Webhook] = await channel.webhooks()
|
||||||
for hook in hooks:
|
for hook in hooks:
|
||||||
if hook.name == wname:
|
if hook.name == wname:
|
||||||
|
|||||||
+3
-1
@@ -1,9 +1,11 @@
|
|||||||
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, Webhook
|
from discord import (ButtonStyle, Embed, Interaction, Message, TextStyle,
|
||||||
|
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
|
||||||
|
|
||||||
from utils.base import BasicView
|
from utils.base import BasicView
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import pnwkit
|
||||||
|
|
||||||
|
|
||||||
|
class Bank:
|
||||||
|
def __init__(self, kit: pnwkit.QueryKit):
|
||||||
|
self.kit = kit
|
||||||
|
|
||||||
|
async def balance(self, id: int):
|
||||||
|
"""
|
||||||
|
receiver_type:
|
||||||
|
()
|
||||||
|
"""
|
||||||
|
resources = await self.kit.query(
|
||||||
|
"alliances",
|
||||||
|
{"id": 10177, "first": 1},
|
||||||
|
"money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel",
|
||||||
|
)
|
||||||
Reference in new issue
Block a user