Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
updated commands and events
Browse files Browse the repository at this point in the history
  • Loading branch information
RohitM-IN authored Dec 3, 2019
1 parent 418b852 commit ed07177
Show file tree
Hide file tree
Showing 23 changed files with 729 additions and 231 deletions.
60 changes: 36 additions & 24 deletions commands/bot/eval.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
const config = require("../../config.json");

module.exports = {
name: "eval",
category: "bot",
description: "Dangerous eval command",
run: async (client, message, args) => {

if(message.author.id !== config.ownerid) return;
try {
const code = args.join(" ");
let evaled = eval(code);

if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);

message.channel.sendCode("xl", evaled);
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}


}
}
const Discord = require("discord.js");
const config = require("../../config.json");
const ownerid = "348832732647784460";
const { inspect } = require("util");

module.exports = {
name: "eval",
category: "bot",
description: "Dangerous eval command",
run: async (client, message, args) => {

console.log(`working bot`)
if(message.author.id == ownerid){
let toeval = args.join(" ");
let evaled = inspect(eval(toeval, { depth: 0 }))
try{
if(toeval) {
let hrStart = process.hrtime()
let hrDiff;
hrDiff = process.hrtime(hrStart)
return message.channel.send(`Executed in ${hrDiff[0] > 0 ? `${hrDiff[0]}s`: ''}${hrDiff[1]/ 1000000}ms *\`\`\`javascrpit\n${evaled}\n\`\`\``, { maxLength: 1900})
} else {
message.channel.send("Error while evaluating.")
}
} catch(e){
message.channel.send(`Error while evaluating : \`${e.message}\``);
}
} else {
return message.reply("you dont have perission to use this command").then(m => m.delete(5000));
}




}
}
50 changes: 17 additions & 33 deletions commands/fun/invite.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
const fs = require('fs');
const Discord = require('discord.js');
module.exports = {
name: "invite",
category: "fun",
description: "Sends you the invite link for bot and server",
run: async (client, message, args ) => {
let invitecode = "https://discord.gg/55rfDdK";
let botinvitecode = "http://bit.ly/ethytgamingbot";

// let sEmbed = new Discord.RichEmbed()
// .setColor("RANDOM")
// .setTitle(`Here is the invite link for inviting to your server`)
// .setDescription(`${botinvitecode}`);

// let Embed = new Discord.RichEmbed()
// .setColor("RANDOM")
// .setTitle(`Here is the invite code for joining bot's support server`)
// .setDescription(`${invitecode}`);

// if(args[0] == 'bot') message.reply(sEmbed);
// if(args[0] == 'server') message.reply(Embed);
//message.reply(sEmbed);
//message.reply(Embed);
message.channel.send(`Here is the invite link for inviting to your server\n${botinvitecode}\nHere is the invite code for joining bot's support server\n${invitecode}`);
message.author.send(`Here is the invite link for inviting to your server\n${botinvitecode}\nHere is the invite code for joining bot's support server\n${invitecode}`);
//message.author.send(sEmbed);
//message.author.send(Embed);
console.error('Caught the promise rejections');
}

}
process.on('unhandledRejection', error => console.log('Uncaught Promise Rejection', error));
const fs = require('fs');
const Discord = require('discord.js');
module.exports = {
name: "invite",
category: "fun",
description: "Sends you the invite link for bot and server",
run: async (client, message, args ) => {
let invitecode = "https://discord.gg/55rfDdK";
let botinvitecode = "http://bit.ly/ethytgamingbot";

message.channel.send(`Here is the invite link for inviting to your server\n${botinvitecode}\nHere is the invite code for joining bot's support server\n${invitecode}`);

// message.author.send(`Here is the invite link for inviting to your server\n${botinvitecode}\nHere is the invite code for joining bot's support server\n${invitecode}`);

}

}
31 changes: 31 additions & 0 deletions commands/fun/love.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { RichEmbed } = require("discord.js");
const { getMember } = require("../../functions.js");

module.exports = {
name: "love",
aliases: ["affinity"],
category: "fun",
description: "Calculates the love affinity you have for another person.",
usage: "[mention | id | username]",
run: async (client, message, args) => {
// Get a member from mention, id, or username
let person = getMember(message, args[0]);

if (!person || message.author.id === person.id) {
person = message.guild.members
.filter(m => m.id !== message.author.id)
.random();
}

const love = Math.random() * 100;
const loveIndex = Math.floor(love / 10);
const loveLevel = "💖".repeat(loveIndex) + "💔".repeat(10 - loveIndex);

const embed = new RichEmbed()
.setColor("#ffb6c1")
.addField(`☁ **${person.displayName}** loves **${message.member.displayName}** this much:`,
`💟 ${Math.floor(love)}%\n\n${loveLevel}`);

message.channel.send(embed);
}
}
44 changes: 44 additions & 0 deletions commands/fun/rps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { RichEmbed } = require("discord.js");
const { promptMessage } = require("../../functions.js");

const chooseArr = ["🗻", "📰", "✂"];

module.exports = {
name: "rps",
category: "fun",
description: "Rock Paper Scissors game. React to one of the emojis to play the game.",
usage: "rps",
run: async (client, message, args) => {
const embed = new RichEmbed()
.setColor("#ffffff")
.setFooter(message.guild.me.displayName, client.user.displayAvatarURL)
.setDescription("Add a reaction to one of these emojis to play the game!")
.setTimestamp();

const m = await message.channel.send(embed);
const reacted = await promptMessage(m, message.author, 30, chooseArr);

const botChoice = chooseArr[Math.floor(Math.random() * chooseArr.length)];

const result = await getResult(reacted, botChoice);
await m.clearReactions();

embed
.setDescription("")
.addField(result, `${reacted} vs ${botChoice}`);

m.edit(embed);

function getResult(me, clientChosen) {
if ((me === "🗻" && clientChosen === "✂") ||
(me === "📰" && clientChosen === "🗻") ||
(me === "✂" && clientChosen === "📰")) {
return "You won!";
} else if (me === clientChosen) {
return "It's a tie!";
} else {
return "You lost!";
}
}
}
}
2 changes: 1 addition & 1 deletion commands/fun/uptime.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
const min = Math.floor((ms / (1000 * 60)) % 60).toString()
const hrs = Math.floor((ms / (1000 * 60 * 60)) % 60).toString()
const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString()
return `${days.padStart(1, '0')} days, ${hrs.padStart(2, '0')} hours, ${min.padStart(2, '0')} minutes, ${sec.padStart(2, '0')} seconds, `
return `${days.padStart(1, '0')} days, ${hrs.padStart(2, '0')} hours, ${min.padStart(2, '0')} minutes, ${sec.padStart(2, '0')} seconds!! `
}

message.channel.send(`I have been online for: ${duration(bot.uptime)}`)
Expand Down
54 changes: 27 additions & 27 deletions commands/fun/write.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const fs = require('fs')

module.exports = {
name: "write",
category: "fun",
description: "Save 1 message in our database",
run: async (client, message, args) => {

// editedmessage = message.content.slice(6);
//console.log(args.join(" "));
let save = args.join(" ");


let msgs = JSON.parse(fs.readFileSync("./message.json", "utf8"));

msgs [message.guild.id]= {[message.author.id] : {
message: save
}};
await fs.writeFile("./message.json", JSON.stringify(msgs,null,4), (err) => {
if (err) throw err;
console.log(err);
message.channel.send("message saved!")
});

}

}
const fs = require('fs')

module.exports = {
name: "write",
category: "fun",
description: "Save 1 message in our database",
run: async (client, message, args) => {

// editedmessage = message.content.slice(6);
//console.log(args.join(" "));
let save = args.join(" ");


let msgs = JSON.parse(fs.readFileSync("./message.json", "utf8"));

msgs [message.guild.id]= {[message.author.id] : {
message: save
}};
await fs.writeFile("./message.json", JSON.stringify(msgs,null,4), (err) => {
if (err) throw err;
console.log(err);
message.channel.send("message saved!")
});

}

}
37 changes: 37 additions & 0 deletions commands/fun/xkcd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { RichEmbed } = require("discord.js");
const fetch = require("node-fetch"); //npm i node-fetch

module.exports = {
name: "xkcd",
description: "xkcd comics, get the latest or certain comic",
usage: "<search|latest> (id)",
category: "miscellaneous",
accessableby: "Members",
run: async (client, message, args) => {
if(!message.channel.nsfw) return message.channel.send("Please run this command in a `NSFW` channel.");
if((args[1] && isNaN(args[1])) || !["search", "latest"].includes(args[0])) return message.channel.send("`-xkcd <search|latest> (id)");

let search = args[1] ? `http://xkcd.com/${args[1]}/info.0.json` : "http://xkcd.com/info.0.json";
try {
message.channel.send("checking and sending.......").then(msg => {
fetch(search).then(res => res.json()).then(res => {
if(!res) return msg.edit("No results found for this comic, sorry!");
let { safe_title, img, day, month, year, num, alt} = res;

let embed = new RichEmbed()
.setColor("RANDOM")
.setDescription(alt ? alt : "*crickets* - No Description")
.setAuthor(`XKCD | ${safe_title} [${num}]`)
.setImage(img)
.setFooter(`Published ${day}/${month}/${year}`)

msg.edit(embed);
})

})
} catch(e) {
console.log(e)
return message.channel.send("looks like ive broken! Try again.");
}
}
}
78 changes: 78 additions & 0 deletions commands/game/csgo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const Discord = require('discord.js');
var request = require('request');
var cheerio = require('cheerio');
const { stripIndents } = require("common-tags");

function getStatData(location , $){

var selector = $('.stats-stat .value').eq(location).text();

var stat_array = $.parseHTML(selector);

var stat = 0;

if(stat_array == null || stat_array.lengh == 0){
return -1;

}else{
stat = stat_array[0].data;
}

return stat;
}

module.exports = {
name: "csgo",
description: "Displays a user's csgo stats!",
usage: "csgo <steamid or custom url>",
category: "game",
aliases: ["cs-go"] ,
run: async (client, message, args) => {
var UR_L = "http://csgo.tracker.network/profile/" + args[0];

if(!args[0]){
return message.channel.send("Please Enter a valid STEAMID64 or custom url");
}

request(UR_L, function(err, resp, body){

$ = cheerio.load(body);

var KD = getStatData(0, $);
if(KD == -1){
return message.channel.send("Invalid, make sure your profile is not private and you have entered a valid STEAMID64 or Custom URL!");
}

var WIN = getStatData(1, $);
var HS = getStatData(4, $);
var MONEY = getStatData(5, $);
var SCORE = getStatData(6, $);
var KILLS = getStatData(7, $);
var DEATHS = getStatData(8, $);
var MVP = getStatData(9, $);
var BS = getStatData(13, $);
var BD = getStatData(14, $);
var HR = getStatData(15, $);

var embed = new Discord.RichEmbed()
.setTitle("__***CSGO Stats***__")
.setURL(UR_L)
.addField("Current stats",stripIndents`
Total KD: __**${KD}**__
Total Win%: __**${WIN}**__
Total MVPs: __**${MVP}**__
Total Score: __**${SCORE}**__
Total Kills: __**${KILLS}**__
Total Deaths: __** ${DEATHS}**__
Total Bombs Set: __** ${BS}**__
Total Bombs Defused: __** ${BD}**__
Total Headshots: __**${HS}**__
Total Money Earned: __**${MONEY}**__
Total Hostages Rescued: __**${HR}**__`, true)
.addField("Powered by:", `**[csgo.tracker.network](http://csgo.tracker.network)**`, false)
.setTimestamp()
.setColor("0x#FF0000");
message.channel.send(embed);
}
)}
}
Loading

0 comments on commit ed07177

Please sign in to comment.