Interaction handlers in the command instead of globally
Honestly. I would much rather add interactions from my command and from there tell to continue in (for example) a different function within that command class than have to handle the interaction in a certain "listener" and keep a state of whats what before the interaction.
vladdy•970d ago
Interesting.. thats a different mentality than what I have with them. In a bot I just finished writing for someone, the handler for buttons is a listener (bc no native support yet) and it processes the ID and does the action. Now, of course, this is 1 id, but a collector is not something you can easily revive, a listener-replica is!
Now, registering a button in the command class..gets too messy too fast
what if you send components in an event
what if you send components in a task
𝖄𝖚𝖌𝖊𝖓•970d ago
You could tell by sending it what should be triggered by it
Not just commands
vladdy•970d ago
You can't tho
Buttons in channel.send are dumb
all they store is an id, a name, optional emoji, and a style
and a type for link/non-link
Elliot•970d ago
where else would they be?
𝖄𝖚𝖌𝖊𝖓•970d ago
All you need is the id to achieve what I said tho
vladdy•970d ago
Dumb as in they don't have a connection to something
𝖄𝖚𝖌𝖊𝖓•970d ago
By the id and the listener you could determine what has been stored to be triggered
vladdy•970d ago
Wait, what exactly are you asking for? I'm confused
Elliot•970d ago
ah ok, then it relates to my #2 : i only use them in-place (with collectors), so i don't have this problem
vladdy•970d ago
The thing is, collectors aren't saved
if your bot restarts mid collecting, thats you loosing god knows how many interactions
You should build out your listeners in an abstract way, EXCEPT MAYBE for a one-time confirmation message
Elliot•970d ago
The thing is, collectors aren't savedthat's true but the only time i've used them was for a quick prompt in a command, so i didn't really care if the bot restarted (and there was really a very low chance of it restarting in this time)
vladdy•970d ago
Sure, but you gotta consider long lasting buttons too
Example: reaction roles, our clicky to agree, etc
Elliot•970d ago
yep didn't thought of it, only though of my use cases
vladdy•970d ago
👍
Elliot•970d ago
so ig it would make sense
vladdy•970d ago
Nothing forces you to use our handlers for your use case, but i am trying to collect a bigger picture to see what would be the ideal solution
𝖄𝖚𝖌𝖊𝖓•970d ago
That goes for normal messages too
message.addButton(() => this.buttonClicked())
Very rough example
Id is generated. Callback is stored somewhere. Untill timeoutvladdy•970d ago
Not happening, we cannot extend structures and that is an EXTREMELY LIMITING API
𝖄𝖚𝖌𝖊𝖓•970d ago
Extending was not intention
And yes. Its limiting in one way. But you're excegarating it's limitness
I am on my phone mind you
vladdy•970d ago
Yugen, it's not revivable after a reboot
𝖄𝖚𝖌𝖊𝖓•970d ago
Bruh
Its never reviveable unless you keep state
Or save it in a db or w/e
vladdy•970d ago
Thats on the user side, and it beats the point of a lot of these stateless things it is! You always get an event when you click a button
a global listener will always fire
𝖄𝖚𝖌𝖊𝖓•970d ago
This for example is never gonna be saved after a reboot since you have 0 context but an id
vladdy•970d ago
an awaitMessageComponent won't
𝖄𝖚𝖌𝖊𝖓•970d ago
And then what
You dont know what for
vladdy•970d ago
You've never used buttons clearly
Which is fine
don't blame you
the custom id can give you a hint, you also get the full message object
so you have a LOT of info already
𝖄𝖚𝖌𝖊𝖓•970d ago
And then I'll have to figure out from that event what to continue on
Thats basically as much work as just creating a custom listener for it anyways
vladdy•970d ago
Not really?
I don't get what you're trying to reach at
𝖄𝖚𝖌𝖊𝖓•970d ago
And I don't think I can explain it well enough from my phone
Ill continue this tomorrow morning
vladdy•970d ago
You can explain it tomorrow
𝖄𝖚𝖌𝖊𝖓•970d ago
Yeh
vladdy•970d ago
There's no rush with this
𝖄𝖚𝖌𝖊𝖓•970d ago
Off to bed xoxo
Good night
vladdy•970d ago
i wanna get it right in 1 shot
nini
Welcome to the Sapphire Discord server! The next-gen object-oriented Discord.js bot framework can be found here.
2.2KMembers
View on DiscordWant results from more Discord servers?
More Posts