Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slash commands support #1026

Open
lucasgmagalhaes opened this issue Sep 21, 2021 · 12 comments
Open

Add slash commands support #1026

lucasgmagalhaes opened this issue Sep 21, 2021 · 12 comments
Assignees
Milestone

Comments

@lucasgmagalhaes
Copy link
Collaborator

No description provided.

@lucasgmagalhaes lucasgmagalhaes added this to the 5.0 milestone Sep 21, 2021
@lucasgmagalhaes lucasgmagalhaes self-assigned this Sep 21, 2021
@mikedotexe
Copy link

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

@lucasgmagalhaes
Copy link
Collaborator Author

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!

@vafanassieff
Copy link

Would love to see slash commands support too !

Thanks for your work :)

@lucasgmagalhaes
Copy link
Collaborator Author

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.

@AndyClausen
Copy link

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

@mikedotexe
Copy link

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.

@lucasgmagalhaes
Copy link
Collaborator Author

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

@mikedotexe
Copy link

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

applescript-test-slash-commands.mp4

@lucasgmagalhaes
Copy link
Collaborator Author

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.

@TomerRon
Copy link

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.

@SteveChurch
Copy link

SteveChurch commented Sep 22, 2022

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.

@net-tech
Copy link

net-tech commented Mar 10, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants