Discord chat bot to announce projects (#590)
Add support for discord chat bot to announce when images are set, with instructions on configuring for dev. This uses the REST API instead of a websocket connection, which is needed for serverless deployment. Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
This commit is contained in:
@@ -59,6 +59,27 @@ localUser2@kurthutten.com: `abc123`
|
||||
|
||||
localAdmin@kurthutten.com: `abc123`
|
||||
|
||||
### Discord bot setup
|
||||
|
||||
To set up the discord bot to notify when users publish new content (see also [the discord JS tutorial](https://discordjs.guide/preparations/setting-up-a-bot-application.html)):
|
||||
|
||||
1. If you're setting up the bot in a dev environment, create a new discord server (the "plus" button on the left when logged into the Discord webpage). Make note of the name of the project.
|
||||
2. With [developer mode turned on](https://www.howtogeek.com/714348/how-to-enable-or-disable-developer-mode-on-discord/), right click the channel you wish the bot to announce on and select "Copy ID". Add this to `.env.defaults` as `DISCORD_CHANNEL_ID`.
|
||||
3. [create a new application](https://discord.com/developers/applications), or navigate to an existing one.
|
||||
4. Create a bot within that application. Copy the bot token and add it to `.env.defaults` as `DISCORD_TOKEN`.
|
||||
5. Go to the "URL Generator" under "OAuth2" and create a URL with scope "bot" and text permission "Send Messages".
|
||||
6. Copy the generated URL and open it in a new tab. Follow the instructions on the page to add the bot to your discord server.
|
||||
|
||||
When you next start CADHub, you should see in the logs `Discord: logged in as <bot name>` and you should see a startup message from the bot in the channel.
|
||||
|
||||
To send messages as the bot when things happen in the service, use the `sendChat` helper function:
|
||||
|
||||
```typescript
|
||||
import { sendChat } from 'src/lib/discord'
|
||||
|
||||
sendChat("hello world!")
|
||||
```
|
||||
|
||||
## Designs
|
||||
|
||||
In progress, though can be [seen on Figma](https://www.figma.com/file/VUh53RdncjZ7NuFYj0RGB9/CadHub?node-id=0%3A1)
|
||||
|
||||
Reference in New Issue
Block a user