Skip to content

Commit

Permalink
Add Bitcoin info and Ratcoin info commands
Browse files Browse the repository at this point in the history
Added commands relating to Bitcoin and Ratcoin information.
  • Loading branch information
Gisgar3 committed Jul 12, 2018
1 parent 5ba82d8 commit 81d128a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
8 changes: 6 additions & 2 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"/ratz botinfo",
"/ratz releaseinfo",
"/ratz play + YouTube URL",
"/ratz stop"
"/ratz stop",
"/ratz btcinfo",
"/ratz ratcoininfo + Twitch Username"
],
"definitions": [
"Shows all commands for ratzBot",
Expand All @@ -17,6 +19,8 @@
"Shows all information about ratzBot",
"Shows the latest release information of ratzBot",
"Plays YouTube video audio",
"Stops YouTube video audio"
"Stops YouTube video audio",
"Shows information about Bitcoin",
"Shows the amount of RTC a user has on Twitch"
]
}
53 changes: 52 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,58 @@ bot.on('message', (message) => {
}
}
catch (err) {
console.log(`ERROR: ${err}`);
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
}
})
}
if (message.content.toString() == "/ratz btcinfo") {
var getBTCInfo = {
method: "GET",
url: "https://api.blockchain.info/stats"
}
request(getBTCInfo, (error, response, body) => {
try {
if (!error & response.statusCode == 200) {
var stats = JSON.parse(body);
const embed = new Discord.RichEmbed()
.setTitle("BTC Information")
.setColor(0xcb00ff)
.setThumbnail(bot.user.avatarURL)
.addField("Market Price (USD)", `$${stats.market_price_usd}`)
.addField("BTC Mined", stats.n_btc_mined)
.addField("Blocks Mined", stats.n_blocks_mined)
.addField("Total Blocks", stats.n_blocks_total)
.addField("Total BTC Sent", stats.total_btc_sent)
message.channel.send(embed);
}
else {
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
}
}
catch (err) {
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
}
})
}
// -----STREAMLABS INTEGRATION
if (message.content.startsWith("/ratz ratcoininfo ")) {
var result = message.content.slice(18);
var getRTCInfo = {
method: "GET",
url: `https://streamlabs.com/api/v1.0/points?access_token=${tokens.streamlabstoken}&username=${result}&channel=ratzdoll`
}
request(getRTCInfo, (error, response, body) => {
try {
if (!error & response.statusCode == 200) {
var stats = JSON.parse(body);
message.channel.send(`${message.author}, ${result} has ${stats.points} RTC!`);
}
else {
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
}
}
catch (err) {
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ratzbot",
"version": "2.4.1",
"version": "2.5.0",
"description": "Discord bot for Twitch streamer ratzDoll",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 81d128a

Please sign in to comment.