#How to create a bot that can use / commands
1 messages · Page 1 of 1 (latest)
do you mean slash commands?
yes
If you know, please help me write a demo code for me to review
Here's the slash basic example.
https://www.youtube.com/watch?v=Geoos96ht6Y&t=321s
Can you help me use slash command like in this video?
that is discord.py and not py-cord
I followed but it doesn't work and no errors appear
so can you help me? 😦
can you show your pip list pls
you have discord.py installed
this library is py-cord
So either you installed the wrong library or you're in the wrong discord, your choice
When I followed the video and ran the bot, no errors occurred
.
So which one should I use? discord.py or pycord
you choose
from this discord you will only receive biased answers most likely
but imo the slash command syntax is a lot more simple in pycord
What about the features and operating speed of these two libraries?
I haven't used discord.py since years, so idk
but slash commands just seem more logical here
no Bot class?
I deleted it
and what did you install instead, the packagename?
and in the example you gave did 'import discord'
pycord
kind of a name conflict with an existing package when pycord was made
yea because that's how py-cord is imported
Do I need to do anything else?
not really
I can't find the intents value in the Bot class 😦
because it's not in the bot class
it's discord.Intents
Excited to create your first bot? Once you install Pycord, you can start right
How can a bot send messages that only the person using the command can see?
bot = discord.Bot()
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
@bot.slash_command(name='hello')
async def hello(ctx):
await ctx.respond('Hey')
bot.run()```
Can you help me edit?
add this in the response
Can you tell me why when I write "ephemeral" vscode doesn't suggest the code for me as usual. Even when I type "respond" it's the same
because it's a kwarg
the IDE can't really know what that function takes for kwargs
read the docs, always, it helps a lot
So there's no way for vscode to suggest those codes?
you have to "type-hint" discord.ApplicationContext or vsc doesn't know what type ctx is.
or more formally, intellisense
Can you show me an example?
oh right the kwargs are also documented in the code right? ide readably?
@bot.slash_command(name='hello')
async def hello(ctx: discord.ApplicationContext):
await ctx.respond('Hey')
no, just the respond part
async def hello(ctx: discord.ApplicationContext):
await ctx.respond('Hey', ephemeral=True)```
oh, but it still cannot suggest "ephemeral"
yea, because of what i said about kwargs
a that you meant
for stuff like that (kwargs aka keyword arguments) you need to read the docs
Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord. Features: Modern Pythonic API using async/ await syntax, Sane rate limit handling that prevents 429s, Command...
technically, it's not entirely true, but whatever I don't want to explain it
ik
Is there any utility on vscode that can suggest code when I write a piece of code too many times?
ideally, you should notice that and make that bit of code its own function
Is this a feature of a utility?
what
i dont think you have copilot
no, it's just copilot
but copilot is paid?
it's clearly the video
oh i thought they sent their own screen lmao
you can even see copilot
also, that is discord.py
do not watch that video
i know
but yea thats copilot and costs money
And i think you should learn programming yourself first before using AI
I learned programming before, I quit in October 2023 and I'm very bad at finding reference materials to learn more about python
as i said, youtube and the internet in general are FULL of it
w3schools, geeks4geeks, etc.
but about discord bot I couldn't find any perfect documentation
everything is half-hearted
Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord. Features: Modern Pythonic API using async/ await syntax, Sane rate limit handling that prevents 429s, Command...
and for the start especially, https://guide.pycord.dev/introduction
Pycord Guide is a complete guide for Pycord. Learn how to create Discord Bots today!
And I also want to thank you, thank you for helping me for nearly 2 hours. Thank you very much.