contextMenuCommandDenied question
any way of getting the user who ran the context menu when the
contextMenuCommandDenied
listener is triggered?Solution:Jump to solution
That is not the valid parameters for the listener. The types are
error: Error, payload: ContextMenuCommandDeniedPayload
So to get the interaction you then do payload.interaction
and the guild therefore is payload.interaction.guild
When programming it is always important to adhere to the parameter order and parameter types when writing and using functions. You should always consult documentation, and if working with a library like discordjs or framework like sapphire you’d also do well to refer to the source code, which gets linked for every symbol in the documentation....10 Replies
Every precondition gets 2 parameters, the error (type UserError) and the payload, which is a variable type but in this case ContextMenuCommandDeniedPayload. As you can see it has the interaction which means you can do interaction.user
sorry didn't understand
understand what exactly. I really cannot explain it in another way. You have a listener, its
run
method has 2 parameters, and those are of the aforementioned types.ah ok, last question, do you know how to access the guild from that interaction? I tried stuff like
i.interaction.commandGuildId
or i.interaction.guildId
but both return TypeError: Cannot read properties of undefined (reading 'interaction')
If
i
is the interaction then it's i.guild
already tried with that, it returned
TypeError: Cannot read properties of undefined (reading 'guild')
What is
i
Please send your full codePastebin
contextMenuCommandDenied - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Solution
That is not the valid parameters for the listener. The types are
error: Error, payload: ContextMenuCommandDeniedPayload
So to get the interaction you then do payload.interaction
and the guild therefore is payload.interaction.guild
When programming it is always important to adhere to the parameter order and parameter types when writing and using functions. You should always consult documentation, and if working with a library like discordjs or framework like sapphire you’d also do well to refer to the source code, which gets linked for every symbol in the documentation.@🠷Carlos👑