Ask about discord.js and typescript

I have an event handler call message-delete.ts Which type should I use when message is using as function args? Here's my code.
import { Events } from "discord.js"

const interaction = {
name: Events.MessageDelete,
async execute(message: which type should I set?) {
// my execution
},
}

export default interaction
import { Events } from "discord.js"

const interaction = {
name: Events.MessageDelete,
async execute(message: which type should I set?) {
// my execution
},
}

export default interaction
8 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs7mo ago
:event: (event) Client#messageDelete discord.js@14.19.3 Emitted whenever a message is deleted.
TÆMBØ
TÆMBØ7mo ago
The docs will show what type is used for each parameter in each event
星野みずき
星野みずきOP7mo ago
thanks
TÆMBØ
TÆMBØ7mo ago
Additionally, you can use the ClientEvents type exported by d.js which contains the parameter types for each event, so you can do something like ClientEvents[Events.MessageDelete] to get the parameter types for a given event
星野みずき
星野みずきOP7mo ago
Like this?
No description
Amgelo
Amgelo7mo ago
that'll give you an array, not just the first parameter so either parameters: ..., or [message, ...]: ... (destructuring)
星野みずき
星野みずきOP7mo ago
Oh...got it

Did you find this page helpful?