diff --git a/.idea/discord.xml b/.idea/discord.xml
index 368d7c1..59b11d1 100644
--- a/.idea/discord.xml
+++ b/.idea/discord.xml
@@ -3,4 +3,7 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5210e9e..f898223 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,68 +2,13 @@
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -93,14 +38,14 @@
-
+
-
+
@@ -128,7 +73,14 @@
-
+
+
+
+
+
+
+
+
@@ -151,18 +103,18 @@
-
+
-
+
-
+
-
+
@@ -179,6 +131,10 @@
+
+
+
+
diff --git a/app.py b/app.py
index 97376fc..3239aae 100644
--- a/app.py
+++ b/app.py
@@ -19,6 +19,7 @@ l_extensions: List[str] = [
"jishaku",
"cogs.Logs",
"cogs.Images",
+ "cogs.Useless",
]
@@ -48,9 +49,9 @@ class TuxBot(commands.AutoShardedBot):
for extension in l_extensions:
try:
self.load_extension(extension)
- print(f"{extension} loaded !")
+ print(extension, "loaded !")
except Exception as e:
- print(f"{type(e).__name__}: {e}")
+ print(f"{type(e).__name__ }:", e)
print("\n"*2)
@@ -69,9 +70,8 @@ class TuxBot(commands.AutoShardedBot):
print(f"\n{'='*118}\n\n")
- @staticmethod
- async def on_resumed():
- print("resumed...")
+ async def on_resumed(self):
+ print(f"resumed... {self.uptime}")
async def get_context(self, message: discord.Message, *, cls=None):
return await super().get_context(message, cls=ContextPlus)
diff --git a/cogs/Images.py b/cogs/Images.py
index 957eece..bcb1957 100644
--- a/cogs/Images.py
+++ b/cogs/Images.py
@@ -5,7 +5,7 @@ import discord
from discord.ext import commands, flags
from app import TuxBot
-from utils.functions.extra import ContextPlus
+from utils.functions.extra import ContextPlus, command_extra
log = logging.getLogger(__name__)
@@ -28,11 +28,11 @@ class Images(commands.Cog, name="Images"):
data = BytesIO(await r.read())
- await ctx.send(
- file=discord.File(data, "output.png")
- )
+ await ctx.send(
+ file=discord.File(data, "output.png")
+ )
- @commands.command(name="phcomment")
+ @command_extra(name="phcomment")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _phcomment(self, ctx: ContextPlus, user: discord.User = None, *, message: commands.clean_content(fix_channel_mentions=True, escape_markdown=True)):
async with ctx.typing():
@@ -55,11 +55,11 @@ class Images(commands.Cog, name="Images"):
data = BytesIO(await r.read())
- await ctx.send(
- file=discord.File(data, "output.png")
- )
+ await ctx.send(
+ file=discord.File(data, "output.png")
+ )
- @commands.command(name="phvideo")
+ @command_extra(name="phvideo")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _phvideo(self, ctx: ContextPlus, image: str, author: discord.User, *, title: commands.clean_content(fix_channel_mentions=True, escape_markdown=True)):
async with ctx.typing():
@@ -74,14 +74,14 @@ class Images(commands.Cog, name="Images"):
data = BytesIO(await r.read())
- await ctx.send(
- file=discord.File(data, "output.png")
- )
+ await ctx.send(
+ file=discord.File(data, "output.png")
+ )
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
@flags.add_flag("--text3", type=str)
- @flags.command(name="balloon")
+ @command_extra(name="balloon")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _balloon(self, ctx: ContextPlus, **passed_flags):
passed_flags["text3"] = passed_flags.get("text3")
@@ -93,48 +93,48 @@ class Images(commands.Cog, name="Images"):
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
@flags.add_flag("--text3", type=str)
- @flags.command(name="butterfly")
+ @command_extra(name="butterfly")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _butterfly(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'butterfly', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
- @flags.command(name="buttons")
+ @command_extra(name="buttons")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _buttons(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'buttons', **passed_flags)
@flags.add_flag("--text1", type=str)
- @flags.command(name="cmm")
+ @command_extra(name="cmm")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _cmm(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'change_my_mind', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
- @flags.command(name="drake")
+ @command_extra(name="drake")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _drake(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'drake', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str, default=False)
- @flags.command(name="fry")
+ @command_extra(name="fry")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _fry(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'fry', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str, default=False)
- @flags.command(name="imagination")
+ @command_extra(name="imagination")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _imagination(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'imagination', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str, default=False)
- @flags.command(name="everywhere")
+ @command_extra(name="everywhere")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _everywhere(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'everywhere', **passed_flags)
@@ -142,13 +142,13 @@ class Images(commands.Cog, name="Images"):
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
@flags.add_flag("--text3", type=str)
- @flags.command(name="choice")
+ @command_extra(name="choice")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _choice(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'choice', **passed_flags)
@flags.add_flag("--text1", type=str)
- @flags.command(name="pika")
+ @command_extra(name="pika")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _pika(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'pika', **passed_flags)
@@ -156,20 +156,20 @@ class Images(commands.Cog, name="Images"):
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
@flags.add_flag("--text3", type=str)
- @flags.command(name="pkp")
+ @command_extra(name="pkp")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _pkp(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'pkp', **passed_flags)
@flags.add_flag("--text1", type=str)
@flags.add_flag("--text2", type=str)
- @flags.command(name="puppet")
+ @command_extra(name="puppet")
@commands.cooldown(1, 5, commands.BucketType.user)
async def _puppet(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'puppet', **passed_flags)
@flags.add_flag("--text1", type=str)
- @flags.command(name="scroll_of_truth", alias=['sot'])
+ @command_extra(name="scroll_of_truth", alias=['sot'])
@commands.cooldown(1, 5, commands.BucketType.user)
async def _sot(self, ctx: ContextPlus, **passed_flags):
await self._send_meme(ctx, 'scroll_of_truth', **passed_flags)
diff --git a/cogs/Logs.py b/cogs/Logs.py
index a238d7b..070ca63 100644
--- a/cogs/Logs.py
+++ b/cogs/Logs.py
@@ -19,6 +19,7 @@ import psutil
from discord.ext import commands, tasks
from app import TuxBot
+from utils.functions.extra import command_extra
log = logging.getLogger(__name__)
@@ -269,7 +270,7 @@ class Logs(commands.Cog):
msg = f'{emoji} `[{dt:%Y-%m-%d %H:%M:%S}] {record.message}`'
await self.logs.get('gateway').send(msg)
- @commands.command('commandstats')
+ @command_extra(name='commandstats')
@commands.is_owner()
async def _commandstats(self, ctx, limit=20):
counter = self.bot.command_stats
diff --git a/cogs/Useless.py b/cogs/Useless.py
new file mode 100644
index 0000000..4788727
--- /dev/null
+++ b/cogs/Useless.py
@@ -0,0 +1,33 @@
+import logging
+
+from discord.ext import commands
+
+from app import TuxBot
+from utils.functions.extra import ContextPlus, command_extra
+
+log = logging.getLogger(__name__)
+
+
+class Useless(commands.Cog, name="Useless"):
+ def __init__(self, bot):
+ self.bot = bot
+
+ @command_extra(name="space")
+ @commands.cooldown(1, 5, commands.BucketType.user)
+ async def _space(self, ctx: ContextPlus):
+ await ctx.send("""
+ > ˚ * . . ✦ ,
+ >
+ > . . ゚ . .
+ >
+ > , . :sunny: . . . ✦ , :rocket: , . . ˚ , . . . * ✦ . . . . :new_moon: . .
+ >
+ > ˚ ゚ . . :earth_americas: , * . . ✦ ˚ . . . ✦ ˚ . . ✦ ,
+ >
+ > . . ゚ . .
+ """)
+
+
+def setup(bot: TuxBot):
+ cog = Useless(bot)
+ bot.add_cog(cog)
diff --git a/requirements.txt b/requirements.txt
index d5a26eb..5c1a15e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@ aiohttp==3.6.2
aiosqlite==0.13.0
astunparse==1.6.3
async-timeout==3.0.1
-asyncpg==0.20.1
+# asyncpg==0.20.1
attrs==19.3.0
braceexpand==0.1.5
chardet==3.0.4
@@ -20,8 +20,7 @@ Pillow==7.1.2
psutil==5.7.0
PyPika==0.37.6
six==1.14.0
-sympy==1.5.1
-tortoise-orm==0.16.11
+# tortoise-orm==0.16.11
typing-extensions==3.7.4.2
websockets==8.1
yarl==1.4.2
diff --git a/utils/functions/extra.py b/utils/functions/extra.py
index a186dd4..5c4dbf5 100644
--- a/utils/functions/extra.py
+++ b/utils/functions/extra.py
@@ -1,9 +1,11 @@
import ast
+import asyncio
import json
import os
import discord
-from discord.ext import commands
+from discord.ext import commands, flags
+
from configs.bot.protected import protected
from configs.bot.settings import prefix
@@ -41,7 +43,47 @@ class ContextPlus(commands.Context):
ast.literal_eval(embed)
)
- return await super().send(content, *args, **kwargs)
+ if self.command.deletable:
+ message = await super().send(content, *args, **kwargs)
+ await message.add_reaction('🗑')
+
+ def check(reaction: discord.Reaction, user: discord.User):
+ return user == self.author \
+ and str(reaction.emoji) == '🗑' \
+ and reaction.message.id == message.id
+
+ try:
+ await self.bot.wait_for(
+ 'reaction_add',
+ timeout=120.0,
+ check=check
+ )
+ except asyncio.TimeoutError:
+ await message.remove_reaction('🗑', self.bot.user)
+ else:
+ await message.delete()
+ else:
+ return await super().send(content, *args, **kwargs)
+
+
+class CommandPLus(flags.FlagCommand):
+ def __init__(self, function, **kwargs):
+ super().__init__(function, **kwargs)
+ self.deletable = kwargs.pop("deletable", True)
+
+
+def command_extra(*args, **kwargs):
+ return commands.command(*args, **kwargs, cls=CommandPLus)
+
+
+class GroupPlus(flags.FlagGroup):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.deletable = kwargs.pop("deletable", True)
+
+
+def group_extra(*args, **kwargs):
+ return commands.group(*args, **kwargs, cls=GroupPlus)
async def get_prefix(bot, message):