Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const client = new Discord.Client();
  3. const config = require("./config.json");
  4. client.on("ready", () => {
  5. console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
  6. client.user.setActivity(`Serving ${client.guilds.size} servers`);
  7. });
  8. client.on("guildCreate", guild => {
  9. console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
  10. client.user.setActivity(`Serving ${client.guilds.size} servers`);
  11. });
  12. client.on("guildDelete", guild => {
  13. console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
  14. client.user.setActivity(`Serving ${client.guilds.size} servers`);
  15. });
  16. client.on("message", async message => {
  17.  
  18. if(message.author.bot) return;
  19. if(message.content.indexOf(config.prefix) !== 0) return;
  20. const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  21. const command = args.shift().toLowerCase();
  22. if(command === "ping") {
  23. const m = await message.channel.send("Ping?");
  24. m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
  25. }
  26. if(command === "say") {
  27. const sayMessage = args.join(" ");
  28. message.delete().catch(O_o=>{});
  29. message.channel.send(sayMessage);
  30. }
  31. if(command === "purge") {
  32. const deleteCount = parseInt(args[0], 10);
  33. if(!deleteCount || deleteCount < 2 || deleteCount > 100)
  34. return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
  35. const fetched = await message.channel.fetchMessages({limit: deleteCount});
  36. message.channel.bulkDelete(fetched)
  37. .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
  38. }
  39. if (command === 'args-info') {
  40. message.channel.send(`Command name: ${command}\nArguments: ${args}`);
  41. }
  42. if (command === 'args2-info') {
  43. let a = args[0]
  44. let b = args[1]
  45. let c = args[2]
  46. message.channel.send("Arg1 "+a+" Arg2 "+b+" Arg3 "+c);
  47. }
  48. if(command==="createaccount") {
  49. var username=message.author.username+"#"+message.author.discriminator
  50. var balance=0
  51. fs = require('fs');
  52. temp="Accounts/"+username+".txt"
  53. var stream = fs.createWriteStream(temp);
  54. stream.once('open', function(fd) {
  55. stream.write(username+"\r\n");
  56. stream.write(balance+"\r\n");
  57. stream.end();
  58. message.channel.send("Account Successfully Created! "+message.author.toString());
  59. });
  60. }
  61. if(command === "bal") {
  62. var txtFile = "Accounts/"+message.author.username+"#"+message.author.discriminator+".txt"
  63. fs = require('fs');
  64. fs.readFile(txtFile, 'utf8', function(err,data) {
  65. var tmparray = fs.readFileSync("Accounts/"+message.author.username+"#"+message.author.discriminator+".txt").toString().split("\n");
  66. if(err) {
  67. message.channel.send("Error!");
  68. }
  69. else {
  70. message.channel.send(message.author.toString()+" Your balance is :dollar:"+tmparray[1]);
  71. console.log(tmparray[1])
  72. }
  73. });
  74. }
  75. if(command === "help") {
  76. var txtFile = "info.txt"
  77. fs = require('fs');
  78. fs.readFile(txtFile, 'utf8', function(err,data) {
  79. if(err) {
  80. message.channel.send("Error!");
  81. }
  82. else {
  83. message.channel.send(data);
  84. }
  85. });
  86. }
  87. if(command==="coinflip") {
  88. let hort = args[0]
  89. let bet = args[1]
  90. //check
  91.  
  92. }
  93. })
  94. client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement