Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const prefix = "gen-";
- const randomWords = require('random-words');
- const request = require("request");
- const Discord = require("discord.js");
- const client = new Discord.Client();
- client.on('ready' , () => {
- client.user.setActivity("for gen-help | " + client.users.size + " users", { type: "watching"})
- });
- client.on('message', async message => {
- function cmd(commandName) {
- if(message.content.toLowerCase() === prefix + commandName.toLowerCase()) {
- return true;
- } else {
- return false;
- }
- };
- function cmdSW(commandName) {
- if(message.content.toLowerCase().startsWith(prefix + commandName.toLowerCase())) {
- return true;
- } else {
- return false;
- }
- };
- function send(messageToSend) {
- message.channel.send(messageToSend);
- };
- if(cmd("help")) {
- let embed = new Discord.RichEmbed()
- .setTitle("Help me dude!")
- .addField("Commands", "**" + prefix + "clan**: Generates a random clan name.\n**" + prefix + "urban**: Generates a random word and collects the urban dictionary definition for it.\n**" + prefix + "reddit**: Finds the latest post on a random subreddit.\n**" + prefix + "r/<subreddit>**: Finds the latest post on the chosen subreddit.\n**" + prefix + "u/<username>**: Finds the latest post from the chosen user.\n**" + prefix + "clan-suggest <suggestion>**: Sends a suggestion to the dev to add the words to the clan name generator database.\n**" + prefix + "dab**: DAB BOIIIIIIIIIII!\n**" + prefix + "oof**: OOF!")
- .setFooter("Bot made by some gay dude by the name of " + client.users.get("336366633750888448").tag)
- message.channel.send("Please wait, collecting help command...").then((msg)=>{
- setTimeout(function(){ msg.edit(embed) }, 1000);
- })
- }
- if(cmd("clan")) {
- let firstWord = ["", "Hazard", "Danger", "Reck", "Ultimate", "Damage", "Super", "Hard", "Multiple", "Edon", "Krak", "Zag"];
- let secondWord = ["", "Area", "Aim", "Rockers", "Snipez", "Λttackz", "Battering", "Hitz", "420", "Noscoperz", "Upz", "Λlarmz"];
- send("Your generated clan tag is: ``" + firstWord[Math.random() * 10 + 1 | 0] + secondWord[Math.random() * 10 + 1 | 0] + "``");
- };
- if(cmd("oof")) {
- setTimeout(function(){ message.react("🇴") }, 1000);
- setTimeout(function(){ message.react("🅾") }, 2000);
- setTimeout(function(){ message.react("🇫") }, 3000);
- }
- if(cmdSW("clan-suggest")) {
- let args = message.content.split(" ")
- let embed = new Discord.RichEmbed()
- if(args.length === 3) {
- embed.setTitle("New Suggestion! \:pencil2:\:newspaper:")
- embed.addField("New Suggestion from " + message.author.tag, message.content.slice(prefix.length + "clan-suggest ".length))
- client.channels.get("505490013811900437").send(embed)
- .then(function (message) {
- setTimeout(function(){ message.react("👍") }, 500);
- setTimeout(function(){ message.react("👎") }, 600);
- });
- send("Suggestion sent!")
- } else if (args.length < 3) {
- send("Incorrect Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
- } else if (args.length > 3) {
- send("Incorrent Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
- } else {
- send("Incorrent Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
- }
- };
- if(cmd("urban")) {
- let embed = new Discord.RichEmbed();
- var term = randomWords();
- request('http://api.urbandictionary.com/v0/define?term=' + term, function (error, response, body) {
- body = JSON.parse(body);
- if(body) {
- let defintionFixed1 = body["list"][0]["definition"].toString().split("]");
- let defintionFixed2 = defintionFixed1.toString().split("[");
- let defintionFixed3 = defintionFixed2.toString().split(",");
- let definition = defintionFixed3.join("");
- let thumbsUp = body["list"][0]["thumbs_up"];
- let thumbsDown = body["list"][0]["thumbs_down"];
- embed.setTitle(term.charAt(0).toUpperCase() + term.slice(1));
- embed.addField("Definition", definition + "\n\n[Urban Dictionary Page](https://www.urbandictionary.com/define.php?term=" + term + ")");
- embed.setFooter("\👍 " + thumbsUp + " | \👎 " + thumbsDown);
- send(embed);
- } else {
- send("Word Not Found!");
- }
- })
- };
- if(cmd("uptime")) {
- message.channel.send(process.uptime() + " seconds!")
- }
- if(cmd("dab")) {
- let dab_Database = ["", "<o/", "\\o>", "<o>", "\\o/", "ヽ( •_)ᕗ", "\( ͡° ͜ʖ ͡°) >"]
- let editLength = Math.random() * (Math.random() * 5 + 1 | 0) * 5 + 1 | 0
- let i = 0
- let dabs = "<o/ "
- while(i < editLength) {
- dabs = dabs + dab_Database[Math.random() * 6 + 1 | 0] + " "
- i = i + 1
- }
- let embed = new Discord.RichEmbed()
- .setTitle("OOF you dab? Well I dab too!")
- .addField("Here are your great generated dabs!", dabs)
- send(embed)
- }
- if(cmd("reddit")) {
- request('https://reddit.com/r/random/comments.json?limit=1', function (error, response, body) {
- body = JSON.parse(body);
- let embed = new Discord.RichEmbed();
- embed.setTitle("Reddit: " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"])
- embed.addField("Body: ", body["data"]["children"][0]["data"]["body"])
- if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
- embed.setImage(body["data"]["children"][0]["data"]["link_url"])
- }
- send(embed)
- });
- };
- if(cmdSW("r/")) {
- request('https://reddit.com/r/' + message.content.slice(prefix.length + "r/".length) + '/comments.json?limit=1', function (error, response, body) {
- body = JSON.parse(body);
- let embed = new Discord.RichEmbed();
- embed.setTitle("Reddit: " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"])
- embed.addField("Body: ", body["data"]["children"][0]["data"]["body"])
- if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
- embed.setImage(body["data"]["children"][0]["data"]["link_url"])
- }
- send(embed)
- })
- }
- if(cmdSW("u/")) {
- request('https://reddit.com/u/' + message.content.slice(prefix.length + "r/".length) + '/comments.json?limit=1', function (error, response, body) {
- body = JSON.parse(body);
- let embed = new Discord.RichEmbed();
- let status
- if(JSON.stringify(body) === '{"message":"Not Found","error":404}') {
- status = false;
- } else {
- status = true;
- }
- if(status) {
- embed.setTitle("Username: " + body["data"]["children"][0]["data"]["author"])
- embed.addField(body["data"]["children"][0]["data"]["author"] + "'s latest post in " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"], body["data"]["children"][0]["data"]["body"])
- if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
- embed.setImage(body["data"]["children"][0]["data"]["link_url"])
- }
- } else {
- embed.addField("Uh oh!", "Well this is embarrassing, that user does not seem to exist!")
- }
- send(embed)
- })
- }
- });
- app.use(express.static('public'));
- app.get('/', function(request, response) {
- response.sendFile(__dirname + "/views/home/index.html");
- });
- app.get('/gen-stable', function(request, response) {
- response.sendFile(__dirname + "/views/generator/stable/index.html");
- });
- app.get('/gen-beta', function(request, response) {
- response.sendFile(__dirname + "/views/generator/beta/index.html");
- });
- app.get('/setup', function(request, response) {
- response.sendFile(__dirname + "/views/setup/stable/index.html");
- });
- app.get('/image', function(request, response) {
- response.sendFile(__dirname + "/views/image/stable/index.html");
- });
- app.get('/inc', function(request, response) {
- response.sendFile(__dirname + "/views/inc/stable/index.html");
- });
- app.get('/dinosaur', function(request, response) {
- response.sendFile(__dirname + "/views/dinosaur/stable/index.html");
- });
- app.get('/sha-256', function(request, response) {
- response.sendFile(__dirname + "/views/misc/sha256/index.html");
- });
- app.get('/sprokket', function(request, response) {
- response.sendFile(__dirname + "/views/misc/sprokket/index.html");
- });
- const listener = app.listen(process.env.PORT, function() {
- console.log("yay the bot is actually online");
- });
- client.login(process.env.TOKEN);
Advertisement
RAW Paste Data
Copied
Advertisement