This is a bot for the 0x Community on Discord, created with ❤️ by cheesits456
Table of Contents
Provides information about the current staking epoch, such as the total ZRX currently staked, or how much time is remaining until the epoch expires. Stats are provided in the form of viewable but unjoinable voice channels, collapsable under their own category at the top of the server's channel list.
Provides information about the total dollar value (USD) of all trades on the ZRX network for the past 24 hours, as well as all time. Similar to the staking stats, the network volume statistics also use a voice channel in its own collapsable category.
Utilizes the 0x Tracker API to post details about every transaction on the ZRX Network to a read-only text channel in Discord. The Discord messages also contain a link to that transaction's page on the 0x Tracker website, as well as a Twitter link to draft a new Tweet about the transaction.
This bot has only been tested on Linux. It may turn out to work perfectly fine on Windows, but be aware that it also may turn out not to work perfectly fine on Windows
You'll need the following installed on your system in order to proceed with setup:
- Git
- Node.js v14 or higher
Run the following commands in the terminal to get started:
git clone https://github.com/cheesits456/0xDiscordBot.git
cd ./0xDiscordBot
npm install
cp ./.env.example ./.env
Next, open the .env
file with your text editor of choice. If you don't want Telegram or Twitter integration, simply leave those keys blank, ie:
# Telegram bot auth token
TELEGRAM_TOKEN=
Location: ./.env
A file of key-value pairs using Bash syntax (used to store API auth tokens securely).
Key | Description |
---|---|
DISCORD_TOKEN | The token for your Discord Bot (obtainable at Discord's Developer Portal) |
TELEGRAM_TOKEN | The token for your Telegram Bot (obtainable by messaging @BotFather on Telegram) |
TWITTER_CONSUMER_KEY | The API Key for your Twitter Bot (obtainable at Twitter's Developer Portal) |
TWITTER_CONSUMER_SECRET | The API Key Secret for your Twitter Bot (obtainable at Twitter's Developer Portal) |
TWITTER_ACCESS_TOKEN | The Access Token for your Twitter Bot (obtainable at Twitter's Developer Portal) |
TWITTER_ACCESS_TOKEN_SECRET | The Access Token Secret for your Twitter Bot (obtainable at Twitter's Developer Portal) |
Sample .env
# Discord bot auth token
DISCORD_TOKEN=S3CR3T
# Telegram bot auth token
TELEGRAM_TOKEN=T0K3N
# Twitter API tokens
TWITTER_CONSUMER_KEY=WhyDoes
TWITTER_CONSUMER_SECRET=Twitter
TWITTER_ACCESS_TOKEN=HaveFourDifferent
TWITTER_ACCESS_TOKEN_SECRET=AuthTokens
Location: ./config.json
Parameter | Type | Description |
---|---|---|
feedIcons | Boolean | Whether or not to use token icon emojis in transaction feed channel (see also: Icons.js) |
owners | Array<UserID> | Users who are allowed to use the restart and setup commands |
prefix | String | The default prefix for the bot |
statuses | Array<UserStatus> | Bot statuses to show in member list • minimum of 1 • no maximum • cycles every 15 seconds |
Sample config.json
{
"feedIcons": true,
"owners": [
"306018440639152128",
"517534579335233579"
],
"prefix": "!",
"statuses": [{
"name": "{trades} trades (24h)",
"type": "WATCHING"
}, {
"name": "{traders} traders (24h)",
"type": "WATCHING"
}]
};
Location: ./base/Icons.js
This file's default values will work fine for the official 0x Discord Bot. The documentation for this file is here for other people looking to host their own instance of the bot
This file defines which emojis the bot should use for different tokens in the transaction feed channel. If the feedIcons
option in config.json is set to false
, this file is ignored. If you're someone looking to host your own separate instance of this bot, the default values set in this file won't work for you - you'll need to change the IDs to ones for emojis your bot has access to (bots can only use emojis from servers they're in).
Parameter | Type | Description |
---|---|---|
default | EmojiID | The icon used for tokens that don't have an icon defined in this file |
EmojiID | The icon to display beside the Twitter link | |
TokenType (see example below) | EmojiID | The icon to use for the specified token |
Sample Icons.js
module.exports = {
default: "753024461254426674",
twitter: "752981062128369805"
ALEPH: "752511902357258240",
AMPL: "753009860026695680",
ANT: "752667695736029244",
BAT: "752379457204912248",
BUSD: "752392861428875295",
BZRX: "752466096560537672",
CARD: "752439167342084157",
CEL: "752959417795870721",
CELR: "753011925453111316",
COMP: "752400408453840966",
CRV: "752993259495620728",
DAI: "752385816269029447",
ENJ: "752385308837806080",
FOAM: "752532538437926922",
HT: "752996998457852026",
HUSD: "753010351993258395",
KNC: "752406951631257601",
LEND: "752994151825539103",
LINK: "752376842463477765",
LPT: "752517942834626620",
MANA: "752997376406585435",
MKR: "753005638593806417",
OMG: "752487743870992454",
PAX: "752405441597931572",
RARI: "753011492944740403",
REN: "753008350672977950",
REP: "753006702814691438",
REPv2: "752516431056207922",
RWS: "752653343666602025",
SNX: "752998308280270890",
STAKE: "753018780606660629",
TUSD: "752385812079050794",
UMA: "753009307611693146",
USDC: "752376590595260527",
USDT: "752376088960827462",
WBTC: "753008869256724651",
WETH: "752990647035625555",
YFI: "752411230760730694",
ZAP: "753007418165821561",
ZRX: "752998693048811571",
imBTC: "752392862053957673",
renBTC: "752457288299708439",
sUSD: "752398395313881098"
}
Location: ./base/AmountEmojis.json
This file defines the conditions for special emojis to appear beside the USD value in the transaction feed channel. It also defines the minimum USD value for a transaction to appear in the #trades
channel, as well as the minimum value required for a transaction to get a Twitter post.
- The key with the lowest numeric value determines the minumum USD value required for a transaction to be posted in Discord
- The lowest numbered key that has a non-empty value determines the minumum USD value required for a transaction to be posted on Twitter
- Values don't have to be emojis, you can set different messages for different value ranges if desired
Sample AmountEmojis.json
{
"5000": "",
"200000": "💵💵💵",
"300000": "💵💵💵💵💵💵",
"400000": "💵💵💵💵💵💵💵💵💵",
"500000": "💰💰💰",
"600000": "💰💰💰💰💰💰",
"700000": "💰💰💰💰💰💰💰💰💰",
"800000": "🚀🚀🚀",
"900000": "🚀🚀🚀🚀🚀🚀",
"1000000": "🚀🚀🚀🚀🚀🚀🚀🚀🚀",
"2000000": "🔥🔥🔥",
"3000000": "🔥🔥🔥🔥🔥🔥",
"4000000": "🔥🔥🔥🔥🔥🔥🔥🔥🔥",
"5000000": "🐳🐳🐳",
"6000000": "🐳🐳🐳🐳🐳🐳",
"7000000": "🐳🐳🐳🐳🐳🐳🐳🐳🐳",
"8000000": "🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳",
"9000000": "🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳",
"10000000": "🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳🐳"
}
Type: Object
Parameter | Type | Description |
---|---|---|
name | String | The name of the activity, with support for a couple variable values (see below) |
type | ActivityType | The type of activity |
String | Replaced With |
---|---|
{trades} |
The number of trades made withing the last 24 hours |
{traders} |
The number of active traders within the last 24 hours |
Example UserStatuses
{
"name": "{trades} trades (24h)",
"type": "WATCHING"
}
{
"name": "{traders} traders (24h)",
"type": "LISTENING"
}
Type: String
Any one of the following values:
LISTENING
PLAYING
STREAMING
WATCHING
With the config set up, you can now start the bot with the following command:
./start.sh
To kill the bot's main process, Press CTRL + C in its terminal window.
Once the bot is connected to discord, an invite link will be logged to the console. The invite link can be used to invite the bot to a new server, and has all the necessary permission flags set
Execute a shell command on the host machine
This command can only be executed by users set as "owner" in config.json
Execute a JavaScript function
This command can only be executed by users set as "owner" in config.json
A basic command to check the bot's websocket and processing latency
Used to change the command prefix for the server the command is issued in
This command can only be executed by server administrators
Use this command to shut down and restart the bot
This command can only be executed by users set as "owner" in config.json
Use this command to create the stat channels and network transaction feed
This command can only be executed by users set as "owner" in config.json
Fetch the most recent version of the bot code from GitHub and automatically merge it with the currently running code
This command can only be executed by users set as "owner" in config.json
This project is licensed under AGPL-3.0