tuxbot-bot/cogs/admin.py
2017-07-05 13:58:06 -04:00

68 lines
2.3 KiB
Python
Executable file

from discord.ext import commands
import aiohttp
import asyncio
import time
import discord
from .utils import checks
class Admin:
"""Commandes secrètes d'administration."""
def __init__(self, bot):
self.bot = bot
@checks.is_owner()
@commands.command()
async def unload(self, module: str):
"""Unloads a module."""
try:
self.bot.unload_extension(module)
except Exception as e:
await self.bot.say('\N{PISTOL}')
await self.bot.say('{}: {}'.format(type(e).__name__, e))
else:
await self.bot.say('\N{OK HAND SIGN}')
@checks.is_owner()
@commands.command(name='reload_cog', hidden=True)
async def _reload(self, *, module: str):
"""Reloads a module."""
try:
self.bot.unload_extension(module)
self.bot.load_extension(module)
await self.bot.say("Nice !")
except Exception as e: #TODO : A virer dans l'event on_error
await self.bot.say(':( Erreur :')
await self.bot.say('{}: {}'.format(type(e).__name__, e))
else:
await self.bot.say('\N{OK HAND SIGN}')
@checks.is_owner()
@commands.command(name='clear', pass_context=True, hidden=True)
async def _clear(self, ctx, number: int):
try:
number = number + 1
await self.bot.purge_from(ctx.message.channel, limit=number)
await self.bot.say("Hello World !")
except Exception as e: #TODO : A virer dans l'event on_error
await self.bot.say(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
@checks.is_owner()
@commands.command(name='say', pass_context=True, hidden=True)
async def _say(self, ctx, *dire:str):
try:
await self.bot.say(dire)
await self.bot.delete_message(ctx.message)
except Exception as e: #TODO : A virer dans l'event on_error
await self.bot.say(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
@checks.is_owner()
@commands.command(pass_context=True, hidden=True)
async def _clearterm(self):
clear = "\n" * 100
print(clear)
await self.bot.say(":ok_hand: It's good")
def setup(bot):
bot.add_cog(Admin(bot))