feat(automation): add possibility to delete command output

This commit is contained in:
Romain J 2020-05-27 00:58:53 +02:00
commit 45d61fc71d
8 changed files with 136 additions and 102 deletions

View file

@ -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)

View file

@ -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

33
cogs/Useless.py Normal file
View file

@ -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)