corde icon indicating copy to clipboard operation
corde copied to clipboard

Add slash commands support

Open lucasgmagalhaes opened this issue 3 years ago • 12 comments

lucasgmagalhaes avatar Sep 21 '21 15:09 lucasgmagalhaes

Happy to help test if this feature is in progress :)

mikedotexe avatar Feb 03 '22 09:02 mikedotexe

Hi @mikedotexe!. It will be very helpful! Sorry for the extreme delay in the new version, I can't focus too much on the library, but as soon as I finish the migration to the new Discord.js version and add the tool to test slash commands, I will release a preview version so you can test! Thank you so much!

lucasgmagalhaes avatar Feb 03 '22 17:02 lucasgmagalhaes

Would love to see slash commands support too !

Thanks for your work :)

vafanassieff avatar Feb 07 '22 20:02 vafanassieff

Hi guys, unfortunately, there is no way (for now) to make corde test slash commands. Discord API doesn't allow bots to send slash commands. So, the only thing that is possible to do is to check if a slash command exists, its params, etc. But not test the action directly :(

I can not figure out any workaround for now so we will have to wait for Discord to allow bots to send slash commands to move on with this.

lucasgmagalhaes avatar Feb 14 '22 18:02 lucasgmagalhaes

Is there a feedback post on Discord's support page that we can upvote?

AndyClausen avatar Feb 17 '22 20:02 AndyClausen

Hi guys, unfortunately, there is no way (for now) to make corde test slash commands. Discord API doesn't allow bots to send slash commands. So, the only thing that is possible to do is to check if a slash command exists, its params, etc. But not test the action directly :(

Thank you so much for being responsive, and wonderful work.

mikedotexe avatar Feb 17 '22 21:02 mikedotexe

@AndyClausen I just created a feature proposal in discord discussion.

lucasgmagalhaes avatar Feb 18 '22 12:02 lucasgmagalhaes

For those of us desperate to have something, anything working, here's a wild approach for Mac users: use AppleScript.

https://user-images.githubusercontent.com/1042667/154858995-476dc708-32ad-424b-b3c8-3638f9b40b1c.mp4

mikedotexe avatar Feb 20 '22 18:02 mikedotexe

Maybe we could use this. Run chrome headless. So a real user will send messages, the bot will respond to them, and corde will check the response of the bot. Just discovered this script, I gonna see if it's works later.

lucasgmagalhaes avatar Feb 21 '22 17:02 lucasgmagalhaes

Hey folks, I ran into the exact same issue while writing tests for cordless, unfortunately I don't think there's anything we can do here. Bots are not able to use commands by design, I doubt Discord will budge on the issue.

Run chrome headless. So a real user will send messages, the bot will respond to them, and corde will check the response of the bot

This could work, but is most likely against the Discord ToS so you risk getting banned. Even if it's not against the ToS, it will be really painful to implement and maintain, and will probably be unusable in a CI/CD pipeline since you'll start getting captchas.

My current line of thought is to just query the Discord API for my bot's commands and save the response as a snapshot. This will at least allow me to assert that the commands were registered correctly. Of course, that still doesn't allow me to test how the commands are handled by the bot.

TomerRon avatar Jul 17 '22 08:07 TomerRon

For those who are Jetbrains users and also want to test Slash Commands, I have started prototyping the use of Selenium to run through my test sets.

https://www.youtube.com/watch?time_continue=4&v=VDpkfjEwzro&feature=emb_title

  1. Create yourself a test user
  2. Add your test bot to a test server
  3. Have the tests log in as your test user and run the commands you want
  4. Test the output.

There are so many implementations of Selenium out there, I use this as I love Jetbrains tools and that plugin makes code production a lot quicker. It needs tweaking from time to time.

EDIT: This is more for people wanting to run a e2e integration test, I still unit test some of my bot code which doesn't rely on mocking.

SteveChurch avatar Sep 22 '22 17:09 SteveChurch

@lucasgmagalhaes What if the dev could attach their discord.js instance (if they were using discord.js) and then corde would emit a fake ApplicationCommand interaction event.

Sure it only supports discord.js but djs is the largest library for js.

net-tech avatar Mar 10 '23 15:03 net-tech