| 1234567891011121314151617181920212223242526 |
- import discord
- from discord.ext import commands
- import time
- from discord import app_commands
- async def setup(bot: commands.Bot):
- await bot.add_cog(GeneralCommands(bot))
- class GeneralCommands(commands.Cog):
- """General functionality."""
- def __init__(self, bot: commands.Bot):
- self.bot = bot
- @app_commands.command(
- name="ping",
- description="Get the bot's current websocket and API latency.",
- )
- async def ping(self, interaction: discord.Interaction) -> None:
- start_time = time.time()
- #message = await ctx.send(f"Pong!\nGateway heartbeat in {round(self.bot.latency * 1000)}ms.")
- end_time = time.time()
- await interaction.response.send_message(f"API roundtrip latency {round((end_time - start_time) * 1000)}ms.")
|