discord py command not found

Takeraparterer

I'm making a discord bot, and trying to have / menu context commands. this is my code:

import discord
from discord.ext import commands
from dotenv import load_dotenv
import requests
load_dotenv()
url = "https://discord.com/api/v10/applications/ID/commands"
TOKEN = "TOKEN"


# This is an example CHAT_INPUT or Slash Command, with a type of 1
json = {
    "name": "ping",
    "type": 1,
    "description": "test lmao",
    "options": [
        {
            "name": "test",
            "description": "test",
            "type": 3,
            "required": True,
        }
    ]
}

# For authorization, you can use either your bot token

headers = {
    "Authorization": "Bot TOKEN"
}

r = requests.post(url, headers=headers, json=json)


bot = commands.Bot(command_prefix='/',intents=discord.Intents.all())

@bot.event
async def on_read():
  print("Bot is ready!")

@bot.command(pass_context = True)
async def ping(ctx, arg):
  await ctx.send("Pong! "+ str(arg))



bot.run(TOKEN)

The application command shows up, but the bot doesn't respond and I get this error: discord.app_commands.errors.CommandNotFound: Application command 'ping' not found

Kejax

Seems like you try to use slash commands, but you aren’t defining any app commands (slash commands) you‘re defining a text command.

to you slash commands, you should use the app_commands package of discord.py. it also handles registering the app commands at discord

https://discordpy.readthedocs.io/en/stable/interactions/api.html#application-commands

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related