Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from vigneshd332/staging
Browse files Browse the repository at this point in the history
Staging -> Master
  • Loading branch information
vigneshd332 authored Jun 11, 2020
2 parents 0b32def + a7bb5e9 commit c0eb020
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Right now, the bot can:
* token = Your unique Discord API Token from the bot's account.
* watson_key = Your unique IBM API key from IBM Cloud.
* watson_url = The URL in IBM Cloud with the API Key.
* giphykey = Your unique Giphy API key

#### Commands:
* \<prefix>play \<url> : Plays audio from video in url.
Expand All @@ -22,6 +23,7 @@ Right now, the bot can:
* \<prefix>image \<search term> : Displays images related to the search term.
* \<prefix>bruh : Displays a bruh gif.
* \<prefix>tts \<language accent> \<text>: Converts text in any script to audio.
* \<prefix>gif \<search term> : Displays a gif related to the search term.

** Language accents: en, it, jp, ru, etc.**
## To deploy a version of this bot to your Heroku account:
Expand Down
98 changes: 55 additions & 43 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const queue = new Map();

client.once('ready', () => {
console.log('Ready!');
client.user.setActivity("Use " + `${process.env.prefix}help` + " v3.2.1 | Hi Thu, UwU").catch(logger.error);
client.user.setActivity("Use " + `${process.env.prefix}help` + " v3.2.2").catch(logger.error);
});

client.once('reconnecting', () => {
Expand Down Expand Up @@ -63,41 +63,8 @@ client.on('message', (message) => {

if (message.content.startsWith(`${process.env.prefix}gif`))
{
// Split message to search GIPHY
let splitWord = message.toString().split(" ");
let gifWord = "";

// Loop through incase of multiple word search
for( var i = 1; i < splitWord.length; i++)
{
if(i > 1)
{
gifWord = gifWord + "+";
}

gifWord = gifWord + splitWord[i];
}

request("http://api.giphy.com/v1/gifs/search?q=" + gifWord + "&api_key=" + process.env.giphykey + "&limit=100", function (error, response, body)
{
if (!error && response.statusCode == 200)
{
// Convert body to JSON object
let jsonUrl = JSON.parse(body);

// Get random number to choose GIF
let totGif = jsonUrl.data.length;

if(totGif > 100)
{
totGif = 100;
}

let ranNum = Math.floor(Math.random() * totGif);

message.channel.sendMessage(jsonUrl.data[ranNum].url);
}
});
let splitWord = message.toString().split(" ");
gif(message, splitWord);
}
});
client.on('message', message => {
Expand Down Expand Up @@ -218,8 +185,7 @@ client.on('message', async message => {
message.channel.send('(P.S Boot his a** if he does not respond)')
return;
} else if (message.content.startsWith(`${process.env.prefix}about`)) {
message.channel.send('Well, Well. I see you are interested. But I am taken. Sorry!')
message.channel.send('**Version :** v3.2.1')
message.channel.send('**Version :** v3.2.2')
message.channel.send('**Build Date :** 19/4/2020')
message.channel.send('**Hosted on :** Heroku (Stack 18)')
message.channel.send('Built using **Node.js**')
Expand All @@ -240,6 +206,19 @@ client.on('message', async message => {
} else if (message.content.startsWith(`${process.env.prefix}hd`)) {
hyperdelete(message);
return;
} else if (message.content.startsWith(`${process.env.prefix}noncify`)) {
var pieces = message.content.split(' ');
if(pieces.length>=2) {
var user = pieces[1];
message.channel.send('Hello I am Chris Hansen, and ' + user + ' is offcially a nonce!');
var nonce = 'user nonce';
pieces = nonce.split(' ');
image(message, pieces);
}
else {
message.channel.send("Please mention a user");
}
return;
} else {
return;
}
Expand All @@ -259,9 +238,6 @@ function hyperdelete(message) {
if (message.author.id === "432474514534957057"){
message.delete(10);
}
else {
message.channel.send('I aint doin the dirty work of cleaning up your shit');
}
}

async function execute(message, serverQueue) {
Expand Down Expand Up @@ -345,11 +321,10 @@ function play(guild, song) {
}
function image(message, parts) {
const args = message.content.split(' ');

/* extract search query from message */

var search = parts.slice(1).join(" "); // Slices of the command part of the array ["!image", "cute", "dog"] ---> ["cute", "dog"] ---> "cute dog"

console.log(search);
var options = {
url: "https://www.dogpile.com/serp?qc=images&q=" + search + "&capv=iLTjemasNqjegwR_UdH2YCEUiIhYjMN4Bo6oC9Ghc2x9toMka1N4gQdbzk25RV2r",
method: "GET",
Expand Down Expand Up @@ -392,4 +367,41 @@ function image(message, parts) {
}
});
}
function gif(message, splitWord) {
// Split message to search GIPHY
let gifWord = "";
console.log(splitWord)

// Loop through incase of multiple word search
for( var i = 1; i < splitWord.length; i++)
{
if(i > 1)
{
gifWord = gifWord + "+";
}

gifWord = gifWord + splitWord[i];
}

request("http://api.giphy.com/v1/gifs/search?q=" + gifWord + "&api_key=" + process.env.giphykey + "&limit=100", function (error, response, body)
{
if (!error && response.statusCode == 200)
{
// Convert body to JSON object
let jsonUrl = JSON.parse(body);

// Get random number to choose GIF
let totGif = jsonUrl.data.length;

if(totGif > 100)
{
totGif = 100;
}

let ranNum = Math.floor(Math.random() * totGif);

message.channel.sendMessage(jsonUrl.data[ranNum].url);
}
});
}
client.login(process.env.token);
4 changes: 2 additions & 2 deletions 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": "bot-discord-athena",
"version": "3.2.1",
"version": "3.2.2",
"description": "Kinda do it all.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c0eb020

Please sign in to comment.