Skip to content

Commit

Permalink
Allow commands to run in user-installed context (#89)
Browse files Browse the repository at this point in the history
* Update discord-api-types + workers-discord

* Allow user-install for all commands

* Add notes to README for user-install commands

* Improve command registration debugging

* Add new invite for user-install

* Don't scope staging to a specific guild
  • Loading branch information
MattIPv4 authored Aug 12, 2024
1 parent 727cb5f commit 2a2e1f6
Show file tree
Hide file tree
Showing 17 changed files with 573 additions and 493 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deployment-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
CLIENT_ID: ${{ secrets.STAGING_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.STAGING_CLIENT_SECRET }}
CLIENT_PUBLIC_KEY: ${{ secrets.STAGING_CLIENT_PUBLIC_KEY }}
TEST_GUILD_ID: ${{ secrets.STAGING_TEST_GUILD_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.STAGING_SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.STAGING_SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.STAGING_SENTRY_PROJECT }}
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

---

1.1.1.1 works from a Discord server, thanks to the 1.1.1.1 bot. [Invite the bot to your Discord server](https://dns-over-discord.v4.wtf/invite) to start using DNS over Discord.
1.1.1.1 works from a Discord server, thanks to the 1.1.1.1 bot. [Invite the bot to your Discord server](https://dns-over-discord.v4.wtf/invite) to start using DNS over Discord. Or, [add the bot to your Discord account](https://dns-over-discord.v4.wtf/invite/user) to use it anywhere in Discord.

## Perform DNS lookups

Expand Down Expand Up @@ -301,8 +301,9 @@ Example:

### `invite` command

The `/invite` command provides the user with a quick link to invite the 1.1.1.1 DNS over Discord bot to another Discord server.
The `/invite` command provides the user with a quick link to invite the 1.1.1.1 DNS over Discord bot to another Discord server, or to add it to a Discord account.
The bot can be invited at any time with [https://dns-over-discord.v4.wtf/invite](https://dns-over-discord.v4.wtf/invite).
The bot can also be added to accounts with [https://dns-over-discord.v4.wtf/invite/user](https://dns-over-discord.v4.wtf/invite/user).

```txt
/invite
Expand Down Expand Up @@ -361,6 +362,16 @@ node
5. Develop with the worker by running `npm run dev`.
6. (Optional) Start an HTTP tunnel to your local development server by running `npm run tunnel`, using [cloudflared](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/trycloudflare).

### User-installed commands

To test the user-installed commands functionality, you'll need to make sure your Discord application has the User Install option enabled.

You'll then need to make sure that the `TEST_GUILD_ID` in `development.env` is commented out, as user-installed commands need to be registered globally.

After that, start the worker as usual with `npm run dev`, install the application to your Discord user, and test the commands.

If you no longer wish to have the commands registered globally, leave `TEST_GUILD_ID` commented and update `webpack.config.js` to pass an empty array to the `registerCommands` call, then start the worker again to remove the global commands.

## Deployments

`wrangler.toml` and this repository is currently designed for a staging deployment and a production deployment.
Expand Down
Loading

0 comments on commit 2a2e1f6

Please sign in to comment.