Add ping command to the bot
This commit is contained in:
parent
203be35c7d
commit
6cc4f8fcdc
30
modules/tools.py
Normal file
30
modules/tools.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
import discord
|
||||||
|
import traductions as tr
|
||||||
|
|
||||||
|
|
||||||
|
class MainClass:
|
||||||
|
name = "tools"
|
||||||
|
|
||||||
|
def __init__(self, guild):
|
||||||
|
self.guild = guild
|
||||||
|
|
||||||
|
async def ping(self, msg, command, args):
|
||||||
|
|
||||||
|
embed = discord.Embed(title=tr.tr[self.guild.config["lang"]]["modules"]["tools"]["ping"]["title"])
|
||||||
|
t1 = time.time()
|
||||||
|
reponse = await msg.channel.send(embed=embed)
|
||||||
|
for i in range(1, 5):
|
||||||
|
embed = discord.Embed(title=tr.tr[self.guild.config["lang"]]["modules"]["tools"]["ping"]["title"])
|
||||||
|
|
||||||
|
embed.add_field(name="Temps de réponse", value=str((time.time() - t1) / i) + "s ")
|
||||||
|
embed.add_field(name="Latence", value=str(self.guild.bot.latency))
|
||||||
|
await reponse.edit(embed=embed)
|
||||||
|
|
||||||
|
async def on_message(self, msg):
|
||||||
|
if msg.content.startswith(self.guild.config["prefix"]):
|
||||||
|
command, *args = msg.content.lstrip(self.guild.config["prefix"]).split(" ")
|
||||||
|
if command == "ping":
|
||||||
|
await self.ping(msg, command, args)
|
||||||
|
return
|
@ -119,6 +119,21 @@ tr = {
|
|||||||
},
|
},
|
||||||
"pi": "Voici les 2000 décimales de pi que vous avez demandé (à partir de la {debut}ème):",
|
"pi": "Voici les 2000 décimales de pi que vous avez demandé (à partir de la {debut}ème):",
|
||||||
},
|
},
|
||||||
|
"tools": {
|
||||||
|
"description": "Commandes utiles",
|
||||||
|
"help": {
|
||||||
|
"ping": {
|
||||||
|
"description": "Renvoie le temps de réponse du bot",
|
||||||
|
"examples": [
|
||||||
|
("`{prefix}ping`", "Affiche le temps de réponse du bot"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ping": {
|
||||||
|
"title": "Pong!"
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"LangNotFoundError": "La langue {lang} est introuvable, tapez {prefix}list_lang pour voir les langues "
|
"LangNotFoundError": "La langue {lang} est introuvable, tapez {prefix}list_lang pour voir les langues "
|
||||||
|
Loading…
Reference in New Issue
Block a user