19 Replies
This isn't as simple a question as you think
What are you trying to do?
I want to make an authorization system; when the bot starts, I need to send a message with a button to a certain channel and when the button is clicked, open a modal window.
I'm thinking about rebooting, but I'm not sure if I can connect to an existing message (Buttons)
In the modal window you will need to enter the game nickname, after confirmation I will add the received data to the database
OK, you need a button-based authorisation system, do you know what the channel type, ID and guild are ahead of time?
ye, it`s my guild
I will make config for settings
I'd recommend using a command instead of sending a message on every startup
but if you really can't get away from that, you could use the GuildCreateEvent or maybe the ReadyEvent if you don't need anything in your cache
I thought about this, but most likely we will have an automatic nightly reboot and the modal window will fall off (
That shouldn't be a problem
Okay, thanks a lot for your help
Create your button using
actionRow {}
instead of components {}
Solution
then listen for the
ButtonInteractionCreateEvent
you can do the same thing for modals (
ModalSubmitInteractionCreateEvent
)Will it work after reboot?
yep
tysm
the main thing to bear in mind is the
customId
you give the buttonokay
you can match against that in your event handler
again, same thing for modals
:pepe: Okay, i will try it
Alright, glad to have helped haha
oh, and if it helps, I wrote a bot recently that basically does exactly this
that code is here, though do note the license https://github.com/cmc-discord/bot-invites-kotlin/blob/root/src/main/kotlin/wiki/moderation/bot/invites/extensions/InviteExtension.kt