Advertisement
Ryyan

Untitled

Jul 5th, 2019
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.27 KB | None | 0 0
  1. // Load up the discord.js library
  2. const Discord = require("discord.js");
  3.  
  4. // This is your client. Some people call it `bot`, some people call it `self`,
  5. // some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
  6. // this is what we're refering to. Your client.
  7. const client = new Discord.Client();
  8.  
  9. // Here we load the config.json file that contains our token and our prefix values.
  10. const config = require("./config.json");
  11. // config.token contains the bot's token
  12. // config.prefix contains the message prefix
  13.  
  14. const weather = require("weather-js");
  15.  
  16. const moment = require('moment');
  17.  
  18. const fs = require("fs");
  19.  
  20. const fsn = require('fs-nextra');
  21.  
  22. const cpuStat = require("cpu-stat");
  23.  
  24. const express = require('express');
  25. const keepalive = require('express-glitch-keepalive');
  26.  
  27. const app = express();
  28.  
  29. app.use(keepalive);
  30.  
  31. app.get('/', (req, res) => {
  32. res.json('This bot should be online! uptimerobot will keep it alive');
  33. });
  34. app.get("/", (request, response) => {
  35. response.sendStatus(200);
  36. });
  37. app.listen(process.env.PORT);
  38.  
  39.  
  40.  
  41.  
  42.  
  43. client.on("ready", () => {
  44. // This event will run if the bot starts, and logs in, successfully.
  45. console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
  46. // Example of changing the bot's playing game to something useful. `client.user` is what the
  47. // docs refer to as the "ClientUser".
  48. client.user.setPresence({
  49. game: {
  50. name: `over ${client.guilds.size} servers!`,
  51. type: "watching",
  52. url: "https://www.twitch.tv/monstercat"
  53. }
  54. });
  55. });
  56.  
  57.  
  58.  
  59.  
  60. client.on("guildCreate", guild => {
  61. // This event triggers when the bot joins a guild.
  62. console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
  63. client.user.setActivity(`Serving ${client.guilds.size} servers`);
  64. });
  65.  
  66. client.on("guildDelete", guild => {
  67.  
  68. // this event triggers when the bot is removed from a guild.
  69. console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
  70. client.user.setActivity(`Serving ${client.guilds.size} servers`);
  71. });
  72.  
  73. client.on('guildMemberRemove', function (message) {
  74.  
  75. const guild2 = message.guild;
  76. const member2 = message;
  77. const membercount2 = client.users.size;
  78.  
  79. let logleftmemberembed = new Discord.RichEmbed()
  80. .setTitle(`A user just left the server! ${member2.user.tag}!`)
  81.  
  82.  
  83. member2.guild.channels.find(`name`, `ใ€Œ๐Ÿ“Žใ€logs`).send(logleftmemberembed)
  84. member2.guild.channels.find(`name`, `ใ€Œโœˆใ€airport`).send(`:( ${member2.user.tag} just left the server! we will miss you! i also dm'd them!`)
  85. member2.send(`Awww! You left ${guild2.name}! we hope you join again!`)
  86. member2.send(`AWww! you left our server!`)
  87. });
  88.  
  89. client.on("guildMemberAdd", function (message) {
  90.  
  91. const guild = message.guild;
  92. const member = message;
  93. const membercount = client.users.size;
  94.  
  95. let lognewmemberembed = new Discord.RichEmbed()
  96. .setTitle(`A new user has joined the guild. ${member.user.tag}!`)
  97.  
  98.  
  99. member.guild.channels.find(`name`, `ใ€Œ๐Ÿ“Žใ€logs`).send(lognewmemberembed)
  100. member.guild.channels.find(`name`, `ใ€Œโœˆใ€airport`).send(`Welcome to our server ${member} You are our ${guild.memberCount} member! and you were created on ${member.user.createdAt}`)
  101. member.send(`Welcome ${member.user} to ${guild.name} we hope you enjoy your time here.`)
  102. });
  103.  
  104.  
  105.  
  106. client.on("message", async message => {
  107. // This event will run on every single message received, from any channel or DM.
  108.  
  109. // It's good practice to ignore other bots. This also makes your bot ignore itself
  110. // and not get into a spam loop (we call that "botception").
  111. if (message.author.bot) return;
  112.  
  113. // Also good practice to ignore any message that does not start with our prefix,
  114. // which is set in the configuration file.
  115. if (message.content.indexOf(config.prefix) !== 0) return;
  116.  
  117. // Here we separate our "command" name, and our "arguments" for the command.
  118. // e.g. if we have the message "+say Is this the real life?" , we'll get the following:
  119. // command = say
  120. // args = ["Is", "this", "the", "real", "life?"]
  121. const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  122. const command = args.shift().toLowerCase();
  123.  
  124. if (command === "say") {
  125. // makes the bot say something and delete the message. As an example, it's open to anyone to use.
  126. // To get the "message" itself we join the `args` back into a string with spaces:
  127. const sayMessage = args.join(" ");
  128. // Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
  129. message.delete().catch(O_o => {});
  130. // And we get the bot to say the thing:
  131. message.channel.send(sayMessage);
  132. }
  133. if (command === "kill") {
  134. let killed = message.mentions.members.first();
  135. if (!killed) return message.channel.send("Please provide a user to kill!")
  136.  
  137. ballMessage = message.content.slice(9);
  138. number = 2;
  139. var random = Math.floor(Math.random() * (number - 1 + 1)) + 1;
  140. switch (random) {
  141. case 1:
  142. message.channel.send(`${message.author} killed all of ${killed} family members.`)
  143. break;
  144. case 2:
  145. message.reply(`${message.author} used a sharp axe to kill ${killed}`);
  146. break;
  147. }
  148.  
  149.  
  150.  
  151.  
  152. }
  153. if (command === "help") {
  154. const infoList = fs.readFileSync("./info.txt", "utf8");
  155. let bicon = client.user.displayAvatarURL;
  156. const pidor = message.guild.members.get(args[0]) || message.member;
  157.  
  158.  
  159.  
  160. let infoEmbed = new Discord.RichEmbed()
  161. .setColor("00ff00")
  162. .setTitle("**__Info commands__**")
  163. .setDescription(infoList)
  164.  
  165. pidor.send(infoEmbed);
  166.  
  167.  
  168. let supEmbed = new Discord.RichEmbed()
  169. .setColor("#00ff00")
  170. .setTitle("Support")
  171. .setImage("https://cdn.discordapp.com/avatars/291221132256870400/4f71fea454b62405b55f2fe0d8e7db0c.png?size=2048")
  172. .setDescription("If you need help with something feel free to join the [Support Server](https://discord.gg/wJ2ARmw)")
  173. .setFooter("<> means required, [] means optional")
  174. .setTimestamp()
  175.  
  176. pidor.send(supEmbed)
  177.  
  178. let chanEmbed = new Discord.RichEmbed()
  179. .setTitle("Help")
  180. .setColor("#0ff00")
  181. .setFooter(`Help command used by: ${pidor.user.username}`)
  182. .setDescription(`${pidor} Check your DMs`);
  183.  
  184. message.channel.send(chanEmbed).then(msg => {
  185. msg.delete(5000)
  186. });
  187.  
  188. message.delete();
  189.  
  190. }
  191.  
  192. if (command === "meme") {
  193. const randomPuppy = require('random-puppy');
  194.  
  195.  
  196. let reddit = [
  197. "meme",
  198. "dankmemes",
  199. "dankmeme"
  200. ]
  201.  
  202. let subreddit = reddit[Math.floor(Math.random() * reddit.length)];
  203.  
  204. message.channel.startTyping();
  205.  
  206. randomPuppy(subreddit).then(async url => {
  207. await message.channel.send({
  208. files: [{
  209. attachment: url,
  210. name: 'meme.png'
  211. }]
  212. }).then(() => message.channel.stopTyping());
  213. }).catch(err => console.error(err));
  214.  
  215. };
  216.  
  217. if (command === "ticket") {
  218. const cooldown = new Set();
  219. let args = message.content.split(' ').slice(1).join(' ');
  220. message.delete();
  221. if (cooldown.has(message.author.id && message.guild.id)) {
  222. return message.channel.send('**[COOLDOWN]** Sending tickets has **5 Minutes** Cooldown!');
  223. }
  224. if (args.length < 1) {
  225. return message.channel.send(`You must give me something to report first ${message.author}`);
  226. }
  227. cooldown.add(message.author.id && message.guild.id);
  228. setTimeout(() => {
  229. cooldown.delete(message.author.id && message.guild.id);
  230. }, 300000);
  231. let guild = message.guild;
  232. const cnl = message.guild.channels.find(channel => channel.name === "ใ€Œ๐Ÿ’ปใ€staff-chat");
  233. message.channel.send(`Hey, ${message.author}, we got your report! We will reply soon as possible! Here is the full ticket:`);
  234. const embed2 = new Discord.RichEmbed()
  235. .setAuthor(`Ticket from ${message.author.tag}`, message.author.displayAvatarURL)
  236. .addField('Ticket:', `**Tickets's Author:** ${message.author.tag}\n**Server:** ${guild.name}\n**Full ticket:** ${args}`)
  237. .setThumbnail(message.author.displayAvatarURL)
  238. .setFooter(`${moment().format('MMMM Do YYYY, h:mm:ss a')}`)
  239. .setColor(16711728);
  240. message.channel.send({
  241. embed: embed2
  242. });
  243. const embed = new Discord.RichEmbed()
  244. .setAuthor(`Ticket from ${message.author.tag}`, message.author.displayAvatarURL)
  245. .addField('Ticket:', `**Report's Author:** ${message.author.tag}\n**Server:** ${guild.name}\n**Full report:** ${args}`)
  246. .setThumbnail(message.author.displayAvatarURL)
  247. .setColor("#ffd700");
  248. cnl.send({
  249. embed
  250. })
  251. }
  252.  
  253.  
  254. if (command === "announce") {
  255.  
  256. if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
  257.  
  258. let announcementchannel = message.guild.channels.find(channel => channel.name === "ใ€Œ๐Ÿ“Œใ€announcements");
  259.  
  260. let sayMessage = args.join(" ");
  261.  
  262. let announcembed = new Discord.RichEmbed()
  263. .setTitle("Important announcement:")
  264. .setDescription(sayMessage)
  265. .setFooter(`announcement made by ${message.author.tag}!`, message.author.displayAvatarURL)
  266.  
  267. announcementchannel.send(announcembed)
  268.  
  269. message.delete().catch(O_o => {});
  270.  
  271. }
  272.  
  273. if (command === "stats") {
  274. let {
  275. version
  276. } = require("discord.js");
  277.  
  278. cpuStat.usagePercent(function (err, percent, seconds) {
  279. if (err) {
  280. return console.log(err);
  281. }
  282.  
  283. let secs = Math.floor(client.uptime % 60);
  284. let days = Math.floor((client.uptime % 31536000) / 86400);
  285. let hours = Math.floor((client.uptime / 3600) % 24);
  286. let mins = Math.floor((client.uptime / 60) % 60);
  287.  
  288. //let duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
  289. let embedStats = new Discord.RichEmbed()
  290. .setTitle("*** Stats ***")
  291. .setColor("#00ff00")
  292. .addField("โ€ข Mem Usage", `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} / ${(os.totalmem() / 1024 / 1024).toFixed(2)} MB`, true)
  293. .addField("โ€ข Uptime ", `${hours}h ${mins}m`, true) //`${duration}`, true)
  294. .addField("โ€ข Users", `${client.users.size.toLocaleString()}`, true)
  295. .addField("โ€ข Servers", `${client.guilds.size.toLocaleString()}`, true)
  296. .addField("โ€ข Channels ", `${client.channels.size.toLocaleString()}`, true)
  297. .addField("โ€ข Discord.js", `v${version}`, true)
  298. // .addField("โ€ข Node", `${process.version}`, true)
  299. .addField("โ€ข CPU", `\`\`\`md\n${os.cpus().map(i => `${i.model}`)[0]}\`\`\``)
  300. .addField("โ€ข CPU usage", `\`${percent.toFixed(2)}%\``, true)
  301. .addField("โ€ข Arch", `\`${os.arch()}\``, true)
  302. .addField("โ€ข Platform", `\`\`${os.platform()}\`\``, true)
  303. .setFooter("Tom The Bot stats")
  304.  
  305. message.channel.send(embedStats)
  306. })
  307.  
  308. }
  309.  
  310. if (command === "weather") {
  311. weather.find({
  312. search: args.join(" "),
  313. degreeType: "F"
  314. }, function (err, result) { // Make sure you got that args.join part
  315. if (err) message.channel.send(err);
  316.  
  317. // We also want them to know if a place they enter is invalid.
  318. if (result === undefined || result.length === 0) {
  319. message.channel.send("**Please enter a valid location.**") // This tells them that the location they entered is invalid.
  320. return; // This exists the code so that the rest doesn't run.
  321. }
  322.  
  323. // Variables
  324. var current = result[0].current; // This is a varable for the current part of the JSON output.
  325. var location = result[0].location; // This is a variable for the location part of the JSON output.
  326.  
  327. // Let's use an embed for this.
  328. const embed = new Discord.RichEmbed()
  329. .setDescription(`**${current.skytext}**`) // This is the text of what they sky looks like.
  330. .setAuthor(`Weather for ${current.observationpoint}`) // This shows the current location of the weather.
  331. .setThumbnail(current.imageURL) // This sets the thumbnail of the embed
  332. .setColor(0x00AE86) // This sets the color of the embed, you can chnage this to whatever you want, if you use a hex editor, make sure to put 0x in front of it.
  333. .addField('Timezone', `UTC${location.timezone}`, true) // This is the first field, it shows the timezone.
  334. .addField('Degree Type', location.degreetype, true) // This is the filed that shows the degree type, and its inline.
  335. .addField('Temperature', `${current.temperature} Degrees`, true)
  336. .addField('Feels Like', `${current.feelslike} Degrees`, true)
  337. .addField('Winds', current.winddisplay, true)
  338. .addField('Humidity', `${current.humidity}%`, true)
  339. .addField("Date:", message.createdAt.toLocaleString())
  340.  
  341. // Now, lets display it when called
  342. message.channel.send({
  343. embed
  344. });
  345.  
  346. });
  347. }
  348.  
  349. if (command === "uptime") {
  350.  
  351.  
  352. let totalSeconds = (client.uptime / 1000);
  353. let days = Math.floor(totalSeconds / 86400);
  354. let hours = Math.floor(totalSeconds / 3600);
  355. totalSeconds %= 3600;
  356. let minutes = Math.floor(totalSeconds / 60);
  357. let seconds = totalSeconds % 60;
  358.  
  359. let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
  360.  
  361. message.channel.send(uptime)
  362. }
  363.  
  364. if (command === "8ball") {
  365. let question = message.content.split(/\s+/g).slice(1).join(" ");
  366.  
  367. if (!question) {
  368. return message.channel.send('You must provide a question! **Usage: !!!8ball <question>**');
  369.  
  370. }
  371.  
  372. var answer = ['It is certain',
  373. 'It is decidedly so',
  374. 'Without a doubt',
  375. 'Yes, definitely',
  376. 'You may rely on it',
  377. 'As I see it, yes',
  378. 'Most likely',
  379. 'Outlook good',
  380. 'Yes',
  381. 'Signs point to yes',
  382. 'Reply hazy try again',
  383. 'Ask again later',
  384. 'Better not tell you now',
  385. 'Cannot predict now',
  386. 'Concentrate and ask again',
  387. 'Don\'t count on it',
  388. 'My reply is no',
  389. 'My sources say no',
  390. 'Outlook not so good',
  391. 'Very doubtful'
  392. ];
  393. const ballEmbed = new Discord.RichEmbed()
  394. .setAuthor(question)
  395. .setDescription(answer[Math.round(Math.random() * (answer.length - 1))] + '.')
  396. .setColor(0x646770)
  397. .setTimestamp();
  398. message.channel.send(ballEmbed);
  399.  
  400. }
  401. if (command === "poll") {
  402. if (args.length == 0) {
  403. return message.channel.send({
  404. embed: {
  405. "title": "Help",
  406. "fields": [{
  407. "name": "Simple Poll (Yes/No)",
  408. "value": "`poll` - this menu\n`poll <time> <question>` - poll with timed end. Time should be entered in seconds, default - 1 hour"
  409. },
  410. {
  411. "name": "Multi-choice Poll",
  412. "value": "`mpoll <time> <question> <a1>...<a9>` - poll with multi-choice and timed end. Time should be entered in seconds, default - 1 hour"
  413. }
  414. ],
  415. "color": 3264944,
  416. "footer": {
  417. "text": message + ""
  418. }
  419. }
  420. });
  421. }
  422.  
  423. let time1 = args.shift();
  424. let question = args.join(" ");
  425.  
  426. if (!isNaN(time1)) {
  427. time1 = time1 * 1000;
  428. } else {
  429. question = time1 + " " + question;
  430. time1 = 3600 * 1000;
  431. }
  432.  
  433. message.channel.send({
  434. embed: {
  435. "title": `Poll by ${message.author.username}`,
  436. "description": question + "",
  437. "color": "3264944",
  438. "footer": {
  439. "text": "Poll Created By " + message.author.username,
  440. "icon_url": message.author.avatarURL
  441. }
  442. }
  443. }).then(async function (msg) {
  444. await msg.react('๐Ÿ‘');
  445. await msg.react('๐Ÿ‘Ž');
  446.  
  447. var reactions = await msg.awaitReactions(reaction => reaction.emoji.name === '๐Ÿ‘' || reaction.emoji.name === '๐Ÿ‘Ž', {
  448. time: time1
  449. });
  450.  
  451. var yes = "Most voted ๐Ÿ‘";
  452. var no = "Most voted ๐Ÿ‘Ž";
  453. var tie = "Tie!";
  454. var end;
  455.  
  456. if (msg.reactions.get('๐Ÿ‘').count - 1 > msg.reactions.get('๐Ÿ‘Ž').count - 1) {
  457. end = yes
  458. } else if (msg.reactions.get('๐Ÿ‘').count - 1 < msg.reactions.get('๐Ÿ‘Ž').count - 1) {
  459. end = no
  460. } else if (msg.reactions.get('๐Ÿ‘').count - 1 == msg.reactions.get('๐Ÿ‘Ž').count - 1) {
  461. end = tie
  462. }
  463.  
  464. msg.channel.send({
  465. embed: {
  466. "title": question,
  467. "description": `**Poll ended!** \n\n๐Ÿ‘: ${msg.reactions.get('๐Ÿ‘').count-1}\n***----------***\n๐Ÿ‘Ž: ${msg.reactions.get('๐Ÿ‘Ž').count-1}`,
  468. "color": 3264944,
  469. "footer": {
  470. "text": end
  471. }
  472. }
  473. })
  474. });
  475.  
  476. }
  477.  
  478. if (command === "coinflip") {
  479. let = headembed = new Discord.RichEmbed()
  480. .setTitle(`${message.author.username}`)
  481. .setDescription(`heads!`)
  482. .setFooter(`Tommy bot! | Replying to ${message.author.username}`)
  483. .setTimestamp()
  484.  
  485. let tailsembed = new Discord.RichEmbed()
  486. .setTitle(`Coinflip`)
  487. .setDescription(`Tails!`)
  488. .setFooter(`Tommy bot! | Replying to ${message.author.username}`)
  489. .setTimestamp()
  490.  
  491. ballMessage = message.content.slice(9);
  492. number = 2;
  493. var random = Math.floor(Math.random() * (number - 1 + 1)) + 1;
  494. switch (random) {
  495.  
  496.  
  497. case 1:
  498. message.channel.send(tailsembed)
  499. break;
  500. case 2:
  501. message.channel.send(headembed)
  502. break;
  503. }
  504. }
  505.  
  506. if (command === "rps") {
  507. let rock2 = ['Paper! I win!', 'Scissors! You win!']
  508. let rock1 = Math.floor(Math.random() * rock2.length);
  509.  
  510. let paper2 = ['Rock! You win!', 'Scissors! I win!']
  511. let paper1 = Math.floor(Math.random() * paper2.length);
  512.  
  513. let scissors2 = ['Rock! I win', 'Paper! You win!']
  514. let scissors1 = Math.floor(Math.random() * scissors2.length);
  515.  
  516. let rock = new Discord.RichEmbed()
  517. .setAuthor('Rock, Paper, Scissors')
  518. .setColor(0x6B5858)
  519. .addField('You choose', `${args[0]}`)
  520. .addField('I choose', rock2[rock1])
  521. .setTimestamp()
  522.  
  523. let paper = new Discord.RichEmbed()
  524. .setAuthor('Rock, Paper, Scissors')
  525. .setColor(0x6B5858)
  526. .addField('You choose', `${args[0]}`)
  527. .addField('I choose', paper2[paper1])
  528. .setTimestamp()
  529.  
  530. let scissors = new Discord.RichEmbed()
  531. .setAuthor('Rock, Paper, Scissors')
  532. .setColor(0x6B5858)
  533. .addField('You choose', `${args[0]}`)
  534. .addField('I choose', scissors2[scissors1])
  535. .setTimestamp()
  536.  
  537. if (message.content === '$rps rock') message.channel.send(rock)
  538. if (message.content === '$rps Rock') message.channel.send(rock)
  539.  
  540. if (message.content === '$rps paper') message.channel.send(paper)
  541. if (message.content === '$rps Paper') message.channel.send(paper)
  542.  
  543. if (message.content === '$rps scissors') message.channel.send(scissors)
  544. if (message.content === '$rps Scissors') message.channel.send(scissors)
  545.  
  546.  
  547. if (message.content === '$rps') message.channel.send('Options: ``Rock``, ``Paper``, ``Scissors``. **Usage: $rps <option>**')
  548.  
  549.  
  550.  
  551.  
  552. }
  553. if (command === "contact") {
  554. if (args[0] == "help") {
  555. let helpembxd = new Discord.RichEmbed()
  556. .setColor("#00ff00")
  557. .addField("Contact Command", "Usage: !Contact <reason>")
  558.  
  559. message.channel.send(helpembxd);
  560. return;
  561. }
  562.  
  563. let Invite = await message.guild.channels.find((c) => c.type === 'text').createInvite()
  564. let Sender = message.author;
  565. const sayMessage = args.join(" ");
  566. if (!sayMessage) return message.channel.send("Please give us reason for contacting").then(msg => {
  567. msg.delete(5000)
  568. });
  569.  
  570. let contact = new Discord.RichEmbed()
  571. .setColor("00ff00")
  572. .setThumbnail(Sender.displayAvatarURL)
  573. .setDescription(`Contact message from [${message.guild.name}](${Invite.url})`)
  574. .setTitle("Message from contact command!")
  575. .addField("User", Sender, true)
  576. .addField("User ID: ", Sender.id, true)
  577. .addField("Message: ", sayMessage)
  578. .setTimestamp()
  579.  
  580. client.users.get("308589969704747009").send(contact);
  581.  
  582. let embed = new Discord.RichEmbed()
  583. .setColor("#00ff00")
  584. .setTitle("Message Sent!")
  585. .setDescription("Your contact message has been sent!")
  586. .addField("Reqested by ", Sender)
  587. .addField("Message: ", sayMessage)
  588. .setFooter("Thanks you for contacting The Bot's Owner! so i can be better!")
  589.  
  590. message.channel.send(embed).then(msg => {
  591. msg.delete(10000)
  592. });
  593.  
  594. message.delete();
  595.  
  596. }
  597.  
  598. if (command === "spam") {
  599. if (args.length !== 0) {
  600. if (message.content.indexOf("@everyone") > -1 || message.content.indexOf("@here") > -1) {
  601. message.channel.send("No.");
  602. } else {
  603. message.channel.send(args.join(" ").repeat(500).substring(0, 500));
  604. }
  605. } else {
  606. message.reply("you need to specify what you want to spam!");
  607. }
  608. };
  609. if (command === "ping") {
  610. // Calculates ping between sending a message and editing it, giving a nice round-trip latency.
  611. // The second ping is an average latency between the bot and the websocket server (one-way, not round-trip)
  612. const m = await message.channel.send("Ping?");
  613. m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
  614. }
  615.  
  616. if (command === "botinfo") {
  617. let inline = true
  618. let bicon = client.user.displayAvatarURL;
  619. let usersize = client.users.size
  620. let chansize = client.channels.size
  621. let uptimxd = client.uptime
  622. let servsize = client.guilds.size
  623. let botembed = new Discord.RichEmbed()
  624. .setColor("#00ff00")
  625. .setThumbnail(bicon)
  626. .addField("Bot Name", `${client.user.username}`, inline)
  627. .addField("Bot Owner", "<@321091504242294784>", inline)
  628. .addField("Servers", `๐Ÿ›ก ${servsize}`, inline)
  629. .addField("Channels", `๐Ÿ“ ${chansize}`, inline)
  630. .addField("Users", `${usersize}`, inline)
  631. .addField("Bot Library", "Discord.js", inline)
  632. .addField("Created On", client.user.createdAt)
  633. .setTimestamp()
  634.  
  635. message.channel.send(botembed);
  636.  
  637. }
  638.  
  639. if (command === "avatar") {
  640. let msg = await message.channel.send("Generating avatar...");
  641.  
  642. let mentionedUser = message.mentions.users.first() || message.author;
  643.  
  644. let embed = new Discord.RichEmbed()
  645.  
  646. .setImage(mentionedUser.displayAvatarURL)
  647. .setColor("00ff00")
  648. .setTitle("Avatar")
  649. .setFooter("Searched by " + message.author.tag)
  650. .setDescription("[Avatar URL link](" + mentionedUser.displayAvatarURL + ")");
  651.  
  652. message.channel.send(embed)
  653.  
  654.  
  655. message.delete();
  656. }
  657.  
  658. if (command === "userinfo") {
  659. let inline = true
  660. let resence = true
  661. const status = {
  662. online: "<:online:424890369688469504> Online",
  663. idle: "<:idle:424890472855502849> Idle",
  664. dnd: "<:dnd:424890429524410368> Do Not Disturb",
  665. offline: "<:offilne:424890400319340546> Offline/Invisible"
  666. }
  667.  
  668. const member = message.mentions.members.first() || message.guild.members.get(args[0]) || message.member;
  669. let target = message.mentions.users.first() || message.author
  670.  
  671. if (member.user.bot === true) {
  672. bot = "<:bottag:425631858265423883> Yes";
  673. } else {
  674. bot = "<:user:424958082691629057> No";
  675. }
  676.  
  677. let embed = new Discord.RichEmbed()
  678. //.setAuthor(member.user.username)
  679. .setThumbnail((target.displayAvatarURL))
  680. .setColor("#00ff00")
  681. .addField("Full Username", `${member.user.tag}`, inline)
  682. .addField("ID", member.user.id, inline)
  683. .addField("Nickname", `${member.nickname !== null ? `<425632265993846795> Nickname: ${member.nickname}` : "<:no:425632070036094986> None"}`, true)
  684. .addField("Bot", `${bot}`, inline, true)
  685. .addField("Status", `${status[member.user.presence.status]}`, inline, true)
  686. .addField("Playing", `${member.user.presence.game ? `๐ŸŽฎ ${member.user.presence.game.name}` : "<425632070036094986> Not playing"}`, inline, true)
  687. .addField("Roles", `${member.roles.filter(r => r.id !== message.guild.id).map(roles => `\`${roles.name}\``).join(" **|** ") || "<:no:425632070036094986> No Roles"}`, true)
  688. .addField("Joined Discord At", member.user.createdAt)
  689. .setFooter(`Information about ${member.user.username}`)
  690. .setTimestamp()
  691.  
  692. message.channel.send(embed);
  693.  
  694. message.delete();
  695. }
  696.  
  697. if (command === "report") {
  698. message.delete()
  699. // mentioned or grabbed user
  700. let target = message.mentions.members.first() || message.guild.members.get(args[0])
  701. if (!target) return message.channel.send("Please provide a valid user").then(m => m.delete(15000))
  702.  
  703. // reasoning definition
  704. let reason = args.slice(1).join(" ")
  705. if (!reason) return message.channel.send(`Please provide a reason for reporting **${target.user.tag}**`).then(m => m.delete(15000))
  706.  
  707. // grab reports channel
  708. let sChannel = message.guild.channels.find(x => x.name === "ใ€Œ๐Ÿ“Žใ€logs")
  709.  
  710. // send to reports channel and add tick or cross
  711.  
  712. message.channel.send("Your report has been filed to the staff team. Thank you!").then(m => m.delete(15000))
  713. sChannel.send(`**${message.author.tag}** has reported **${target.user.tag}** for **${reason}**.`).then(async msg => {
  714. await msg.react("โœ…")
  715. await msg.react("โŒ")
  716. })
  717.  
  718.  
  719.  
  720. }
  721.  
  722. if (command === "addrole") {
  723. if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
  724.  
  725. let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
  726. if (!rMember) return message.channel.send("Please provide a user to add a role too.")
  727. let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
  728. if (!role) return message.channel.send("Please provide a role to add to said user.")
  729. let reason = args.slice(2).join(" ")
  730. if (!reason) return message.channel.send("Please provide a reason")
  731.  
  732. if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to perform this command.")
  733.  
  734. if (rMember.roles.has(role.id)) {
  735. return message.channel.send(`${rMember.displayName}, already has the role!`)
  736. } else {
  737. await rMember.addRole(role.id).catch(e => console.log(e.message))
  738. message.channel.send(`The role, ${role.name}, has been added to ${rMember.displayName}.`)
  739. }
  740.  
  741. let addroleembed = new RichEmbed()
  742. .setColor(redlight)
  743. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  744. .addField("Moderation:", "Addrole")
  745. .addField("Person who was moderated:", rMember.user.username)
  746. .addField("Moderator:", message.author.username)
  747. .addField("Reason:", reason)
  748. .addField("Date:", message.createdAt.toLocaleString())
  749.  
  750. let sChannel = message.guild.channels.find(c => c.name === "logs")
  751. sChannel.send(addroleembed)
  752. }
  753.  
  754. if (command === "removerole") {
  755. if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
  756.  
  757. let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
  758. if (!rMember) return message.channel.send("Please provide a user to remove a role too.")
  759. let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
  760. if (!role) return message.channel.send("Please provide a role to remove from said user.")
  761. let reason = args.slice(2).join(" ")
  762. if (!reason) return message.channel.send("Please provide a reason")
  763.  
  764. if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to perform this command.")
  765.  
  766. if (!rMember.roles.has(role.id)) {
  767. return message.channel.send(`${rMember.displayName}, doesnt have the role!`)
  768. } else {
  769. await rMember.removeRole(role.id).catch(e => console.log(e.message))
  770. message.channel.send(`The role, ${role.name}, has been removed from ${rMember.displayName}.`)
  771. }
  772.  
  773. let removeroleembed = new RichEmbed()
  774. .setColor(redlight)
  775. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  776. .addField("Moderation:", "Addrole")
  777. .addField("Person who was moderated", rMember.user.username)
  778. .addField("Moderator:", message.author.username)
  779. .addField("Reason:", reason)
  780. .addField("Date:", message.createdAt.toLocaleString())
  781.  
  782. let sChannel = message.guild.channels.find(c => c.name === "logs")
  783. sChannel.send(removeroleembed)
  784. }
  785. if (command === "votekick") {
  786. const agree = "โœ…";
  787. const disagree = "โŽ";
  788.  
  789. if (message.mentions.users.size === 0){
  790. return message.reply(":x: " + "| Please Mention A User To Kick Next Time");
  791. }
  792.  
  793. let kickmember = message.guild.member(message.mentions.users.first());
  794. if(!kickmember){
  795. message.reply(":x: " + "| That User Does Not Seem Valid!");
  796. }
  797.  
  798. if(!message.guild.member(client.user).hasPermission("KICK_MEMBERS")){
  799. return message.reply(":x: " + "| i need the \"KICK_MEMBERS\" permission!").catch(console.error);
  800. }
  801.  
  802. let msg = await message.channel.send("Vote now! (10 Seconds)");
  803. await msg.react(agree);
  804. await msg.react(disagree);
  805.  
  806. const reactions = await msg.awaitReactions(reaction => reaction.emoji.name === agree || reaction.emoji.name === disagree, {time: 10000});
  807. msg.delete();
  808.  
  809. var NO_Count = reactions.get(disagree).count;
  810. var YES_Count = reactions.get(agree);
  811.  
  812. if(YES_Count == undefined){
  813. var YES_Count = 1;
  814. }else{
  815. var YES_Count = reactions.get(agree).count;
  816. }
  817.  
  818. var sumsum = new Discord.RichEmbed()
  819.  
  820. .addField("Voting Finished:", "----------------------------------------\n" +
  821. "Total votes (NO): " + `${NO_Count-1}\n` +
  822. "Total votes (Yes): " + `${YES_Count-1}\n` +
  823. "----------------------------------------\n" +
  824. "NOTE: Votes needed to kick (3+)\n" +
  825. "----------------------------------------", true)
  826.  
  827. .setColor("0x#FF0000")
  828.  
  829. await message.channel.send({embed: sumsum});
  830.  
  831. if(YES_Count >= 4 && YES_Count > NO_Count){
  832.  
  833. kickmember.kick().then(member => {
  834. message.reply(`${member.user.username} was succesfully kicked`)
  835. })
  836. }else{
  837.  
  838. message.channel.send("\n" + "SAFE..... FOR NOW");
  839. }
  840.  
  841. }
  842. if (command === "ban") {
  843. // Most of this command is identical to kick, except that here we'll only let admins do it.
  844. // In the real world mods could ban too, but this is just an example, right? ;)
  845. if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
  846.  
  847. let member = message.mentions.members.first();
  848. if (!member)
  849. return message.reply("Please mention a valid member of this server");
  850. if (!member.bannable)
  851. return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
  852.  
  853. let reason = args.slice(1).join(' ');
  854. if (!reason) reason = "No reason provided";
  855.  
  856. await member.ban(reason)
  857. .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
  858. message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
  859. }
  860.  
  861. if (command === "purge") {
  862. // This command removes all messages from all users in the channel, up to 100.
  863.  
  864. // get the delete count, as an actual number.
  865. const deleteCount = parseInt(args[0], 10);
  866.  
  867. // Ooooh nice, combined conditions. <3
  868. if (!deleteCount || deleteCount < 2 || deleteCount > 100)
  869. return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
  870.  
  871. // So we get our messages, and delete them. Simple enough, right?
  872. const fetched = await message.channel.fetchMessages({
  873. limit: deleteCount
  874. });
  875. message.channel.bulkDelete(fetched)
  876. .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
  877. }
  878. if (command === "lockdown") {
  879. if (!message.member.permissions.has("MANAGE_CHANNELS")) return message.channel.send("Sorry, you do not have permission to perform the antiraid command.");
  880. if (!message.guild.member(client.user).hasPermission('MANAGE_CHANNELS')) return message.reply('Sorry, i dont have the perms to do this cmd i need MANAGE_CHANNELS. :x:')
  881. const ms = require('ms');
  882. if (!client.lockit) client.lockit = [];
  883. const time = args.join(' ');
  884. const validUnlocks = ['release', 'unlock', 'stop', 'off'];
  885. if (!time) return message.reply('You must set a duration for the lockdown in either hours, minutes or seconds');
  886.  
  887. if (validUnlocks.includes(time)) {
  888. message.channel.overwritePermissions(message.guild.id, {
  889. SEND_MESSAGES: true
  890. }).then(() => {
  891. message.channel.send('Lockdown lifted.');
  892. clearTimeout(client.lockit[message.channel.id]);
  893. delete client.lockit[message.channel.id];
  894. }).catch(error => {
  895. console.log(error);
  896. });
  897. } else {
  898. message.channel.overwritePermissions(message.guild.id, {
  899. SEND_MESSAGES: false
  900. }).then(() => {
  901. message.channel.send(`Channel locked down for ${ms(ms(time), { long:true })}`).then(() => {
  902.  
  903. client.lockit[message.channel.id] = setTimeout(() => {
  904. message.channel.overwritePermissions(message.guild.id, {
  905. SEND_MESSAGES: true
  906. }).then(message.channel.send('Lockdown lifted.'))
  907. delete client.lockit[message.channel.id];
  908. }, ms(time));
  909. }).catch(error => {
  910. console.log(error);
  911. });
  912. });
  913. }
  914. }
  915.  
  916. if (command === "unban") {
  917. if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
  918.  
  919. if (isNaN(args[0])) return message.channel.send("You need to provide an ID.")
  920. let bannedMember = await client.fetchUser(args[0])
  921. if (!bannedMember) return message.channel.send("Please provide a user id to unban someone!")
  922.  
  923. let reason = args.slice(1).join(" ")
  924. if (!reason) reason = "No reason given!"
  925.  
  926. if (!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("I dont have permission to perform this command!") |
  927. message.delete()
  928. try {
  929. message.guild.unban(bannedMember, reason)
  930. message.channel.send(`${bannedMember.tag} has been unbanned from the guild!`)
  931. } catch (e) {
  932. console.log(e.message)
  933. }
  934.  
  935. let unbannedembed = new RichEmbed()
  936. .setColor(redlight)
  937. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  938. .addField("Moderation:", "unban")
  939. .addField("Moderated on:", `${bannedMember.username} (${bannedMember.id})`)
  940. .addField("Moderator:", message.author.username)
  941. .addField("Reason:", reason)
  942. .addField("Date:", message.createdAt.toLocaleString())
  943.  
  944. let sChannel = message.guild.channels.find(c => c.name === "ใ€Œ๐Ÿ“Žใ€logs")
  945. sChannel.send(unbannedembed)
  946. }
  947. if (message.guild && message.content.startsWith('$dmeveryone')) {
  948. if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('This requires the permission: ADMINISTRATOR');
  949. let text = message.content.slice('$dmeveryone'.length); // cuts off the /private part
  950. message.guild.members.forEach(member => {
  951. if (member.id != client.user.id && !member.user.bot) member.send(text);
  952. });
  953. }
  954.  
  955.  
  956. if (command === "kick") {
  957. // This command must be limited to mods and admins. In this example we just hardcode the role names.
  958. // Please read on Array.some() to understand this bit:
  959. // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
  960. if (!message.member.hasPermission("KICK_MEMBERS")) return message.reply("Sorry, you don't have permissions to use this!");
  961.  
  962. // Let's first check if we have a member and if we can kick them!
  963. // message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
  964. // We can also support getting the member by ID, which would be args[0]
  965. let member = message.mentions.members.first() || message.guild.members.get(args[0]);
  966. if (!member)
  967. return message.reply("Please mention a valid member of this server");
  968. if (!member.kickable)
  969. return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
  970.  
  971. // slice(1) removes the first part, which here should be the user mention or ID
  972. // join(' ') takes all the various parts to make it a single string.
  973. let reason = args.slice(1).join(' ');
  974. if (!reason) reason = "No reason provided";
  975.  
  976. // Now, time for a swift kick in the nuts!
  977. await member.kick(reason)
  978. .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
  979.  
  980. message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`)
  981.  
  982. }
  983.  
  984. if (command === "unmute") {
  985. if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
  986.  
  987. if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
  988.  
  989. //define the reason and unmutee
  990. let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
  991. if (!mutee) return message.channel.send("Please supply a user to be muted!");
  992.  
  993. let reason = args.slice(1).join(" ");
  994. if (!reason) reason = "No reason given"
  995.  
  996. //define mute role and if the mute role doesnt exist then send a message
  997. let muterole = message.guild.roles.find(r => r.name === "Muted")
  998. if (!muterole) return message.channel.send("That user is muted.")
  999.  
  1000. //remove role to the mentioned user and also send the user a dm explaing where and why they were unmuted
  1001. mutee.removeRole(muterole.id).then(() => {
  1002. message.delete()
  1003. mutee.send(`Hello, you have been unmuted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
  1004. message.channel.send(`${mutee.user.username} was unmuted!`)
  1005. })
  1006.  
  1007. //send an embed to the modlogs channel
  1008. let unmuteembed = new RichEmbed()
  1009. .setColor(redlight)
  1010. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  1011. .addField("Moderation:", "unmute")
  1012. .addField("Person who was moderated:", mutee.user.username)
  1013. .addField("Moderator:", message.author.username)
  1014. .addField("Reason:", reason)
  1015. .addField("Date:", message.createdAt.toLocaleString())
  1016.  
  1017. let sChannel = message.guild.channels.find(c => c.name === "ใ€Œ๐Ÿ“Žใ€logs")
  1018. sChannel.send(unmuteembed)
  1019.  
  1020. }
  1021.  
  1022. if (command === "mute") {
  1023. if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
  1024.  
  1025. if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
  1026.  
  1027. //define the reason and mutee
  1028. let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
  1029. if (!mutee) return message.channel.send("Please supply a user to be muted!");
  1030.  
  1031. let reason = args.slice(1).join(" ");
  1032. if (!reason) reason = "No reason given"
  1033.  
  1034. //define mute role and if the mute role doesnt exist then create one
  1035. let muterole = message.guild.roles.find(r => r.name === "Muted")
  1036. if (!muterole) {
  1037. try {
  1038. muterole = await message.guild.createRole({
  1039. name: "Muted",
  1040. color: "#514f48",
  1041. permissions: []
  1042. })
  1043. message.guild.channels.forEach(async (channel, id) => {
  1044. await channel.overwritePermissions(muterole, {
  1045. SEND_MESSAGES: false,
  1046. ADD_REACTIONS: false,
  1047. SEND_TTS_MESSAGES: false,
  1048. ATTACH_FILES: false,
  1049. SPEAK: false
  1050. })
  1051. })
  1052. } catch (e) {
  1053. console.log(e.stack);
  1054. }
  1055. }
  1056.  
  1057. //add role to the mentioned user and also send the user a dm explaing where and why they were muted
  1058. mutee.addRole(muterole.id).then(() => {
  1059. message.delete()
  1060. mutee.send(`Hello, you have been muted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
  1061. message.channel.send(`${mutee.user.username} was successfully muted.`)
  1062. })
  1063.  
  1064. //send an embed to the modlogs channel
  1065. let muteembed = new RichEmbed()
  1066. .setColor(redlight)
  1067. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  1068. .addField("Moderation:", "mute")
  1069. .addField("Person who was moderated:", mutee.user.username)
  1070. .addField("Moderator:", message.author.username)
  1071. .addField("Reason:", reason)
  1072. .addField("Date:", message.createdAt.toLocaleString())
  1073.  
  1074. let sChannel = message.guild.channels.find(c => c.name === "ใ€Œ๐Ÿ“Žใ€logs")
  1075. sChannel.send(muteembed)
  1076. }
  1077.  
  1078. if (command === "serverinfo") {
  1079.  
  1080. const verlvl = {
  1081. 0: "None",
  1082. 1: "Low",
  1083. 2: "Medium",
  1084. 3: "(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป",
  1085. 4: "(ใƒŽเฒ ็›Šเฒ )ใƒŽๅฝกโ”ปโ”โ”ป"
  1086. }
  1087.  
  1088. let inline = true
  1089. let sicon = message.guild.iconURL;
  1090. let serverembed = new Discord.RichEmbed()
  1091. .setColor("#00ff00")
  1092. .setThumbnail(sicon)
  1093. .setAuthor(message.guild.name)
  1094. .addField("Name", message.guild.name, inline)
  1095. .addField("ID", message.guild.id, inline)
  1096. .addField("Owner", message.guild.owner, inline)
  1097. .addField("Region", message.guild.region, inline)
  1098. .addField("Verification Level", verlvl[message.guild.verificationLevel], inline)
  1099. .addField("Members", `<:user:424958082691629057> ${message.guild.memberCount}`, inline)
  1100. .addField("Roles", message.guild.roles.size, inline)
  1101. .addField("Channels", message.guild.channels.size, inline)
  1102. .addField("You Joined", message.member.joinedAt)
  1103. .setFooter(`Created ${message.guild.createdAt}`);
  1104.  
  1105. message.channel.send(serverembed);
  1106.  
  1107. message.delete();
  1108. }
  1109. if (command === "invite") {
  1110. let bicon = client.user.displayAvatarURL;
  1111.  
  1112. let inviteEmbed = new Discord.RichEmbed()
  1113. .setDescription("[**Invite**](https://discordapp.com/oauth2/authorize?&client_id=596214805786918923&scope=bot&permissions=8)")
  1114. .setColor("#00ff00")
  1115. .setThumbnail(bicon)
  1116. .addField("Use this invite to invite the bot in your server!", "https://discordapp.com/oauth2/authorize?&client_id=596214805786918923&scope=bot&permissions=8")
  1117.  
  1118. message.channel.send(inviteEmbed);
  1119.  
  1120. message.delete();
  1121.  
  1122. }
  1123.  
  1124. // Let's go with a few common example commands! Feel free to delete or change those.
  1125. })
  1126. client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement