Cannot find how I can use buttons
I want to create a message with some buttons for people to click on and recieve some messages something like what it is in the attached image.
What I cannot figure out is how do I use it. I tried to read the documentation and I'm pretty sure im missing a big gotcha
https://sapphirejs.dev/docs/Guide/interaction-handlers/buttons
Sapphire Framework
Buttons | Sapphire
Buttons are components that are clickable. You will recieve an interaction for every click of a button! Here's an
17 Replies
I understand that it will be a component of a message reply, I just dont get how the syntax goes, the documentation is also doesnt show it
buttons are part of interaction handlers: https://sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they
Sapphire Framework
What are they? | Sapphire
These are interaction handlers! A simple class you can extend to handle almost all the interactions you may receive in
im still struggling to figure out how I can get a button to be with a message as a reply
😠😠😠😠😠😠ðŸ˜
maybe check out some of the other open source bots
Discord Bots using @sapphire/framework
v5.x
- Gemboard á´± á´°
- Skyra á´± á´¬ á´°
- Dragonite á´± á´°
- Archangel á´± á´°
- Official Bot Examples ᴱ ᴰ ᴶˢ
- KBot á´± á´¬ á´°
- Perpetual Mechanical Array á´°
v4.x
- Radon á´± á´¬
- Sapphire Application Commands Examples á´±
- Zeyr á´° á´¬
- Birthdayy á´°
- RTByte á´± á´¬
Legend for the identifiers
á´±: Uses ESM (if not specified then uses CJS)
á´¬: Advanced bot (if not specified it is a simple bot, or not graded)
á´°: Uses Docker in production
ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
oo free freference
they are all typescript 😠and I still dont get how the interaction handler works for this situation
typescript just just javascript with types. When you remove the
: type
syntax from everything it's just javascript.1. Create a button component through the discordjs code for that
2. assign a custom id
3. add an interaction handler file
4. in the parse method check the custom id, return
this.none()
if it doesnt match and this.some()
if it does
5. Create a the run method, now ensured to be a click of the desired button
6. Process the interaction
Steps 1, 2, and 6 are all pure DiscordJS. Refer to https://discordjs.guide and https://discord.js.org for their guide and documentation respectively. This is also not something we can help with because it all comes down to what you want the button to do.discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
okay this is so helpful
i will go through this now
I just wanted a reply to one of my commands to have a button and for starters the button on click can get the bot to say hi
you reacted with sad here but let me give you an example and you'll start to understand it's really not that hard to mentally convert it. You'll be much much better of if you do learn it.
typescript
:
javascript
:
(or preferebly javascript
with doc comments so it's still has type information in your editor):
oh no 😠is like the laughing in pain kind of thing
ive worked with js a lot before so ive checked out ts but its just taht im super new to discord bot and this framework is very new to me too
reminds me of type declaration in pyton even though it diesnt affect ðŸ˜
i dont get it :c
isnt there a simpler dirty hack where i can just write a button inside the reply??
something like this
You can use component collector if you wanna use classic approach
https://discordjs.guide/popular-topics/collectors.html#interaction-collectors
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
What exactly you can't figure out with sapphire approach with
interaction-handlers
directory?i figured this out a while back so thanks 😀
is there any way for my bot to use a carlbot or a dyno bot command and not get ignored?
like the carlbot/dynobot should react to prefix commands from my bot
cant figure that out
i dont think that this is possible
no workaround? i really dont want to implement temproles by myseld
if theres any workaround or alternative bot or ANYTHING ðŸ˜ðŸ˜ðŸ˜
No, bots cannot trigger commands of other bots
You never want bots to be able to talk to one another lest you create an infinite loop