Skip to content

Commit

Permalink
Add new '/ratz laststream' command
Browse files Browse the repository at this point in the history
Added new '/ratz laststream' command that gives information of the last stream's VOD.
  • Loading branch information
Gisgar3 committed Jul 13, 2018
1 parent 81d128a commit 0c8d53d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
6 changes: 4 additions & 2 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"/ratz play + YouTube URL",
"/ratz stop",
"/ratz btcinfo",
"/ratz ratcoininfo + Twitch Username"
"/ratz ratcoininfo + Twitch Username",
"/ratz laststream"
],
"definitions": [
"Shows all commands for ratzBot",
Expand All @@ -21,6 +22,7 @@
"Plays YouTube video audio",
"Stops YouTube video audio",
"Shows information about Bitcoin",
"Shows the amount of RTC a user has on Twitch"
"Shows the amount of RTC a user has on Twitch",
"Shows last stream VOD and VOD information"
]
}
35 changes: 34 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bot.on('message', (message) => {
}
})
}
// -----STREAMLABS INTEGRATION
// -----STREAMLABS INTEGRATION-----
if (message.content.startsWith("/ratz ratcoininfo ")) {
var result = message.content.slice(18);
var getRTCInfo = {
Expand All @@ -224,6 +224,39 @@ bot.on('message', (message) => {
}
})
}
// -----TWITCH NEW API-----
if (message.content.toString() == "/ratz laststream") {
var getStreamVOD = {
method: 'GET',
url: `https://api.twitch.tv/helix/videos?user_id=157901049&first=1`,
headers: {
"Client-ID": `${tokens.twitchapiclientid}`
}
}
request(getStreamVOD, (error, response, body) => {
try {
if (!error & response.statusCode == 200) {
var stats = JSON.parse(body);
const embed = new Discord.RichEmbed()
.setTitle("Last Stream VOD from ratzDoll")
.setThumbnail(bot.user.avatarURL)
.setColor(0xcb00ff)
.setURL(stats.data[0].url)
.addField("Title", "" + stats.data[0].title)
.addField("Published At", "" + stats.data[0].published_at)
.addField("Duration", "" + stats.data[0].duration)
.addField("View Count", stats.data[0].view_count)
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.`);
}
})
}
// -----VOICE CHANNELS-----
if (message.content.startsWith("/ratz play ")) {
var result = message.content.slice(11);
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.5.0",
"version": "2.5.1",
"description": "Discord bot for Twitch streamer ratzDoll",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 0c8d53d

Please sign in to comment.