ThatSameer
DIAdiscord.js - Imagine an app
•Created by ThatSameer on 3/4/2024 in #djs-questions
Correct 'type' for Interaction Object?
Hi, I'm trying to find the correct type/interface for the Interaction object which is sent by Discord to my endpoint using the types found in the DiscordJS library.
I'm not sure if this is the correct one but I'm trying with
APIInteraction
from discord.js and can kind of scope the interface to give somewhat correct typing depending if it's an application command or message component like this:
With this, the "somewhat" correct typing for interaction.data.
show up depending on the if scope.
The issue I'm having right now is getting the application command if statement recognising that the interaction object may be one with an options
field, used for subcommand interactions.
Is there anything I can do to scope the APIInteraction
type to recognise the options
field in application commands or do I need to readdress this approach with other typings (if so which typings)?
Thanks!8 replies
DIAdiscord.js - Imagine an app
•Created by ThatSameer on 2/29/2024 in #djs-questions
Patch webhook type, ActionRowBuilder issue
Hi,
I am using the Discord API to patch webhook message using he help of DiscordJS to create components. I'm trying to find and use the correct typescript type/interface for the JSON/Form params of my axios patch message.
I am trying with
RESTPatchAPIInteractionFollowupJSONBody
however when using the component param in the patch message, I get a ts error even though I am assigning the generic type to ActionRowBuilder:
The code:
The axios function:
Not sure where to go from here...6 replies
DIAdiscord.js - Imagine an app
•Created by ThatSameer on 9/8/2022 in #djs-questions
Get my bots webhook ID and Token on ready
Hi,
Long story short - I accidentally deleted my database so I have lost webhook details of a few servers. I was wondering if I could add something into my ready event to regain my existing webhooks for my bot.
My ideal one off solution would be on ready, to go get webhooks of guilds the bot is in, filter to my bot only, and then grab the ID and Token from it to write to my DB.
I'm thinking of going down the await client.guilds.cache but honestly I haven't done Discord dev work in a while so I don't really know.
Thanks.
9 replies