Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const Client = new Discord.Client();
  3. const OwnerID = "130515926117253122";
  4.  
  5. const prefix = "!"
  6.  
  7.  
  8.  
  9. Client.on("ready", () => {
  10. console.log("online");
  11. Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
  12. });
  13.  
  14. // welcome message
  15.  
  16. Client.on("guildMemberAdd", member => {
  17. member.guild.defaultChannel.send("Welcome to: " + member.guild.name + " Hope you enjoy it here")
  18. });
  19.  
  20. Client.on("guildMemberRemove", member => {
  21. member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
  22. });
  23.  
  24. Client.on("guildCreate", guild => {
  25. console.log("Some one added the test bot to a server created by: " + guild.owner.user.username)
  26. });
  27.  
  28. Client.on("message", async (message) => {
  29. if (message.author.bot) return;
  30. if (!message.content.startsWith(prefix)) return;
  31.  
  32. let command = message.content.split(" ")[0];
  33. command = command.slice(prefix.length);
  34.  
  35. let args = message.content.split(" ").slice(1);
  36.  
  37. if (command === "ping") {
  38. message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
  39. } else
  40.  
  41. if (command === "say") {
  42. message.delete()
  43. const embed = new Discord.RichEmbed()
  44. .setColor(0x954D23)
  45. .setDescription(message.author.username + " says: " + args.join(" "));
  46. message.channel.send({embed})
  47. } else
  48.  
  49. if (command == "help") {
  50. const embed = new Discord.RichEmbed()
  51. .setColor(0x954D23)
  52. .setTitle("Command List:")
  53. .addField("!help", "Will give the current command list")
  54. .addField("!ping", "WIll show the ping time for the bot")
  55. .addField("!say [text]", "Will make the bot say something")
  56. .addField("!announcement [text]", "Will make the bot say an announcement and tag everyone")
  57. .addField("!cat", "Will send a random cat image");
  58. message.channel.send({embed})
  59. }
  60.  
  61. });
  62.  
  63. Client.login("Redacted");
  64.  
  65. Error
  66.  
  67. (node:38708) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Incorrect login details were provided.
  68. (node:38708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement