Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. const config = require("./config.json");
  4.  
  5. var prefix = config.prefix
  6.  
  7. function magic8Ball() {
  8. var rand = [':8ball: Absolutly.', ':8ball: Absolutly not.', ':8ball: It is true.', ':8ball: Impossible.', ':8ball: Of course.', ':8ball: I do not think so.', ':8ball: It is true.', ':8ball: It is not true.', ':8ball: I am very undoubtful of that.',
  9. ':8ball: I am very doubtful of that.', ':8ball: Sources point to no.', ':8ball: Theories prove it.', ':8ball: Reply hazy try again', ':8ball: Ask again later', ':8ball: Better not tell you now', ':8ball: Cannot predict now', ':8ball: Concentrate and ask again'
  10. ];
  11. return rand[Math.floor(Math.random() * rand.length)];
  12. };
  13.  
  14. bot.on("ready", () => {
  15. console.log(`Hi Gamma! I've initiated with ${bot.users.size} users, in ${bot.guilds.size} guild(s)`);
  16. bot.user.setGame(`j!help | ${bot.guilds.size} Guilds!`);
  17. });
  18.  
  19. bot.on("message", async message => {
  20. if (message.author.bot) return;
  21. if (message.content.indexOf(config.prefix) !== 0) return;
  22. const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  23. const command = args.shift().toLowerCase();
  24.  
  25. client.on("guildMemberAdd", (member) => {
  26. newUsers.set(member.id, member.user);
  27. });
  28.  
  29. client.on("message", (message) => {
  30. if (message.content.startsWith("ping")) {
  31. message.channel.send("pong!");
  32. }
  33. });
  34.  
  35. client.on("guildMemberAdd", (member) => {
  36. const guild = member.guild;
  37. if (!newUsers[guild.id]) newUsers[guild.id] = new Discord.Collection();
  38. newUsers[guild.id].set(member.id, member.user);
  39.  
  40. if (newUsers[guild.id].size > 1) {
  41. const userlist = newUsers[guild.id].map(u => u.toString()).join(" ");
  42. guild.channels.get(guild.id).send("Welcome!\n" + userlist);
  43. newUsers[guild.id].clear();
  44. }
  45. });
  46.  
  47. client.on("guildMemberRemove", (member) => {
  48. const guild = member.guild;
  49. if (newUsers[guild.id].has(member.id)) newUsers.delete(member.id);
  50. });
  51.  
  52.  
  53. if (command === "say") {
  54. const sayMessage = args.join(" ");
  55. message.delete().catch(Kek => {});
  56. message.channel.send(sayMessage);
  57. };
  58.  
  59. if (command === "invite") {
  60. message.channel.send ("Here ya go! https://discordapp.com/oauth2/authorize?client_id=381649594783891476&scope=bot&permissions=268561478");
  61. console.log("Sent invite link.")
  62. };
  63.  
  64. if(command === "ping") {
  65. // Calculates ping between sending a message and editing it, which gives the time in milliseconds
  66. const m = await message.channel.send("Calculating...");
  67. m.edit(`:ping_pong: Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(bot.ping)}ms);
  68. }
  69.  
  70. if (command === "youtube") {
  71. message.channel.send("Try this on for size! https://youtube.com/GammaRayTheBestEvahhhh");
  72. console.log("Sent Channel Link.")
  73. }
  74.  
  75. if (command === "dab") {
  76. message.channel.send(`<o/ ${message.author} has been dabbed on`);
  77. console.log("Dabbed on someone.");
  78. }
  79.  
  80. if (command === "help") {
  81. message.channel.send("Here's a list of commands!")
  82. message.channel.send("**j!8ball <Question>** Gives a response to a question just as a Magic Eight Ball would!")
  83. message.channel.send("**j!say <Words>** Takes any text after the j!say command, and repeats it back!")
  84. message.channel.send("**j!youtube** Sends Gamma's Youtube link!")
  85. message.channel.send("**j!invite** Sends the invite link for me in chat so you can invite me to your servers!")
  86. message.channel.send("**j!Dab** Dabs on you!")
  87. message.channel.send("*Pg. 1/1*")
  88. console.log("Opened help menu");
  89. };
  90.  
  91. if (command === "8ball") {
  92. message.channel.send(magic8Ball()) }});
  93.  
  94. bot.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement