Put your slash commands on Cloudflare's Worker service.
git clone https://github.com/A5rocks/slash-worker.git
cd slash-worker
- Edit
wrangler.toml
, putting in your account id. - Edit
public_keys.ts
, putting in the public key Discord provides in the application portal. - (optional) Edit
sentry.ts
with your values. npm i
- (you might not need to do this)
wrangler login
orwrangler config
wrangler publish
- Put the URL
wrangler
told you as theInteractions Endpoint URL
in the application portal.
Then, you can run any command (see "Registering a command") and it will work!
You can either use a library for a 1-use script or use a binary, your choice:
- Library: try out
slash-commands
. Checkcreate_command.js
in this directory for an example. - Binary: none yet, try searching GitHub! https://github.com/NurMarvin had one in the works, not sure of its status.
Or... You can read the documentation and manually construct a request in Insomnia or Postman... This is not recommended, though.
- Write a function that takes an
InteractionRequest
and returns aPromise<InteractionResponse>
. (or uses the endpoints to do equivalent) - Edit
commands/index.ts
to import the function and add it tohandlers
.
And then it should work! Make sure you have the slash command experiment enabled, so you can actually run your command.