discord-read
Sequence that reads messages from Discord channel and writes to topic.
Description
Read messages from Discord channel and write to topic. This Sequence is a topic provider, it writes data under a topic name messages-slack-inbound
in "application/x-ndjson"
content type.
In order to read messages from Discord we need to create a bot first:
- Go to Developer Portal and click on Applications
- Click on
New Application
button and give it a name. Then click onCreate
. - In the newly created and selected app, click on
Bot
and click onAdd Bot
button. - Under
Build-A-Bot
either click onClick to Reveal Token
link or onCopy
button to get Discord Bot Token. This is important! - You can uncheck Public Bot.
- You can customize its name and icon.
- Expand
OAuth2
and selectURL Generator
. - Select
bot
under scopes andRead Messages/View Channels
under bot permissions. Copy URL. - Paste the URL into web browser address bar. Connect to Discord message will appear. Select your server from
Add To Server
dropdown and click onContinue
. If you don't have any servers you need to create one in those simple steps:- Start the Discord app for desktop or smartphone/tablet.
- Log into your Discord account.
- Click on the plus symbol on the left-hand side of the page.
- Select the option “Create a server”.
- Enter the name of your new Discord server.
- Click on “Create”.
- Confirm permissions on the next screen by clicking
Authorize
button. - You will get a confirmation saying: you may now close this window or tab.
Create a file called config.json
and add:
{
"token": "DISCORD_BOT_TOKEN_GOES_HERE"
}
Add config.json
to main directory in discord-read
sample and follow running process below:
Running
❗ Remember to setup transform-hub locally or use the platform's environment for the sequence deployment.
# install dependencies
npm install
# transpile TS->JS to dist/
npm run build
# make a compressed package with Sequence
si seq pack dist
# send Sequence to transform hub, this will output Sequence ID
si seq send dist.tar.gz
# start a Sequence
si seq start - -f config.json
# check Discord API connection via stdout stream
si inst stdout -
# type some messages on any channel on your Discord server and view the messages in topic
si topic get messages-slack-inbound