This code is based off the modular (and not secure) ERC20 Tip Bot here. This one does not claim to be modular, yet it should be easy to modify this bot to work off other databases or coin APIs.
To install the bot:
- If the coin is BTC based:
- Install your 'BTCd'.
- Edit the conf file to add
server=1,rpcuser=user, andrpcpass=pass(with your own username and password). - Start the daemon.
- Move
btcSettings.jsontosettings.json. - Edit the
settings.jsonfile'scoinobject to have:symbolset to the coin's symbol ("BTC").decimalsset to the amount of the coin's decimals (8). Optionally, you may set a lower amount of decimals so users can't tip satoshis.portset to the daemon's RPC port (8337).userset to the username you set in the conf file ("user").passset to the password you set in the conf file ("pass").
- If the coin is an ERC20:
- Move
erc20Settings.jsontosettings.json. - Edit the
settings.jsonfile'scoinobject to have:symbolset to the coin's symbol ("ERC").decimalsset to the amount of the coin's decimals (18).withdrawFeeset to the amount of the coin to charge every withdraw.infuraset to the WebSocket URL of the Infura Project the bot is run through.- NOTE: if you want to use a geth light node instead of infura:
- Update geth-light.service replacing
userwith your user and/path/towith the path to the erc20tipbot folder. - Move to the service folder
mv geth-light.service /etc/systemd/system/geth-light.service - Start the service:
systemctl start geth-light
- Update geth-light.service replacing
keysset to the directory used for keystore files. Every keystore in this directory must be encrypted with a blank password, and the bot will work with every keystore.
- Edit the
settings.jsonfile'scoin.addressesobject to have:walletset to the address which will host all the Ether used to fund TXs. This must be an address in a keystore file already in the keys directory.contractset to the ERC20's contract address.
- Move
- Install MySQL.
- Create a database.
- Create a table with
name VARCHAR(64), address VARCHAR(64), balance VARCHAR(64), notify tinyint(1). - Create a table with
name VARCHAR(64), active tinyint(1) - Edit the
settings.jsonfile'smysqlvar to have:dbset to the name of the database you made for the bot.tipsset to the name of the table you made for the bot.adminsset to the name of the table you made for the admin bot.userset to the name of a MySQL user with access to the DB.passset to the password of that MySQL user.
- Create a Discord Bot User.
- Go to https://discordapp.com/developers/applications/me.
- Click
New App. - Enter a name, and optionally, upload an icon.
- Click
Create a Bot User. - Grab the
Client IDfrom the top, and go to this link: https://discordapp.com/oauth2/authorize?client_id=!!CLIENT_ID!!&scope=bot&permissions=68672, after replacing !!CLIENT_ID!! with the bot's client ID. This will allow you to add the bot to a server with the proper permissions of Read Messages/Send Messages/Add Reactions (the last one is only necessary if you use giveaways). - Edit the
settings.jsonfile'sdiscordvar to include:tokenset to the bot user token. This is not the client user.userset to the value gotten by right-clicking the bot on your server and clickingCopy ID. This requiresDeveloper Modeto be enabled on your Discord client.giveawayEmojiset to the emoji you want to use for giveaways. This defaults to 🎉.
- Set up pools. Either delete or modify the ones in settings.json.
adminscontrol who can add/remove members.membersis anyone who can spend the money in the pool.
- Set up any channel locked commands in
settings.json'scommandsvar.- If you wish to lock a command to a channel, edit
exampleto be the name of the command, andROOM IDto be the value gotten from right-clicking a room and clickingCopy ID. You can add multiple channel IDs to the array. - To setup more channel locks, simply copy the
exampletemplate and fill it our properly.
- If you wish to lock a command to a channel, edit
- Install NodeJS dependencies via
npm i.discord.jswill print several warnings about requiring a peer but none was installed. These are normal, and refer to optional packages for connecting to voice channels, something we don't do.
All pools must be created via settings.json. All edits to the list of admins must also be done there. Members can be added and removed with !pool NAME add @USER and !pool NAME remove @USER, where NAME is the name of the pool, and @USER is a ping of the Discord user. To send from a pool, use !tip POOL @USER AMOUNT.
There is also a giveaway command to run giveaways with, yet it is currently disabled due to changes with how emojis are handled. If you don't want it, either don't setup the giveaways pool or comment out the line that loads it in main.js. To use it, run !giveaway Ts Ww A, where T is the time in seconds (or use "m" as a suffix for minutes), W is the amount of winners, and A is the amount each win. The amount will come from the giveaways pool and be tipped out to the winners.
Neither of these commands are documented as they are only to be used by whoever runs the bot, and that is not most people. It's not for security via obscurity, but rather because a long help file where half the commands aren't needed is annoying.
Want to donate? 0xA0F7aAAF3161c5611a904263bFfe45C92394Da44