{"id":22862401,"url":"https://github.com/dylibso/discordbot","last_synced_at":"2025-04-30T21:51:33.902Z","repository":{"id":254158673,"uuid":"825092171","full_name":"dylibso/discordbot","owner":"dylibso","description":"xtp demo: discord bot","archived":false,"fork":false,"pushed_at":"2025-02-27T16:44:28.000Z","size":341,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-30T21:51:25.340Z","etag":null,"topics":["discord","extensibility","extism","plugins","wasm","xtp"],"latest_commit_sha":null,"homepage":"https://www.getxtp.com/blog/extending-discord-with-wasm","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dylibso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-06T18:43:31.000Z","updated_at":"2025-04-06T07:13:40.000Z","dependencies_parsed_at":"2024-11-08T18:22:47.387Z","dependency_job_id":"697574c3-cc16-427f-9f8c-8bbcb8c87de5","html_url":"https://github.com/dylibso/discordbot","commit_stats":null,"previous_names":["dylibso/discordbot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fdiscordbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fdiscordbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fdiscordbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylibso%2Fdiscordbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dylibso","download_url":"https://codeload.github.com/dylibso/discordbot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789307,"owners_count":21644081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","extensibility","extism","plugins","wasm","xtp"],"created_at":"2024-12-13T10:13:27.551Z","updated_at":"2025-04-30T21:51:33.875Z","avatar_url":"https://github.com/dylibso.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discordbot\n---\n\n## running it\n\nMake sure that postgres is running on `localhost:5432` with `postgres:password`\nas the credentials. (If you're running xtp locally, this should already be the\ncase!)\n\n1. Copy `env.example` to `.env`.\n2. Create a Discord test server for local dev.\n3. Create a Discord app and bot.\n    - Click \"New Application\" on [the Discord dev portal](https://discord.com/developers/applications).\n    - Call it `xtp (local)`\n    - Navigate to the \"Installation\" drawer tab.\n        - Make sure only \"Guild install\" is checked.\n        - Under \"default install settings\":\n            - Scopes: Add \"application.commands\" and \"bot\".\n            - Permissions:\n                - Add Reactions\n                - Attach files\n                - Ban members\n                - Embed links\n                - Manage Messages\n                - Read message History\n                - Read messages / view channels\n                - Send Messages\n                - Use Slash commands\n            - To add the bot to your server, click the link under \"Install Link\".\n    - Navigate to the \"Bot\" drawer tab.\n        - Click the \"Reset Token\" button. **Save the token as `DISCORD_BOT_TOKEN`**.\n        - Uncheck \"public bot\".\n        - Check \"PRESENCE INTENT\".\n        - Check \"SERVER MEMBERS INTENT\".\n        - Check \"MESSAGE CONTENT INTENT\".\n4. Link an XTP app.\n    - The app should be on staging or local.\n        - For local use `http://localhost:8080`.\n        - For staging use `https://xtp-staging.dylibso.com`\n    - Now login using the xtp CLI: `xtp auth login -e REPLACEME_WITH_XTP_ENDPOINT`.\n        - **Grab the token** using `xtp auth token show` and edit `.env`'s `XTP_TOKEN` value to reflect that token.\n        - **Grab an app id** using `xtp app list`. It'll look like `app_2gv3krz3ry8658t5cbebnbnppy`. Set `XTP_APP_ID` in `.env` to that value.\n    - Just one more thing. :colombo:\n        - Go to your app on the XTP environment you chose. That's `http://localhost:8081` if you're running locally\n          or `https://xtp-staging.dylibso.com` otherwise.\n        - **Create an extension point named `chat`.**\n        - That extension point should use the schema from `./plugin.yaml`.\n\nYou're just about ready. Now you can run:\n\n```\n$ psql postgres://postgres:password@localhost/xtp -c 'create database discordbot;'\n$ npm ci\n$ npm run migrate\n$ npm run dev\n```\n\n### setting up github actions on another app\n\nWhen we switch from xtp-staging to xtp for the deployed service:\n\n- We need to change the `XTP_TOKEN` GitHub secret to an admin of the XTP env's app.\n- We need to create _two_ extension points on that app: one for testing and one for prod.\n- The testing extension ID needs to go in `.github/workflows/ci.yaml` replacing `EXTENSION_ID`.\n- The prod extension ID needs to go in `.github/workflows/cd.yaml` replacing `EXTENSION_ID`.\n\n### setting up local github oauth\n\n2. **[Make a GitHub app](https://github.com/settings/applications/new)**.\n    - the \"Application name\" should be something like \"discordbot (dev)\".\n    - \"Homepage URL\" doesn't really matter, but maybe point it to XTP?\n    - Authorization callback url MUST `http://localhost:8124/login/github/callback` for local dev.\n    - Word to the wise: [**DO NOT PASS GO. DO NOT TAKE 200 DOLLARS.**](https://monopoly.fandom.com/wiki/Go_to_Jail_(card))\n        - Take the client id and secret and put them in your 1Password private vault.\n    - Now go edit your `.env`. `OAUTH_GITHUB_CLIENT_ID` and `OAUTH_GITHUB_SECRET` should reflect the respective values you just saved in your vault.\n    - You _did_ save them, right?\n    - Okay. I'll believe you. But I've got my eyes on you!\n\n---\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylibso%2Fdiscordbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdylibso%2Fdiscordbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylibso%2Fdiscordbot/lists"}