Advertisement
Guest User

xD.

a guest
Jul 22nd, 2019
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.22 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const fs = require('fs');
  3. const superagent = require("superagent");
  4. const config = JSON.parse(fs.readFileSync('config.json', 'utf8'));
  5. var client = new Discord.Client();
  6. const Enmap = require("enmap");
  7.  
  8. client.points = new Enmap({name: "treats"});
  9. client.on('ready', () => {
  10. const http = require('http');
  11. const express = require('express');
  12. const app = express();
  13.  
  14. app.listen(8080);
  15. setInterval(() => {
  16. http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
  17. }, 300000);
  18. console.log('Logged in as ' + client.user.username)
  19. client.user.setActivity('my hooman | a!help', { type: 'WATCHING' })
  20. })
  21.  
  22. var cmdmap = {
  23. say: cmd_say,
  24. help: cmd_help,
  25. ping: cmd_ping,
  26. rps: cmd_rps,
  27. eightball: cmd_8ball,
  28. die: cmd_die,
  29. shibe: cmd_shibe,
  30. about: cmd_about,
  31. serverinfo: cmd_serverinfo,
  32. shbtop: cmd_shbtop,
  33. kick: cmd_kick,
  34. ban: cmd_ban,
  35. report: cmd_report,
  36. suggest: cmd_suggest
  37. }
  38.  
  39. function cmd_help(msg, args) {
  40. const help = new Discord.RichEmbed()
  41. .setColor(0x3AFF00)
  42. .setAuthor("Tricks my hooman has taught me so far")
  43. .addField("Utility", "`ping`, `about`, `serverinfo`", true)
  44. .addField("Fun", "`bork`, `shbtop`, `rps`, `die`, `scream`", true)
  45. .addField("Mod", "`kick`, `ban`, `report`", true)
  46. .addField("Leveling", "`rank`, `lb`", true)
  47. .addField("What's new?", "```- The RPS command is finally fixed``` ```- The bork command may be discontinued?```", true)
  48. .setFooter("Bot in development | Alpha 0.1.5 | Rubber Duck Shobe and PBJF")
  49. .setTimestamp()
  50. msg.channel.send(help)
  51. }
  52.  
  53. function cmd_ping(msg, args) {
  54.  
  55. msg.channel.send("My ping is " + client.ping + "ms! :ping_pong:")
  56. }
  57.  
  58. module.exports.run = async (bot, message, args) =>{
  59. if (!args[0]) {
  60. message.reply("a!rps rock/paper/scissors");
  61. }
  62. }
  63.  
  64. function cmd_about(msg, args) {
  65. let bicon = client.user.displayAvatarURL;
  66. let botembed = new Discord.RichEmbed()
  67. .setDescription("Bot Information")
  68. .setColor(0x3AFF00)
  69. .setThumbnail(bicon)
  70. .addField("Bot Name", client.user.username)
  71. .addField("Created On", client.user.createdAt);
  72. msg.channel.send(botembed)
  73. }
  74.  
  75. function cmd_rps(msg, args) {
  76. module.exports.run = async (bot, message, args) =>{
  77. if (!args[0]) {
  78. message.reply("a!rps rock/paper/scissors");
  79. }
  80. }
  81. if (args[0]) {
  82. let computer_choice = rand(0,2);
  83. let user_choice = args[0] == "rock" ? 1 : args[0] == "paper" ? 2 : 0;
  84. if (computer_choice == user_choice) {
  85. msg.reply("It's a draw!");
  86. }
  87. else if (computer_choice < user_choice || computer_choice == 0 && user_choice == 2) {
  88. msg.reply("I won!");
  89. } else {
  90. msg.reply("You Won!");
  91. }
  92. }
  93. }
  94.  
  95. function eightballpicker() {
  96. var rand = ['Definetely.', 'Outlook good.', 'Probably.', 'Probably not.', 'Try again later.', 'Never'];
  97. return rand[Math.floor(Math.random()*rand.length)];
  98. }
  99.  
  100. function cmd_8ball(msg, args) {
  101. msg.channel.send("<@" + msg.author.id + ">, the magic 8 ball says: ```" + eightballpicker() + "```")
  102. }
  103.  
  104. function cmd_die(msg, args, a){
  105. a = Math.floor(Math.random() * (1 - 6) + 6)
  106. msg.channel.send("🎲 Your die rolled " + a)
  107. }
  108.  
  109.  
  110. function cmd_shibe(msg, args) {
  111. let body = superagent.get(`https://dog.ceo/api/breeds/shiba/images/random`);
  112. let dogembed = new Discord.RichEmbed()
  113. .setColor("#ff9900")
  114. .setTitle("varr bootiful")
  115. .setImage(body.message);
  116. msg.channel.send(dogembed);
  117.  
  118. }
  119.  
  120. function cmd_say(msg, args, channel) {
  121. var author = msg.member
  122. if(author.id == config.owner) {
  123. msg.channel.send(args.join(' '))
  124. }
  125. if(author.id != config.owner){
  126. const denied = new Discord.RichEmbed()
  127. .setDescription("Access Denied. Nice try though.")
  128. .setColor(0xFF0000)
  129. msg.channel.send(denied);
  130. }
  131. }
  132.  
  133. function cmd_shbtop(msg, args){
  134. const shbembd = new Discord.RichEmbed()
  135. .setColor(0xfcd0a1)
  136. .setAuthor("such achieve", "https://cdn.discordapp.com/emojis/464375164646195226.png")
  137. .addField("Easy: 481", "Achieved by Doctor Mlem Inin (<@276797038669332480>)")
  138. .addField("Medium: ~", "This could be achieved by you!")
  139. .addField("Hard: ~", "This could be achieved by you!")
  140. .addField("Impossible: ~", "This could be achieved by you!")
  141. .setFooter("Submit your scores!")
  142. msg.channel.send(shbembd)
  143. }
  144.  
  145. function rand(msg, low, high) {
  146. let rand = Math.random() * (high + 1 - low) + low | 0
  147. }
  148.  
  149. function cmd_serverinfo(msg, args) {
  150. let sicon = msg.guild.iconURL;
  151. let serverembed = new Discord.RichEmbed()
  152. .setDescription("Server Information")
  153. .setColor("0x3AFF00")
  154. .setThumbnail(sicon)
  155. .addField("Server Name", msg.guild.name)
  156. .addField("Created On", msg.guild.createdAt)
  157. .addField("You Joined", msg.member.joinedAt)
  158. .addField("Total Members", msg.guild.memberCount);
  159. console.log(msg.author.tag + ' requested help... who reads these logs lol' )
  160. msg.channel.send(serverembed);
  161. }
  162.  
  163. function cmd_suggest(msg, args){
  164. msg.author.send("✅ Thanks for your suggestion!")
  165. let repch = msg.channels.find(`name`, "rs");
  166. repch.send('Suggestion by <@' + msg.author.id + '> with ID ' + msg.author.id + '. The user suggested:' + args.join(' '))
  167. }
  168.  
  169. function cmd_kick(msg, args) {
  170. if (!msg.member.hasPermission("KICK_MEMBERS")) return msg.channel.send("hoo let you?");
  171. if (msg.member.hasPermission("KICK_MEMBERS")) {
  172. const user = msg.mentions.users.first();
  173. if (user) {
  174. const member = msg.guild.member(user);
  175. if (member) {
  176. member.kick('Kicked by ${msg.author.tag}').then(() => {
  177. msg.reply(`kicced ${user.tag}`);
  178. let incidentchannel = msg.guild.channels.find(`name`, "warnings-and-bans");
  179. let kickEmbed = new Discord.RichEmbed()
  180. .setDescription("Kick")
  181. .setColor("#bc0000")
  182. .addField("Kicked user", `${user.tag} with ID ${user.id}`)
  183. .addField("Staff", `<@${msg.author.id}> with ID ${msg.author.id}`)
  184. .addField("Kicked for", member.kick.reason)
  185. .addField("Time", msg.createdAt)
  186. incidentchannel.send(kickEmbed)
  187. }).catch(err => {
  188. msg.reply('cant kicc');
  189. console.error(err);
  190. });
  191. } else {
  192. msg.reply('404 puppah not found');
  193. }
  194. } else {
  195. msg.reply('what shoober?');
  196. }
  197. }
  198. }
  199.  
  200. function cmd_ban(msg, args) {
  201. if (!msg.member.hasPermission("BAN_MEMBERS")) return msg.channel.send("hoo let you?");
  202. if (msg.member.hasPermission("BAN_MEMBERS")) {
  203. const user = msg.mentions.users.first();
  204. if (user) {
  205. const member = msg.guild.member(user);
  206. if (member) {
  207. member.ban('Banned by ${msg.author.tag}').then(() => {
  208. msg.reply(`baned ${user.tag}`);
  209. let incidentchannel = msg.guild.channels.find(`name`, "warnings-and-bans");
  210. let banEmbed = new Discord.RichEmbed()
  211. .setDescription("Ban")
  212. .setColor("#bc0000")
  213. .addField("Banned user", `${user.tag} with ID ${user.id}`)
  214. .addField("Staff", `<@${msg.author.id}> with ID ${msg.author.id}`)
  215. .addField("Banned for", member.ban.reason)
  216. .addField("Time", msg.createdAt)
  217. incidentchannel.send(banEmbed)
  218. }).catch(err => {
  219. msg.reply('cant ban');
  220. console.error(err);
  221. });
  222. } else {
  223. msg.reply('404 puppah not found');
  224. }
  225. } else {
  226. msg.reply('what shoober?');
  227. }
  228. }
  229. }
  230.  
  231. function cmd_report(msg, args, channel) {
  232. msg.author.send("✅ Your report has been sent. You may want to delete your command message for anonimity.")
  233. let repch = msg.guild.channels.find(`name`, "reports");
  234. repch.send('Report by <@' + msg.author.id + '> with ID ' + msg.author.id + '. The user reported:' + args.join(' '))
  235. }
  236.  
  237. client.on('message', (msg) => {
  238.  
  239. const swearWords = ["swear1", "djwdchjswbcdjws", "frak", "shit"]; //include whatever you like
  240. if( swearWords.some(word => msg.content.includes(word)) ) {
  241. msg.delete();
  242. msg.reply(" we want to keep this server child-friendly. However, I sniffed some swear words in your message. If this was an error, contact the developers.")
  243. }
  244.  
  245. if (msg.author.bot) return;
  246. const key = `${msg.guild.id}-${msg.author.id}`;
  247. client.points.ensure(`${msg.guild.id}-${msg.author.id}`, {
  248. user: msg.author.id,
  249. guild: msg.guild.id,
  250. points: 0,
  251. });
  252. client.points.inc(key, "points");
  253.  
  254. const clean = text => {
  255. if (typeof(text) === "string")
  256. return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
  257. else
  258. return text;
  259. }
  260. const pargs = msg.content.split(" ").slice(1);
  261. if (msg.content.startsWith(config.prefix + "eval")) {
  262. if (msg.author.id != config.owner) { if (msg.author.id != config.beta) {return msg.channel.send("aaaaAAAAAAaaaa! this command is very such reserved!")} }
  263. try {
  264. const code = pargs.join(" ");
  265. let evaled = eval(code);
  266.  
  267. if (typeof evaled !== "string")
  268. evaled = require("util").inspect(evaled);
  269.  
  270. msg.channel.send(clean(evaled), {code:"xl"});
  271. } catch (err) {
  272. msg.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
  273. }
  274. }
  275.  
  276. if (msg.content === "a!rank") {
  277. const key = `${msg.guild.id}-${msg.author.id}`;
  278. return msg.channel.send(`${client.points.get(key, "points")} treets, such amaze \n You can exchange treets for dogecoin, contact PBJF or Rubber \n 1 treat = 1 dogecoin`);
  279. }
  280.  
  281.  
  282.  
  283. if(msg.content === "a!lb") {
  284. const filtered = client.points.filter( p => p.guild === msg.guild.id ).array();
  285. const sorted = filtered.sort((a, b) => a.points - b.points);
  286. const top10 = sorted.splice(0, 10);
  287. const leademb = new Discord.RichEmbed()
  288. .setTitle("Leadehboard")
  289. .setFooter("top 10 many reach")
  290. .setColor(0x00AE86);
  291. for(const data of top10) {
  292. leademb.addField(client.users.get(data.user).tag, `${data.points} treetos`);
  293. }
  294. return msg.channel.send(leademb);
  295. }
  296.  
  297. var cont = msg.content,
  298. author = msg.member,
  299. chan = msg.channel,
  300. guild = msg.guild
  301.  
  302. if (!msg.guild) return;
  303. if (msg.content === 'a!scream') {
  304. if (msg.member.voiceChannel) {
  305. msg.member.voiceChannel.join()
  306. .then(connection => {
  307. const dispatcher = connection.playArbitraryInput('https://cdn.glitch.com/f2789fb5-15e2-4225-8087-db3a587c4782%2FaaAAaaaaAa.mp3?1539361768809');
  308. dispatcher.on('end', () => {
  309. msg.member.voiceChannel.leave()
  310. });
  311. })
  312. .catch(console.log);
  313. } else {
  314. msg.channel.send("Oi! You need to be in a voice channel ~~for me to destroy your ears~~ to hear me!")
  315. }
  316. }
  317.  
  318. if (msg.content === 'a!bork') {
  319. const borkEmbed = new Discord.RichEmbed()
  320. .setColor(0x3AFF00)
  321. .setAuthor("heaven sounds", "http://www.stickpng.com/assets/thumbs/584b1a17526b8582f1dc7d31.png")
  322. .addField("**[1]** Gourmet Borks by Arf", "Video: https://www.youtube.com/watch?v=xrm8ggyYXdw", true)
  323. .addField("**[2]** Gabe the Bork Engine by Rapid Liquid", "Video: https://youtu.be/Ye6TI_iYEV0", true)
  324. .addField("**[3]** Rainbow Tyledog by Rapid Liquid (Shibe Ball Menu Theme)", "Video: https://youtu.be/ites_HIfo8E", true)
  325. .setFooter("Command usage: a!bork <remix number> | Page 1/1, for more pages a!bork p<page number>")
  326. msg.channel.send(borkEmbed)
  327. }
  328.  
  329. if (msg.content === 'a!bork 1') {
  330. if (msg.member.voiceChannel) {
  331. msg.member.voiceChannel.join()
  332. .then(connection => {
  333. console.log('${msg.author.tag} tried cmd.listen.bork.1 and working === true')
  334. const dispatcher = connection.playArbitraryInput('https://cdn.glitch.com/f2789fb5-15e2-4225-8087-db3a587c4782%2FGourmet%20Borks.mp3?1539524027588');
  335. msg.channel.send("Now playing \"Gourmet Borks\" by Arf. \n If the song does not play, switch voice channels and try again")
  336. dispatcher.on('end', () => {
  337. msg.member.voiceChannel.leave()
  338. });
  339. dispatcher.on('error', borkerr => {
  340. console.log(borkerr);
  341. msg.channel.send("Oh, no! A wild shibe has been chewing on our power cables. \nIf this persists, contact Rubber Duck Shobe or PBJF (ping PBJF as much as you like, logs are valid only 2 hours BTW). \nError info:\`" + borkerr + "\`");
  342. msg.member.voiceChannel.leave()
  343. });
  344. })
  345. .catch(console.log);
  346. } else {
  347. console.log(msg.author.tag + ' tried cmd.listen.bork.1 but vc.joined === false')
  348. }
  349. }
  350.  
  351. if (msg.content === 'a!bork 2') {
  352. if (msg.member.voiceChannel) {
  353. msg.member.voiceChannel.join()
  354. .then(connection => {
  355. console.log('${msg.author.tag} tried cmd.listen.bork.2 and working === true')
  356. const dispatcher = connection.playArbitraryInput('https://cdn.glitch.com/f2789fb5-15e2-4225-8087-db3a587c4782%2FGabeTheBorkEngine.mp3?1540836065697');
  357. msg.channel.send("Now playing \"Gabe the Bork Engine\" by Rapid Liquid. \n If the song does not play, switch voice channels and try again")
  358. dispatcher.on('end', () => {
  359. msg.member.voiceChannel.leave()
  360. });
  361. dispatcher.on('error', borkerr => {
  362. console.log(borkerr);
  363. msg.channel.send("Oh, no! A wild shibe has been chewing on our power cables. \nIf this persists, contact Rubber Duck Shobe or PBJF (ping PBJF as much as you like, logs are valid only 2 hours BTW). \nError info:\`" + borkerr + "\`");
  364. msg.member.voiceChannel.leave()
  365. });
  366. })
  367. .catch(console.log);
  368. } else {
  369. console.log(msg.author.tag + ' tried cmd.listen.bork.2 but vc.joined === false')
  370. }
  371. }
  372.  
  373. if (msg.content === 'a!bork 3') {
  374. if (msg.member.voiceChannel) {
  375. msg.member.voiceChannel.join()
  376. .then(connection => {
  377. console.log('${msg.author.tag} tried cmd.listen.bork.3 and working === true')
  378. const dispatcher = connection.playArbitraryInput('https://cdn.glitch.com/f2789fb5-15e2-4225-8087-db3a587c4782%2FRainbowTyledog.mp3?1540836065697');
  379. msg.channel.send("Now playing \"Rainbow Tyledog\" by Rapid Liquid. \n If the song does not play, switch voice channels and try again")
  380. dispatcher.on('end', () => {
  381. msg.member.voiceChannel.leave()
  382. });
  383. dispatcher.on('error', borkerr => {
  384. console.log(borkerr);
  385. msg.channel.send("Oh, no! A wild shibe has been chewing on our power cables. \nIf this persists, contact Rubber Duck Shobe or PBJF (ping PBJF as much as you like, logs are valid only 2 hours BTW). \nError info:\`" + borkerr + "\`");
  386. msg.member.voiceChannel.leave()
  387. });
  388. })
  389. .catch(console.log);
  390. } else {
  391. console.log(msg.author.tag + ' tried cmd.listen.bork.3 but vc.joined === false')
  392. }
  393. }
  394.  
  395. if (author.id != client.user.id && cont.startsWith(config.prefix)) {
  396. var invoke = cont.split(' ')[0].substr(config.prefix.length),
  397. args = cont.split(' ').slice(1)
  398. if (invoke in cmdmap){
  399. cmdmap[invoke](msg, args)
  400. }
  401. }
  402. })
  403.  
  404. client.login('NjAxMDI2OTEyNjY3ODI4MjM1.XTHDTA.WvvxQHJkoOE0sHskIrPGYVn0C30')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement