Role Reward is a tool developed in Node.js that allows you to create advanced rewards for Twitch.
Table of Contents:
- Create an custom reward on twitch and link that to an action.
- Supports Discord role reward. (Apply a discord role to an user).
- Supports Fetch Reward. (Request to an url with custom data).
- Control the application with the integrated shell.
- Send notifications to an disocrd text channel.
The twitch app must have authorized urls
http://localhost:4000andhttp://localhost:4000/auth/oauth.
Frist clone this repository.
$ git clone https://github.com/VeguiDev/role-reward.gitNext goto the role-reward folder and execute this command. To install all packages.
$ npm installNext create an .env file with this information.
Example:
CLIENT_ID=(GET IT FROM TWITCH DEV CONSOLE)
CLIENT_SECRET=(GET IT FROM TWITCH DEV CONSOLE)
DISCORD_BOT_TOKEN=(GET IT FROM DISCORD DEVELOPER PORTAL)
DISCORD_CLIENT_ID=(GET IT FROM DISCORD DEVELOPER PORTAL)
DISCORD_GUILD_ID=(IT'S THE GUILD YOU WANT TO GIVE THE REWARDS TO)
Next step is build the project.
$ npm run buildAnd last step is launch the application.
$ npm run distTo start using this tool you need to login with twitch to do this there are two ways CLI login or Web Login
To login with this way you need have installed Twitch CLI.
This way is to get a refresh token with the twitch CLI and use it here.
$ twitch token --user-token -s "<NEED SCOPES>"To find out which scopes you need, use the scopes command.
Exmaple of twitch CLI:
Next copy this token to this application.
In this way, a session is started by accessing a web page.
Open browser an goto http://localhost:4000/auth/authorize. This page will be redirect to twitch.
The CLI is one that is within the same application to use it you must execute it.
- Login: Used to login from terminal.
- Action <create|list|get>
create: Starts the setup of a new action.list or ls: List all actions.get id: Get an action with their id.
- Disconnect: Disconnects discord and twitch.
- Reconnect: Reconnect discord and twitch.
- Status: Get the status of the application.
- Logout: Close the current session.
GET /auth
Returns valid credentials.
GET /auth/authorize
Redirects to twitch for oauth login.
DELETE /auth/logout
Close the current session.
GET /channel/rewards
List all channel custom rewards.
GET /channel/rewards/:id
Get an channel custom reward.
GET /channel/rewards/:id/redemptions
Get redemptions of a custom reward.
GET /discord/bot
Create an invite link for the discord bot.
GET /discord/roles
Get all roles of the discord guild configured.
GET /discord/roles/:id
Get an role from discord guild configured.
GET /actions
List all registered actions.
POST /actions
Create a new action.
Body:
{
"action_trigger": {
"title": "Points Reward",
"cost": 1
},
"reward": {
"type": "DISCORD_ROLE",
"roles": ["ROLE ID"]
}
}GET /status
Get the current application status.
Remember that the REST API is insecure and should not be exposed to the internet.
The registered discord slash commands.
/actions: List all registered actions./notify-channel set [channel]: Select the notifications channel. If you don't give a channel, the one in which the command is being executed will be used!/notify-channel view: Shows the notifications channel if it is set.
Its an text channel where the application sends notifications with example when the application complete, cancel or detect unattended redemtions.
See Discord Commands to learn the configuration commands.

