#Slash commands are not displayed

1 messages · Page 1 of 1 (latest)

crimson ocean
#

Hey,
I have problems with the regestration of the slash commands. I have done everything exactly as the instructions say. I also tried with and Guild restriction but it didn't work.
The bot already ran overnight but nothing was regestrated.
This is what a version of the code looks like:

import discord
from discord import slash_command

intents = discord.Intents.default()
intents.members = True

bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@slash_command()  # Create a slash command
async def hello(ctx: discord.ApplicationContext):
    """Say hello to the bot"""  # The command description can be supplied as the docstring
    await ctx.respond(f"Hello {ctx.author}!")

bot.run('Token')

FYI, I don't get any errors

#

Pls Ping me at reply

odd oxide
crimson ocean
#

From the server or from the computer?

odd oxide
#

where you run the bot

crimson ocean
#

For testing locally and over the one night he was on the server.

#
pip freeze

Server:

aiohttp==3.8.4
aiosignal==1.3.1
async-timeout==4.0.2
attrs==22.2.0
charset-normalizer==3.1.0
frozenlist==1.3.3
idna==3.4
multidict==6.0.4
py-cord==2.4.1
typing-extensions==4.5.0
yarl==1.8.2
odd oxide
#

can you try the slash_command from discord.commands?

#

from discord.commands import slash_command

crimson ocean
#

What do you mean by that?

odd oxide
#

you have from discord import slash_command

crimson ocean
#

Yeah?

odd oxide
#

can you try it with discord.commands

crimson ocean
#

k

#

Wait

odd oxide
#

Discord can also be weird sometimes

crimson ocean
#

Like that?

import discord
from discord.commands import slash_command

intents = discord.Intents.default()
intents.members = True

bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@slash_command(guild_ids=[707931710980882484, 1093259424065400862])  # Create a slash command
async def hello(ctx: discord.ApplicationContext):
    """Say hello to the bot"""  # The command description can be supplied as the docstring
    await ctx.respond(f"Hello {ctx.author}!")

bot.run('Token')
odd oxide
#

yes

crimson ocean
#

Doesn't seem to work either

#

The command is not displayed

odd oxide
#

what is the permission of the bot?

crimson ocean
#

Administrator

trim frigate
#

for commands in the main file, you use @bot.slash_command, not discord.slash_command

#

@crimson ocean

proud sigil
#

Use this instead @odd oxide

import discord
from discord.ext import commands

intents = discord.Intents.all()


bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@bot.command(name=“hello”, description=“Say hello to the bot”) 
async def hello(ctx: discord.ApplicationContext):
    await ctx.respond(f"Hello {ctx.author}!")

bot.run('Token')
trim frigate
proud sigil
trim frigate
crimson ocean
#

So

#

wait

proud sigil
crimson ocean
#

It worked

#

What was wrong?

crimson ocean
#

I had used the examples from the documentation as well as from github.

proud sigil
#

Idk, when I started programming I felt in these things:>

trim frigate
#

Because if that was the example, it is incorrect.

crimson ocean
trim frigate
#

for me is says it uses @bot.slash_command

crimson ocean
#

Didn't work

trim frigate
#

perhaps you combined two examples?

crimson ocean
#

Wait, I'll test it

#

Hm

trim frigate
#

they all say @bot.slash_command() for me.

crimson ocean
#

And that hadn't worked, I'll look up the old code for a moment

#

Here it is:

import discord

intents = discord.Intents.default()
intents.members = True

bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@bot.slash_command(guild_ids=[707931710980882484])  # Create a slash command
async def hello(ctx: discord.ApplicationContext):
    """Say hello to the bot"""  # The command description can be supplied as the docstring
    await ctx.respond(f"Hello {ctx.author}!")

bot.run('TOKEN')
trim frigate
crimson ocean
#

I did, it could be that it was because discord.py was installed at the same time.

proud sigil
#

Uninstall discord/discord.py

#

Then install py-cord

crimson ocean
#

i did

#

Well, thank you very much. You have relieved me of my confusion.

trim frigate
#

.solved

gusty breachBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @frigid anvil.