Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const client = new Discord.Client();
- const config = require("./config.json");
- client.on("ready", () => {
- console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
- client.user.setActivity(`Serving ${client.guilds.size} servers`);
- });
- client.on("guildCreate", guild => {
- console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
- client.user.setActivity(`Serving ${client.guilds.size} servers`);
- });
- client.on("guildDelete", guild => {
- console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
- client.user.setActivity(`Serving ${client.guilds.size} servers`);
- });
- client.on("message", async message => {
- if(message.author.bot) return;
- if(message.content.indexOf(config.prefix) !== 0) return;
- const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- if(command === "ping") {
- const m = await message.channel.send("Ping?");
- m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
- }
- if(command === "say") {
- const sayMessage = args.join(" ");
- message.delete().catch(O_o=>{});
- message.channel.send(sayMessage);
- }
- if(command === "purge") {
- const deleteCount = parseInt(args[0], 10);
- if(!deleteCount || deleteCount < 2 || deleteCount > 100)
- return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
- const fetched = await message.channel.fetchMessages({limit: deleteCount});
- message.channel.bulkDelete(fetched)
- .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
- }
- if (command === 'args-info') {
- message.channel.send(`Command name: ${command}\nArguments: ${args}`);
- }
- if (command === 'args2-info') {
- let a = args[0]
- let b = args[1]
- let c = args[2]
- message.channel.send("Arg1 "+a+" Arg2 "+b+" Arg3 "+c);
- }
- if(command==="createaccount") {
- var username=message.author.username+"#"+message.author.discriminator
- var balance=0
- fs = require('fs');
- temp="Accounts/"+username+".txt"
- var stream = fs.createWriteStream(temp);
- stream.once('open', function(fd) {
- stream.write(username+"\r\n");
- stream.write(balance+"\r\n");
- stream.end();
- message.channel.send("Account Successfully Created! "+message.author.toString());
- });
- }
- if(command === "bal") {
- var txtFile = "Accounts/"+message.author.username+"#"+message.author.discriminator+".txt"
- fs = require('fs');
- fs.readFile(txtFile, 'utf8', function(err,data) {
- var tmparray = fs.readFileSync("Accounts/"+message.author.username+"#"+message.author.discriminator+".txt").toString().split("\n");
- if(err) {
- message.channel.send("Error!");
- }
- else {
- message.channel.send(message.author.toString()+" Your balance is :dollar:"+tmparray[1]);
- console.log(tmparray[1])
- }
- });
- }
- if(command === "help") {
- var txtFile = "info.txt"
- fs = require('fs');
- fs.readFile(txtFile, 'utf8', function(err,data) {
- if(err) {
- message.channel.send("Error!");
- }
- else {
- message.channel.send(data);
- }
- });
- }
- if(command==="coinflip") {
- let hort = args[0]
- let bet = args[1]
- //check
- }
- })
- client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement