#๐ Error @bot.slash_command
325 messages ยท Page 1 of 1 (latest)
@marsh briar
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.
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
what lib are you using
i mean
disnake or discord.py
bro
alr
well not really bc i cant write on console:P
alr
lemme check version maybe
make os.system on start
of python on this site
wdym
os.system("pip install -U discord.py")
in your code
dont forget import os
good?
@heady wigeon still noching
thats wreid bc on my pc is working
slash_command is not a thing in discord.py
your pc must have some kind of discord.py forks then
uhhhh
so how create this? i just want to /creator
and just response
its possible to do this?
(this new slash commands rly confisuing me)
discord.py official example for slash commands/context menus
right click on your server name and click copy server id
oooh alr
also you should unisntall all the forks because they might have problems with discord.py because they use the same namespace discord
how to uninstall?-
o my g o d
i HATE errors
show me the pip freeze output
on cmd pip freeze ?
yes
py -m pip uninstall discord discord-py-slash-command py-cord
and then py -m pip install -U discord.py
i writed that
then
i got alot of red error
a lot of it
mb ill try again?
ehh, do py -m pip install discord.py --force-reinstall
alr
i forgor pip
Can you send the last part of the error that's usually is the part where they tell the issues
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
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
yeee
so now my pyhton its okey?
i mean discord.py
or sm
i suggest stick to the official documentations and examples
i mean why we did this tbh
if you have any error or you don't understand, you can ask here or discord.py discord server
that is when i told you to update discord.py, but seems like pip has soem problems updating it, so i told you to do force reinstall instead
i dont really understand
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
Nvm i fixed it.
but on_command_error not taking it either ๐ง
wydm
;w;
well
now
i need to create this ./ command can u help me do it?
in discord.py there are discord.ext.commands.Context for prefix command and discord.Interaction for slash command
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
bot.command create a prefix command
read line 41 to 65 in the example, they covered some type of slash commands
but this bot.tree.command() dont working for me
bot is a Client instance
oh-
so i can attach the tree to client ?
Bot has a tree by default, while Client ain't
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.
ghost ping moment
I recommend py-cord it's easier to create application commands in that library and use the @slash_command decorator
Im using py-cord.
But its not working on my Site where i want put code.
This is Discord.py
You can't have discord.py and py-cord together because it causes conflicts
Can you show me your pip list?
fine
and on my PC its working fine my code, but on site dont working tbh
Uninstall Discord.py
And also py-cord and then reinstall py-cord again
pip uninstall discord.py
right?
pip uninstall discord.py py-cord
alr
Restart your code editor
tbh
Now install py-cord again
but discord.py is not uninstaled
ig
its error
on cmd
'pip' is not recognized as an internal or external command, operable program or batch file.
Use VSC
Try
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
Ok now look at your pip list
Done now try to create the command
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
Can you add a print inside the function and see if it executes?
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)
?
Yeah
Can I see how you have the Bot object defined?
ig u mean this
Are you using prefixed commands?
If you don't need prefixed commands just use discord.Bot()
like
there or sm?
or wdym
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
i got warning
or i can leave alone bot_prefix in my code?
That has nothing to do with the library, it's a syntax error.
;w;
idk
or should i delete this prefix just
Have you tried restarting Discord and the editor?
emmm
no ig
bro
i just kicked bot
and added him again
and it worked
bruh?
crazy
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
Probably conflicts between libraries
And Python still doesn't recognize the changes
Do you use a VPS?
Do you know what system it is?
maybe bc i uninstaled discord.py and installed py-cord?
From that console look at your pip list
Can you reboot?
Ok, so after uninstalling both libraries reboot
Hmmmm I don't know how the site you use works, it's probably a bug because it does work on your computer
i can use VPS to put bot on 24/7h online?
Yes, services like GalaxyGate or Digitial Ocean offer VPS at a good price
well i dont rly have money rn
If you want your bot to be always online and stable you need to pay, free services often cause problems
!hostig
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.
@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
To catch application command errors you need this event:
discord.on_application_command_error()
And if you want to catch errors from prefixed commands use this event:
discord.ext.commands.on_command_error()
its application context
i mean this error its on site panel console so i dont rly know that will help
I don't mean that, I mean that you are using ApplicationContext in the wrong event ๐
Ooooh..
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
what are you trying to do? show me this part of the code
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
I didn't understand, do you want the bot to send a message when someone writes something on a forum?
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
i can show u on VC
we dont must need to talk
on #751592231726481530 i can just live stream or sm
I can't and I also recommend you see the documentation, there are thread events.
This section outlines the different types of events listened by Client. There are 3 ways to register an event, the first way is through the use of Client.event(). The second way is through subclass...
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.