2017-06-11 20:04:03 +02:00
|
|
|
from discord.ext import commands
|
|
|
|
import aiohttp
|
|
|
|
import asyncio
|
|
|
|
import time
|
|
|
|
import discord
|
|
|
|
from .utils import checks
|
|
|
|
|
2017-09-30 18:09:02 +02:00
|
|
|
import requests
|
|
|
|
|
2017-06-11 20:04:03 +02:00
|
|
|
class Admin:
|
|
|
|
"""Commandes secrètes d'administration."""
|
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@checks.is_owner()
|
2017-09-30 18:09:02 +02:00
|
|
|
@commands.command(name='unload_cog', hidden=True)
|
|
|
|
async def _unload(self, ctx, module: str):
|
|
|
|
"""Unloads a module."""
|
|
|
|
try:
|
|
|
|
self.bot.unload_extension("cogs."+module)
|
|
|
|
except Exception as e:
|
|
|
|
await ctx.send('\N{PISTOL}')
|
|
|
|
await ctx.send('{}: {}'.format(type(e).__name__, e))
|
|
|
|
else:
|
|
|
|
await ctx.send('\N{OK HAND SIGN}')
|
|
|
|
print("cog : " + str(module) + " activé")
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.command(name='load_cog', hidden=True)
|
|
|
|
async def _load(self, ctx, module: str):
|
2017-06-11 20:04:03 +02:00
|
|
|
"""Unloads a module."""
|
|
|
|
try:
|
2017-09-30 18:09:02 +02:00
|
|
|
self.bot.load_extension("cogs."+module)
|
2017-06-11 20:04:03 +02:00
|
|
|
except Exception as e:
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send('\N{PISTOL}')
|
|
|
|
await ctx.send('{}: {}'.format(type(e).__name__, e))
|
2017-06-11 20:04:03 +02:00
|
|
|
else:
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send('\N{OK HAND SIGN}')
|
|
|
|
print("cog : " + str(module) + " desactivé")
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
2017-06-11 20:04:03 +02:00
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.command(name='reload_cog', hidden=True)
|
2017-09-30 18:09:02 +02:00
|
|
|
async def _reload(self, ctx, *, module: str):
|
2017-06-11 20:04:03 +02:00
|
|
|
"""Reloads a module."""
|
|
|
|
try:
|
2017-09-30 18:09:02 +02:00
|
|
|
self.bot.unload_extension("cogs."+module)
|
|
|
|
self.bot.load_extension("cogs."+module)
|
|
|
|
await ctx.send("Je te reload ca")
|
2017-07-05 19:58:06 +02:00
|
|
|
except Exception as e: #TODO : A virer dans l'event on_error
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send(':( Erreur :')
|
|
|
|
await ctx.send('{}: {}'.format(type(e).__name__, e))
|
2017-06-11 20:04:03 +02:00
|
|
|
else:
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send('\N{OK HAND SIGN}')
|
|
|
|
print("cog : " + str(module) + " relancé")
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
2017-06-11 20:04:03 +02:00
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.command(name='clear', pass_context=True, hidden=True)
|
|
|
|
async def _clear(self, ctx, number: int):
|
2017-09-30 18:09:02 +02:00
|
|
|
|
|
|
|
await ctx.message.delete()
|
|
|
|
if number < 1000:
|
|
|
|
async for message in ctx.message.channel.history(limit=number):
|
|
|
|
try:
|
|
|
|
await message.delete()
|
|
|
|
except Exception as e: #TODO : A virer dans l'event on_error
|
|
|
|
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
|
|
|
await ctx.send("Hop voila j'ai viré des messages! Hello World")
|
|
|
|
print(str(number)+" messages ont été supprimés")
|
|
|
|
else:
|
|
|
|
await ctx.send('Trop de messages, entre un nombre < 1000')
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
2017-06-11 20:04:03 +02:00
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.command(name='say', pass_context=True, hidden=True)
|
2017-09-30 18:09:02 +02:00
|
|
|
async def _say(self, ctx, *direuh:str):
|
2017-06-11 20:04:03 +02:00
|
|
|
try:
|
2017-09-30 18:09:02 +02:00
|
|
|
dire = ctx.message.content.split("say ")
|
|
|
|
await ctx.message.delete()
|
|
|
|
await ctx.send(dire[1])
|
2017-07-05 19:58:06 +02:00
|
|
|
except Exception as e: #TODO : A virer dans l'event on_error
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send(':sob: Une erreur est survenue : \n {}: {}'.format(type(e).__name__, e))
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
2017-06-11 20:04:03 +02:00
|
|
|
|
|
|
|
@checks.is_owner()
|
|
|
|
@commands.command(pass_context=True, hidden=True)
|
2017-09-30 18:09:02 +02:00
|
|
|
async def _clearterm(self, ctx):
|
2017-06-11 20:04:03 +02:00
|
|
|
clear = "\n" * 100
|
|
|
|
print(clear)
|
2017-09-30 18:09:02 +02:00
|
|
|
await ctx.send(":ok_hand: It's good")
|
|
|
|
|
|
|
|
"""--------------------------------------------------------------------------------------------------------------------------"""
|
|
|
|
|
|
|
|
|
2017-06-11 20:04:03 +02:00
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Admin(bot))
|