#๐Ÿ”’ Error @bot.slash_command

325 messages ยท Page 1 of 1 (latest)

marsh briar
#

.

gray needleBOT
#

@marsh briar

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

marsh briar
#

code:

@bot.slash_command(name="creator", description="Creator of bot")
async def test(ctx: discord.ApplicationContext):
    await ctx.respond("โค๏ธ Creator of bot is: Astlinka", ephemeral=True)

error : screenshot

heady wigeon
#

what lib are you using

marsh briar
#

i mean

heady wigeon
marsh briar
#

its puted on site

#

on my PC console its working perfect

#

on site not really

heady wigeon
marsh briar
heady wigeon
#

so

marsh briar
#

alr

marsh briar
heady wigeon
#

alr

marsh briar
#

lemme check version maybe

heady wigeon
#

make os.system on start

marsh briar
#

of python on this site

marsh briar
heady wigeon
marsh briar
#

on site?

#

or on my cmd

heady wigeon
#

in your code

marsh briar
#

ooh

#

Alr

heady wigeon
#

dont forget import os

marsh briar
#

good?

marsh briar
#

@heady wigeon still noching

#

thats wreid bc on my pc is working

shrewd pecan
#

your pc must have some kind of discord.py forks then

marsh briar
#

uhhhh

marsh briar
#

its possible to do this?

#

(this new slash commands rly confisuing me)

shrewd pecan
marsh briar
#

btw where i can find my GUILD ID ?

#

ooh

#

server id ?

shrewd pecan
#

right click on your server name and click copy server id

marsh briar
#

oooh alr

shrewd pecan
#

also you should unisntall all the forks because they might have problems with discord.py because they use the same namespace discord

marsh briar
#

o my g o d

i HATE errors

shrewd pecan
#

show me the pip freeze output

marsh briar
shrewd pecan
#

yes

marsh briar
#

uhm/

shrewd pecan
#

try py -m pip freeze

#

cuz youre not adding python to path

marsh briar
#

o.O

shrewd pecan
#

py -m pip uninstall discord discord-py-slash-command py-cord

#

and then py -m pip install -U discord.py

marsh briar
#

i writed that

marsh briar
#

i got alot of red error

#

a lot of it

#

mb ill try again?

shrewd pecan
#

ehh, do py -m pip install discord.py --force-reinstall

marsh briar
#

alr

shrewd pecan
#

i forgor pip

marsh briar
#

OOH

#

alr

idle zealot
# marsh briar

Can you send the last part of the error that's usually is the part where they tell the issues

marsh briar
#

Done.

shrewd pecan
#

sure, now do py -m pip freeze again to make sure there's no forks left

and maybe it's time to migrate codes that use in both library to discord.py

marsh briar
#

alr

#

there you are

shrewd pecan
#

discord.py has been updated a lot, so if you follow the tutorial, them "coder youtubers" might use very much forks and library that has feature that already been updated on discord.py

marsh briar
#

so now my pyhton its okey?

#

or sm

shrewd pecan
marsh briar
shrewd pecan
#

if you have any error or you don't understand, you can ask here or discord.py discord server

marsh briar
#

yeaj

#

yeah

shrewd pecan
marsh briar
#

oh

#

alr!

#

ill try do slash command gimme sec

marsh briar
#

i mean my code

#

i mean

#

i dont know how to ADD this to my code tbh

#

but ill try gimme 2 sec

#

@shrewd pecan i have quesstion

#

why tf this not working

#

on my console

#

or someone

shrewd pecan
#

not ApplicationContext

marsh briar
#

Nvm i fixed it.

shrewd pecan
#

but on_command_error not taking it either ๐Ÿง

marsh briar
#

;w;

#

well

#

now

#

i need to create this ./ command can u help me do it?

shrewd pecan
#

in discord.py there are discord.ext.commands.Context for prefix command and discord.Interaction for slash command

marsh briar
#

yeah yk

#

i want from this

@bot.command(name="creator", with_app_command=True, description="Creator of bot")
async def test(ctx: commands.Context):
    await ctx.defer(ephemeral=True)
    await ctx.reply("โค๏ธ ***Creator of bot is: Astlinka***")

do slash command ik its normal channel commad but idk how to rly do it

shrewd pecan
#

bot.command create a prefix command

#

read line 41 to 65 in the example, they covered some type of slash commands

marsh briar
shrewd pecan
#

because you probably declare bot as Client

#

and Client has no tree

marsh briar
#

no.

#

Im declaring as bot

shrewd pecan
#

bot is a Client instance

marsh briar
#

oh-

shrewd pecan
#

so it has no tree

#

the example did something to attach the tree to Client the tree

marsh briar
shrewd pecan
#

Bot has a tree by default, while Client ain't

marsh briar
#

so why i cant do @bot.slash_command :P

#

i mean i need to like this?

@bot.tree.command(name='creator', description="Creator of bot")
async def creator_slash_command(interaction: discord.Interaction):
    # Reply to the user with bot creator info
    await interaction.response.send_message("โค๏ธ ***Creator of bot is: Astlinka***")

? or sm?

#

or i dont understand

#

nvm i cant

#

can u just show me how to do this slash command, its not rly hard to show ig?

#

or sm.

marsh briar
#

ghost ping moment

meager sedge
marsh briar
#

But its not working on my Site where i want put code.

meager sedge
#

You can't have discord.py and py-cord together because it causes conflicts

marsh briar
#

i got only py-cord

#

ill show you my error

#

but its on my site console

#

:P

meager sedge
marsh briar
#

fine

marsh briar
#

and on my PC its working fine my code, but on site dont working tbh

meager sedge
#

You can't have both

marsh briar
#

ill show u all my code

#

and tell me with one i need to delete

#

oke?

meager sedge
marsh briar
#

umm can u tell me command for it?

#

;w;

meager sedge
#

And also py-cord and then reinstall py-cord again

marsh briar
#

right?

meager sedge
marsh briar
#

alr

meager sedge
marsh briar
meager sedge
#

Now install py-cord again

marsh briar
#

ig

#

its error

#

on cmd

#

'pip' is not recognized as an internal or external command, operable program or batch file.

meager sedge
#

Use VSC

marsh briar
#

py -m pip uninstall py-cord discord.py
??

meager sedge
#

Try

marsh briar
#

i uninstalled

#

this 2

#

now ill instal py-cord with this command pip install -U py-cord

#

nvm

#

this * py -m pip install -U py-cord

#

@meager sedge

#

done

meager sedge
#

Ok now look at your pip list

marsh briar
meager sedge
#

Done now try to create the command

marsh briar
#

okey soo

#

i created this :

#
@bot.slash_command(name="creator", description="Creator of bot")
async def test(ctx: discord.ApplicationContext):
    await ctx.respond("โค๏ธ Creator of bot is: Astlinka", ephemeral=True)
#

and ill got this

meager sedge
#

Can you add a print inside the function and see if it executes?

marsh briar
#

you mean like that?

#
@bot.slash_command(name="creator", description="Creator of bot")
async def test(ctx: discord.ApplicationContext):
    print("The /creator command was executed.")  # This will print when the command is run
    await ctx.respond("โค๏ธ Creator of bot is: Astlinka", ephemeral=True)

?

meager sedge
#

Yeah

marsh briar
#

alr ill try gimme sec

#

noching again

#

oooh mb ik why

#

gimme sec

#

nvm

meager sedge
#

Can I see how you have the Bot object defined?

marsh briar
#

ig u mean this

meager sedge
#

Are you using prefixed commands?

marsh briar
#

uhhh

#

notrly

#

i dont using prefixed commad but i have 1 (im not using it so)

meager sedge
#

If you don't need prefixed commands just use discord.Bot()

marsh briar
#

only this but i can delete this

#

oops too more;w;

marsh briar
#

there or sm?

#

or wdym

meager sedge
marsh briar
#

oh.

#

right

marsh briar
#

or i can leave alone bot_prefix in my code?

meager sedge
#

That has nothing to do with the library, it's a syntax error.

marsh briar
#

oh

#

alr

#

alr

#

lemme try now

marsh briar
#

idk

#

or should i delete this prefix just

meager sedge
#

Have you tried restarting Discord and the editor?

marsh briar
#

emmm

#

no ig

#

bro

#

i just kicked bot

#

and added him again

#

and it worked

#

bruh?

#

crazy

meager sedge
#

Lol

#

Very strange

marsh briar
#

real

#

lemme check

#

it it will work on my site

#

well

#

ill add this to uninstall discord.py and install py-cord

#

idk why on site this this wreid error @meager sedge

meager sedge
#

Probably conflicts between libraries

#

And Python still doesn't recognize the changes

marsh briar
#

uh

#

its there solution to do this?

meager sedge
#

Uninstall py-cord

#

And look at your pip list

marsh briar
#

i mean

#

its not

#

my Console

#

its site console

meager sedge
#

Do you use a VPS?

marsh briar
#

why?

meager sedge
#

Do you know what system it is?

marsh briar
meager sedge
#

From that console look at your pip list

marsh briar
#

i cant tbh

#

thats dumb console ngl

meager sedge
#

Can you reboot?

marsh briar
#

yeah

meager sedge
#

Ok, so after uninstalling both libraries reboot

marsh briar
#

1 sec

#

@meager sedge :P

meager sedge
#

Hmmmm I don't know how the site you use works, it's probably a bug because it does work on your computer

marsh briar
#

oh

#

ye

#

well

#

i need another host/site right?

meager sedge
#

I recommend a VPS

#

You have total control

marsh briar
#

i can use VPS to put bot on 24/7h online?

meager sedge
marsh briar
meager sedge
#

If you want your bot to be always online and stable you need to pay, free services often cause problems

#

!hostig

gray needleBOT
#
Discord Bot Hosting

Using free hosting options like repl.it or Heroku for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.

See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.

You may also use #965291480992321536 to discuss different discord bot hosting options.

marsh briar
#

@meager sedge yo

#

u can help me with last thing?

#
@bot.event
async def on_command_error(ctx: discord.ApplicationContext, error: discord.DiscordException):
    await ctx.reply(str(error), ephemeral=True)
#

idk where is there error thb'

#

i mean

#

ugh

#

never mind

#

i fixed it

meager sedge
meager sedge
marsh briar
#

i mean this error its on site panel console so i dont rly know that will help

meager sedge
marsh briar
#

well i have last problem

#

Bc on my pc, my ModMail is working

#

but on site-

#

i got little error but on my pc i dont have this problem tbh

meager sedge
marsh briar
#

and if u write in the channel forum, its supposted to write back as bot on dm like that

#

there is code :

#

em i cant send txt

#

ill sen u on DM code bc its too big

#

or ill SS u

#

all code

#

@meager sedge

#

of this modmail

meager sedge
marsh briar
#

watch

someone writing on dm bot>bot creating channel on forum>u writing on this channel on forum>bot sending what u writed

#

its working on my PC, but on this fuc**ng site no

marsh briar
#

we dont must need to talk

#

on #751592231726481530 i can just live stream or sm

meager sedge
gray needleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.