Код: Выделить всё
import discord
from discord.ext import commands
class Ping(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
message = await ctx.send("Pong!")
latency = self.bot.latency * 1000
await message.edit(content=f'Pong! **{latency:.2f} ms**')
async def setup(bot):
await bot.add_cog(Ping(bot))
Код: Выделить всё
import discord
from discord import app_commands
from discord.ext import commands
class sPing(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command()
async def ping(self, interaction: discord.Interaction):
latency = self.bot.latency * 1000
await interaction.response.send_message(content='Pong!')
msg = await interaction.original_response()
await msg.edit(content=f'Pong! **{latency:.2f} ms**')
async def setup(bot):
await bot.add_cog(sPing(bot))
Подробнее здесь: https://stackoverflow.com/questions/785 ... h-commands