Welecome! The goal of this bot is to combine the abilities of Discord and Twitch, and allow both chats to communicate between eachother.
This file is designed to provided an overview of how to get the bot setup yourself on a custom environment.
Client ID
and Client Secret
. Create the the secret, and store it for later. Client ID will always be the same, but save this as well. These items in particular should be stored in config.json as CLIENT_ID
and CLIENT_SECRET
, under twitch
ACCOUNT_USERNAME
to your account's Twitch username, and add the same username to the CHANNELS
These new credentials will be there to help you authenticate this bot to use your user. This will be done in your web browser. When finished, the bot should communicate out of the user that authenticated it (e.g iSlammedMyKindle would be used to send messages, but internally, the bot can detect if it was sent via itself or other means besides your own keyboard input.)
There's also one channel you need to insert as well (CHANNELS
) - the bot only reads the first one, so in the first array index, pop in your username or whatever user's channel name to listen to that one.
If you intend on deploying this on an external server, you will need to change the address found in config.json
-> REDIRECT_URI
. Change it to the ip or domain name of the server, and redirects should work accordingly. (note that in this early version, the port is hard-coded to 3000; this will be used to deploy a temporary http server. Keep this in mind as providers like google cloud require that you expose ports before using them)
Another note is that if you try to deploy on a web server outside your local machine; auto-opening the browser is not supported. You will need to manually click on the link that is generated in the terminal to fully launch it. After launching the link, the process should be back to the flow as described above.
config.json
-> T2D_DISCORD_TOKEN
bot
, then in the second box, check "Manage messages", "Send Message", and "Read Messages"To prepend an emoji to the sent message, follow these steps:
"discord":{
// Rest of the file
"EMOJI_NAME": "your_emoji_name_here",
"EMOJI_ID": "your_emoji_id_here"
},
If not provided, an emoji won't be displayed, just the username + message.
On your Discord server, the channel that will reflects Twitch chat needs to have permissions disabled on it. Twitch is directly based on an IRC standard, which means things like threads are not going to be supported.
Create the channel, and then copy it's Discord ID (enable developer settings in your personal Discord settings to make this work.) You can also find the Discord ID in the URL of your browser if Discord is being used there (it will be the last set of numbers in the link). Place the channel ID inside config.js
-> T2D_DISCORD_CHANNEL
.
T2D_DEV_SAVE_TOKEN
You'll need this setting toggled to true if you are just developing the bot. Twitch only offers up to 50 tokens at a given time, so this will prevent you from maxing that out quickly!
Run the build script with npm run build
, then run npm run start
and a link should show up in the terminal (if you're on localhost/desktop, a browser window should pop up); it will make you authenticate with Twitch. Once that's finished, the bot should be up and running! If you set T2D_DEV_SAVE_TOKEN
to true, the token that was just created will be saved to a file for when you need to relaunch the bot. If this token expires, you'll need to delete the file to start over. (for now)
At this current point in time, by setting the AUTH_PAGE_PATH
in config.json
, or T2D_AUTH_PAGE_PATH
in your enviorment variables, you are able to directly change the page which is shown once you authenticate. We currently have a default page which is used if you do not wish to pass one/create one.
twitchToDiscord was designed to be run by a separate user other than the broadcaster. However, the four above events can only be subscribed to by the broadcaster user. To get around this, the project makes use of twitchListenerCore, a separate application.
This will send these events directly to discord without creating another bot that uses both twitch and discord apis together.
The following flags are accepted for the config or environment variables:
T2D_LC_URL
- the address listenerCore is listening to.T2D_LC_SCOPE
- (array) the events to start listening to. Event types: ["redeem", "cheer", "follow", "sub"]
Environment variables will have the same syntax for the most part just like in the config.json
. However, there are some main differences when applying the https env's - which are listed below:
T2D_HTTPS_ENABLED
- Turn https on; use this in production!T2D_HTTPS_KEYPATH
- Where your .key is for the ssl certificateT2D_HTTPS_CERTPATH
- The path for the .crtT2D_HTTPS_PASSPHRASE
- The passphrase for the .crtT2D_AUTH_PAGE_PATH
- The direct path to the page you would like to show once you have authed. Keep null/undefined for default page.