diff --git a/commands.json b/commands.json index 2a2d497..defab96 100644 --- a/commands.json +++ b/commands.json @@ -10,7 +10,9 @@ "/ratz stop", "/ratz btcinfo", "/ratz ratcoininfo + Twitch Username", - "/ratz laststream" + "/ratz laststream", + "/ratz gituserinfo + GitHub Username", + "/ratz gitrepoinfo + {GitHubUsername}/{RepositoryName}" ], "definitions": [ "Shows all commands for ratzBot", @@ -23,6 +25,8 @@ "Stops YouTube video audio", "Shows information about Bitcoin", "Shows the amount of RTC a user has on Twitch", - "Shows last stream VOD and VOD information" + "Shows last stream VOD and VOD information", + "Shows information for provided GitHub user", + "Show information for provided GitHub repository (which is owned by the provided GitHub username)" ] } \ No newline at end of file diff --git a/main.js b/main.js index a2b707f..6d2f220 100644 --- a/main.js +++ b/main.js @@ -174,6 +174,76 @@ bot.on('message', (message) => { } }) } + if (message.content.startsWith("/ratz gituserinfo ")) { + var result = message.content.slice(18); + var getGitUserInfo = { + method: "GET", + url: `https://api.github.com/users/${result}`, + headers: { + "User-Agent": "Gisgar3" + } + } + request(getGitUserInfo, (error, response, body) => { + try { + if (!error & response.statusCode == 200) { + var stats = JSON.parse(body); + const embed = new Discord.RichEmbed() + .setTitle(`GitHub User Information for ${result}`) + .setURL(stats.html_url) + .setColor(0xcb00ff) + .setThumbnail(stats.avatar_url) + .addField("Name", stats.name) + .addField("Company", "" + stats.company) + .addField("Bio", "" + stats.bio) + .addField("Location", "" + stats.location) + .addField("Email", "" + stats.email) + .addField("Hireable", "" + stats.hireable) + .addField("Public Repositories", stats.public_repos) + 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.`); + } + }) + } + if (message.content.startsWith("/ratz gitrepoinfo ")) { + var result = message.content.slice(18); + var getGitRepoInfo = { + method: "GET", + url: `https://api.github.com/repos/${result}`, + headers: { + 'User-Agent': 'Gisgar3' + } + } + request(getGitRepoInfo, (error, response, body) => { + try { + if (!error & response.statusCode == 200) { + var stats = JSON.parse(body); + const embed = new Discord.RichEmbed() + .setTitle(`GitHub Repository for ${result}`) + .setURL(stats.html_url) + .setColor(0xcb00ff) + .setThumbnail(stats.owner.avatar_url) + .addField("Name", stats.name) + .addField("Description", stats.description) + .addField("Owner", stats.owner.login) + .addField("Language", stats.language) + .addField("Archive Status", stats.archived) + 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.`); + } + }) + } if (message.content.toString() == "/ratz btcinfo") { var getBTCInfo = { method: "GET", diff --git a/package-lock.json b/package-lock.json index bc235f6..55c9dbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.5.1", + "version": "2.6.0 RC", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 40b5828..09dc89a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.5.1", + "version": "2.6.0 RC", "description": "Discord bot for Twitch streamer ratzDoll", "main": "main.js", "scripts": {