Home python Discord.py | Slash commands

Discord.py | Slash commands




My problem is that when I want to use a slash command, the answer to it does not appear immediately. Only after 2, 3 times using this command. First, an error appears, and then everything works fine. I would like to know what this problem is connected with, and you can somehow solve it. So that the expected response from the command appears immediately, and not an error.

import discord
from discord.ext import commands
from discord_slash import SlashCommand
Bot = commands.Bot (command_prefix = "c:", intents = discord.Intents.all ())
slash = SlashCommand (Bot, sync_commands = True)
@ slash.slash (description = "Bot check")
async def ping (ctx):
  ping = Bot.ws.latency
  emb = discord.Embed (description = "Shcha sec ...", color = discord.Color.orange ())
  msg = await ctx.send (embed = emb)
  emb = discord.Embed (description = f'Pong! `{ping * 1000: .0f} ms`: ping_pong: ', color = discord.Color.orange ())
  await msg.edit (embed = emb)
  print (f '[Logs] Currently ping == {ping * 1000: .0f} ms | ping')
Bot.run ('TOKEN')

Answer 1, authority 100%

After updating the code, you need to wait a while, as the rate limit is triggered

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions