/tags-dappcmd-cfw

discord application command in cf workers

Primary LanguageJavaScript

tags-dappcmd-cfw

discord application command in cf workers

Steps to test run (not production)

  1. Create a discord application in https://canary.discord.com/developers/applications. If you already have an application that you can use to test, no need to create new

  2. Add this application to a test server using this link: https://canary.discord.com/api/oauth2/authorize?client_id=<application_id>&scope=applications.commands. Replace <application_id> with your application's app id, which you can find in the General Information tab of your application. (Remove the angle brackets as well while replacing <application_id>)

  3. Create a .env file in the root of the project

  4. Go to the OAuth2 page of the app

image

  1. Put CLIENT_ID and CLIENT_SECRET from the OAuth2 page in the .env file as shown in the example. (These are used to exchange for a token (see this), which is used only to register commands, for example, see this)

  2. Put the discord guild id as SERVER_ID as well, in the .env file

  3. Now run npm run init. This will register the two test commands (tag and create in init/createGuildCommand.js). The commands will be created for the server only

  4. In a terminal, cd into the project, and run npm ci to install dependencies

  5. From your discord application's General Informations tab, grab the PUBLIC KEY, run npm run put_public_key, and when it asks to enter secret value, paste the public key there and enter

  6. Run npm start

  7. Open another terminal, change directory to the project, and run npm run ngrok

  8. Copy the ngrok url (https one)

  9. Go to your applicataion in the discord applications page, paste the ngrok url in the Interactions Endpoint URL field and hit Save. Cross your fingers and wait for it to get the url accepted

  10. Test the /tag command in your test server