adding ping command for the slash test
This commit is contained in:
parent
b1f2e3ad39
commit
8096305121
1 changed files with 10 additions and 4 deletions
|
@ -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 = '✅')
|
||||
|
|
Reference in a new issue