From 80963051210fd8995e9d1b6e5c0deb829b041165 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 28 May 2021 14:10:05 +0200 Subject: [PATCH] adding ping command for the slash test --- src/cogs/slash.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cogs/slash.py b/src/cogs/slash.py index ec5c133..7bee9a4 100644 --- a/src/cogs/slash.py +++ b/src/cogs/slash.py @@ -1,4 +1,5 @@ import discord +import time from discord.ext import commands from discord_slash import cog_ext, SlashContext @@ -11,7 +12,12 @@ class Slash(commands.Cog): def __init__(self, client): self.client = client - @cog_ext.cog_slash(name="test") - async def _test(self, ctx: SlashContext): - embed = discord.Embed(title="embed test") - await ctx.send(content="test", embeds=[embed]) + @cog_ext.cog_slash(name="pingSlash", description = "Affiche mon ping.") + async def _pingSlash(self, ctx: SlashContext): + now = int(round(time.time() * 1000)) + ping = now - int(round(ctx.message.created_at.timestamp() * 1000)) + embed = discord.Embed(description = 'Pinging...') + message = await ctx.send(embed = embed) + ping2 = int(round(time.time() * 1000)) - now + await message.edit(embed = discord.Embed(color = discord.Colour.random(), description = f':hourglass: {round(self.client.latency * 1000)} ms\n\n:stopwatch: {ping2} ms\n\n:heartbeat: {ping} ms')) + await ctx.message.add_reaction(emoji = '✅')