Context Menu not working
I was changing a command so both the message and context menu version of the command were in the same file, however the context menu part doesn't work, and instead returns the "The application did not respond" error. The message version of the command works fine.
Relevant Code: https://pastebin.com/Ciqk03at
Pastebin
Command - 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.
17 Replies
for starters, you have
options
twice at the top which will cause the file to not load as a JavaScript error will be thrown at init. Your console should be showing you that error...
Other than that, since you didn't specify your imports, make sure you define those correctly
that was just an example, there are actual options on the full command, the imports are also there in the full command
i ran the command while having the code inside a try catch and no errors were returned
Send the actual code then. Rule of thumb is if you want to be helped you have to provide all possible information. Or better yet, review how to ask technical questions. Prime among them, strive to never run into a situation where the person trying to help has to ask you to provide more information.
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stack traces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
- For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines.
- For an excellent video that shows how not to ask technical questions, watch this YouTube video by LiveOverflow.
- Asking technical questions (Clarkson)
- How to ask questions the smart way (Raymond)
alright, I updated the bin: https://pastebin.com/Ciqk03at
Pastebin
Command - 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.
not sure if this helps but I have a similar file where the 2 versions of the command (message and slash) are in the same file and they work correctly
just realized something, on the command i'm having problems with I added a precondition that doesn't support contextMenuRun, would that be the issue?
looks like that wasn't the issue
just realized having the 2 versions of a command in the same file would interfere with the preconditions, since the slash and message versions of the command have different ones, is there any way of fixing this, for example setting different preconfitions for each version of the command even if they are on the same file?
no
would adding a
if()
on the precondition to check if it's a context menu interaction work?Solution
Add a contextMenuRun to the precontion that always returns this.ok()
doing this also removed the error I was getting, ty
sorry for re-opening this post, but is it possible to have 2 context menu commands in 1 file (while also having a message command in the same file, so basically 1 message command and 2 context menu commands in one file)
No. Assuming you want this for user and message based, you handle that with an if statement in the contextMenuRun. Form there you can do whatever you want, such as calling another function.
I wasn't talking about preconditions
basically in the file I have a
warnings
message command, where you can add a flag to view automod warnings instead of manual ones, in the same file I had a Warnings
context menu which lets you view only manual warns, I wanted to see if it was possible to have a third command in the same file, this one would be a Autowarnings
context menu commandThat it is not. That's a separate command.
so I would need to put the
Autowarnings
context menu is a different file?Yes
alright ty