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 toolkit3w 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 docs3w ago
:event: (event) Client#messageDelete [email protected] Emitted whenever a message is deleted.
TÆMBØ
TÆMBØ3w ago
The docs will show what type is used for each parameter in each event
なるこです☄
thanks
TÆMBØ
TÆMBØ3w 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
なるこです☄
Like this?
No description
Amgelo
Amgelo3w ago
that'll give you an array, not just the first parameter so either parameters: ..., or [message, ...]: ... (destructuring)
なるこです☄
Oh...got it

Did you find this page helpful?