Discord slash command help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kitsune
Posts: 4
Joined: 13 Sep 2020, 20:54

Discord slash command help

Post by Kitsune » 28 Nov 2022, 12:34

Hello, I need a working AutoHotkey script to send Discord slash commands.

First of all, I have to mention that recently Discord changed something with slash commands, that made previously working scripts unusable.
Then, when You typed a command, let's call it /cmd, it was possible use space and write something afterwards. Not sure why it was crucial, but now You are unable to type space after a command and this broke my script.

Second thing, I don't get how {ENTER} works in AutoHotkey, because it's definitely not the same thing as pressing enter key, because then You had two press enter double time to send command, also when mentioning someone, hitting enter would autofill the name. AutoHotkey just ignored that and sent message automatically.
If it's not clear what I'm talking about, typing manually @User and then enter, would fill it as @Username, but with AutoHotkey, it just sent @User without autofilling. And the same goes for the slash commands, that has to be picked (first enter), then send (second enter), but AutoHotkey just directly send them.

And that's where's the problem. Because of the change in how commands work, instead of sending slash command /cmd, AutoHotkey send it as TEXT. And therefor my commands don't work.

Also I want to mention that if possible, I want to have one script with multiple hotkeys, as I do now. It looks something like this now: (but with more commands and obviously these ones are just examples)

Code: Select all

NumpadDiv::SendInput @Username
+NumpadDiv::SendInput /cmd {ENTER}
Now the question is. How I make the /cmd {ENTER} working again. And if possible, I would like to have username fill, but not send it. Because after hitting the hotkey I have to hit enter so it fills up as the username, then type something, instead of just hitting button to mention the user and type what I want to send it.

PS I am rather amateur, so please, don't assume I would understand something more advanced. I understand simple logic like NumpadDiv meaning that it's divide on Num keyboard and {ENTER} means enter (though, as I said, it doesn't behave like a enter I would press manually and I don't understand the reason.

Thanks in advance.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Discord slash command help

Post by mikeyww » 30 Nov 2022, 07:31

Hi,

I did not test this in Discord, but it sounds like-- if you can press a hotkey and see the text appear but not generate the response that you expected-- they may have introduced a new process to block this type of scripting. This may or may not help: viewtopic.php?f=7&t=11084.

Kitsune
Posts: 4
Joined: 13 Sep 2020, 20:54

Re: Discord slash command help

Post by Kitsune » 30 Nov 2022, 21:02

mikeyww wrote:
30 Nov 2022, 07:31
Hi,

I did not test this in Discord, but it sounds like-- if you can press a hotkey and see the text appear but not generate the response that you expected-- they may have introduced a new process to block this type of scripting. This may or may not help: viewtopic.php?f=7&t=11084.
To be honest it seems more like they just to try to limit commands to only write something the command ask for. That's why they forced every bot to have slash commands, instead of using different prefix. Because prefix couldn't be automated the way slash commands are now.
Also the only reason it doesn't work now is that You can't send a slash command with a space afterward. Back then I could just copy /cmd with a space at the end and paste it manually and it would work as a command. Right now even doing that isn't possible, because for some reason You can't have space after command. When You press enter and autofills /cmd as a command it automatically makes a space, but You can't copy paste /cmd with space at the end. I hope You get what I mean?

If not, quick explaining. Typing /cmd without enter and trying to press space, doesn't work. If You hit enter, then space is automatically added. It used to let You make space without pressing enter and it automatically became a command. Right now it doesn't. An that's why You can't just make /cmd {ENTER}, because it won't send a message, as You can't have the required space so it activates as a command and then send it.

Also I kinda fixed it. Between the first post and my reply, I had this command, which was a workaround but with terrible performance:

Code: Select all

+NumpadDiv::SendInput /cmd{SLEEP 300}{TAB}{ENTER}
I managed to change some stuff while writing this reply and...

Code: Select all

NumpadDiv::Send /cmd{SLEEP 10}`t`r
It still doesn't work flawlessly, but... I haven't found better option yet and it kinda does a job to some extent.

But the main problem is that performance of the device affect these commands now. Because back then enter meant sending it regardless and now, the sleep must be there so the command menu actually appears. For example the previous command with SLEEP 300 couldn't be less than 300, because it wouldn't work. But it made the command run slowly. But now 10 is kinda enough...

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Discord slash command help

Post by mikeyww » 30 Nov 2022, 21:42

My statement stands intact. Your expectations of Discord's response changed when you realized that it was behaving differently. You now simply need to convert your own new manual actions into new AHK code-- which it sounds like you have just done. :thumbup: :wave:

If you use AHK to send exactly the same keys that you send manually, with the same timing, but you see a different response, then it means that the target program is detecting a difference of some kind. From your description, I cannot tell whether you are simply reporting an update in Discord's command syntax, or a difference in the response between your typing and AHK's typing of the same keys. In any case, if you have it working, it probably doesn't matter much.
I don't get how {ENTER} works in AutoHotkey, because it's definitely not the same thing as pressing enter key.
This statement suggests (though might not absolutely prove) that Discord is responding differently to you vs. AutoHotkey, for the same key sequence. Actually, I've just repeated what I quoted (you as writing), but I'm not sure if you understood it in the same way.

Yes, timing can matter a great deal for controls that use auto-complete or "type ahead". In some cases, adjusting the SetKeyDelay can make the difference between success and failure. This is explained in the "tips for games" as well, at least to the extent of explaining that key delays can be important.

Post Reply

Return to “Ask for Help (v1)”