what would be the best way to implement reusable components inside my discord bot? currently, every one of my responses to commands are containers, and even just a simple container with an accent color and text display requires alot of boilerplate. im thinking of maybe creating functions that are like reusable where its a container with a text display and i just pass it an accent color and text content but im not sure if this the best way. should i be using functions, class methods or something else? not really sure.
#reusable components
26 messages · Page 1 of 1 (latest)
"best" is really subjective tbh, to oop or to not oop is also a big debate
from my personal opinion, oop but without static methods, those can be individual functions
can include them in their own object to simulate a namespace
youre talking about a class that would have methods that would just be functions?
but you're pretty much free to what you want, as long as you're consistent with your rules
alright alright
any static method in general, but that's just my opinion, and even then I've sometimes not followed it myself 
ty for the info
you can check out how I've been doing it and take some inspiration if you like it
#1394605443816357999 message
i took a look and it looks pretty nice. but i feel like its too much when it comes to responses since those deal with components more
like for example my concept is ill have a bunch of wrappers that are just functions
so ill have a function that takes in content and an optional colorresolvable that just returns a container with said content and color
and i can have a makeEphemeral function wrap around it if it needs to be ephemeral
id probably use similar implementation like you when it comes to full on buttons/modals/menus etc
Hmm. Ofc. It should always depend on what gives you the best DX while doing the best job
finding that middle ground takes a lot of trial and error
decorator design pattern 
if the stuff you're doing with said components is simple, like just adding text or changing the color etc, it would make sense to make do with something simple as well.
hm i actually didnt think about decorators
i was just talking about like
makeEphemeral(createSimpleResponse('example components v2', 'Red')
but now that you mention it, i could havve a decorator like
@Ephemeral over anything i want ephemeral
ill need to learn how to make them since ive never used or made one before lol
No no. What i mean is that what you’re doing is the decorator design pattern anyway
@ is just syntactic sugar languages use