2017-06-11 20:04:03 +02:00
from discord . ext import commands
from random import choice , shuffle
import aiohttp
import asyncio
import time
import discord
import platform , socket
import os
2017-09-30 18:09:02 +02:00
import wikipedia , bs4
2017-06-11 20:04:03 +02:00
class General :
""" Commandes générales. """
def __init__ ( self , bot ) :
self . bot = bot
@commands.command ( )
2017-09-30 18:09:02 +02:00
async def ping ( self , ctx ) :
t1 = time . perf_counter ( )
await ctx . trigger_typing ( )
t2 = time . perf_counter ( )
result = round ( ( t2 - t1 ) * 1000 )
if int ( result ) > = 200 :
em = discord . Embed ( title = " Ping : " + str ( result ) + " ms " , description = " ... c ' est quoi ce ping ! " , colour = 0xFF1111 )
await ctx . send ( embed = em )
elif int ( result ) > 100 and int ( result ) < 200 :
em = discord . Embed ( title = " Ping : " + str ( result ) + " ms " , description = " Ca va, ça peut aller, mais j ' ai l ' impression d ' avoir 40 ans ! " , colour = 0xFFA500 )
await ctx . send ( embed = em )
elif int ( result ) < = 100 :
em = discord . Embed ( title = " Ping : " + str ( result ) + " ms " , description = " Wow c ' te vitesse de réaction, je m ' épate moi-même ! " , colour = 0x11FF11 )
await ctx . send ( embed = em )
2017-06-11 20:04:03 +02:00
##INFO##
@commands.command ( )
2017-09-30 18:09:02 +02:00
async def info ( self , ctx ) :
2017-06-11 20:04:03 +02:00
""" Affiches des informations sur le bot """
text = open ( ' texts/info.md ' ) . read ( )
os_info = str ( platform . system ( ) ) + " / " + str ( platform . release ( ) )
em = discord . Embed ( title = ' Informations sur TuxBot ' , description = text . format ( os_info , platform . python_version ( ) , socket . gethostname ( ) , discord . __version__ ) , colour = 0x89C4F9 )
em . set_footer ( text = os . getcwd ( ) + " /bot.py " )
2017-09-30 18:09:02 +02:00
await ctx . send ( embed = em )
2017-06-11 20:04:03 +02:00
## HELP PLZ ##
@commands.command ( )
2017-09-30 18:09:02 +02:00
async def help ( self , ctx ) :
2017-06-11 20:04:03 +02:00
""" Affiches l ' aide du bot """
text = open ( ' texts/help.md ' ) . read ( )
em = discord . Embed ( title = ' Commandes de TuxBot ' , description = text , colour = 0x89C4F9 )
2017-09-30 18:09:02 +02:00
await ctx . send ( embed = em )
2017-06-11 20:04:03 +02:00
def setup ( bot ) :
bot . add_cog ( General ( bot ) )