this is should be slash command about bot ping but i didnt understand how write slahs commands in cogs
import discord
from discord.ext import commands
from discord import Interaction
client = commands.Bot(command_prefix='#', intents=discord.Intents.all())
class ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
await client.tree.sync()
print("/ping.py is ready!")
@client.tree.command(name="ping", description="shows bot ping in ms.")
async def ping(self, interaction: discord.Interaction):
bot_latency = round(self, client.latency * 1000)
await interaction.response.send_message(f"Pong!{bot_latency} ms.")
async def setup(client):
await client.add_cog(ping(client))
error: TypeError: unsupported type annotation <class 'discord.interactions.Interaction'>
help pls, i dont even close understand where is the problem