Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FleetUtil for Fleet Girls Online
- // v0.0.1
- // by Karen
- const Discord = require("discord.js");
- const mysql = require("mysql");
- const fs = require("fs");
- const config = require("./config.json");
- const token = config.token;
- const prefix = config.prefix;
- const bot = new Discord.Client({autoReconnect:true});
- // Bot status, invite and console invitation
- bot.on("ready", async () => {
- bot.user.setStatus("playing")
- bot.user.setActivity("the coastline!", { type: "WATCHING" })
- console.log();
- console.log(`${bot.user.username} is now up and running!`);
- console.log(`Assisting ${bot.users.size} users in Fleet Girls Online!`);
- console.log("Invite link below with permissions set as administrator.");
- try {
- let link = await bot.generateInvite(["ADMINISTRATOR"])
- console.log(link);
- } catch(e) {
- console.log(e.stack);
- };
- });
- bot.on("message", message => {
- if (message.author.bot) return;
- let author = message.author.username
- let content = message.content
- console.log(`${author}: ${content}`);
- });
- // Connects to the fleet database
- var con = mysql.createConnection({
- host: "localhost",
- user: "root",
- password: "karen",
- database: "fleet"
- });
- con.connect(err => {
- if(err) throw err;
- con.query("SHOW TABLES", console.log)
- console.log("Connected to database!");
- });
- function clamp (v, min, max) {
- return (Math.min(max, Math.max(min, v)));
- }
- const ships = require("./ships.json");
- //const construction = require("./construction")
- bot.on("message", async message => {
- if (message.author.bot) return;
- if (message.channel.type === "dm") return;
- if (!message.content.startsWith(prefix)) return;
- //if (message.member.roles.find("name", "Non-Registered Member")) return message.channel.send("You have not yet registered");
- const args = message.content.slice(prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- // Icons/Emotes ----------------------------------
- let IconCoin = bot.emojis.find("name", "IconCoin")
- let IconFuel = bot.emojis.find("name", "IconFuel")
- let IconRuby = bot.emojis.find("name", "IconRuby")
- let IconCube = bot.emojis.find("name", "IconCube")
- let IconDrill = bot.emojis.find("name", "IconDrill")
- let ShipSS = bot.emojis.find("name", "ShipSS")
- let ShipDD = bot.emojis.find("name", "ShipDD")
- let ShipCX = bot.emojis.find("name", "ShipCX")
- let ShipCV = bot.emojis.find("name", "ShipCV")
- let ShipBB = bot.emojis.find("name", "ShipBB")
- //let rrole = message.member.roles.find("name", "Registered Member")
- //let nrole = message.member.roles.find("name", "Non-Registered Member")
- //let rrmsg = message.channel.send("You have already registered")
- //let nrmsg = message.channel.send("You have not yet registered")
- // Command H01 "Help" ------------
- if (command === "help") {
- let h01Script = require("./script/help.json");
- if (!args[0]) return message.channel.send(helpScript.blank);
- if (args[0] === "help") return message.channel.send(h01Script.help)
- if (args[0] === "register") return message.channel.send(h01Script.register)
- if (args[0] === "refuel") return message.channel.send(h01Script.refuel)
- if (args[0] === "upgrade") return message.channel.send(h01Script.upgrade)
- message.channel.send(helpScript.other);
- }
- // Command R01 "Register" --------
- if (command === "register") {
- let r01Script = require("./script/register.json");
- let sqlFill = "DELETE FROM fill"
- let sqlAccount = "(id, coin, fuel, ruby, blue, drill, fuelup, secretary)"
- let RRole = message.guild.roles.find("name", "Registered Member")
- let NRole = message.guild.roles.find("name", "Non-Registered Member")mico
- let dWelcome = "Welcome to **Fleet Girls Online** "
- let dHelp = "\n\n`Type in ;info to view your account and ;help for asssistance.`"
- if (message.member.roles.find("name", "Registered Member")) return message.channel.send("You have already registered, theres no need to register again.");
- // Selection -------------------------------
- let embedSelection = new Discord.RichEmbed()
- .setTitle("Registration")
- .setDescription(r01Script.selection.desc)
- .addField("Starters", r01Script.selection.field)
- .setImage(r01Script.selection.image)
- .setColor(0x9ffff9);
- if (!args[0]) return message.channel.send(embedSelection);
- // Ayanami -------------------------------
- if (args[0].toLowerCase() === "ayanami") {
- let embedAyanami = new Discord.RichEmbed()
- .setTitle("You have now registered!")
- .setDescription(`${dWelcome}${message.author.username}!\n${r01Script.ayanami.desc}${dHelp}`)
- .setThumbnail(r01Script.ayanami.thumbnail)
- .setColor(0x9ffff9);
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql1; let sql2;
- if (rows.length < 1) {
- sql1 = `INSERT INTO account ${sqlAccount} VALUES ('${message.author.id}', 5000, 1500, 1000, 1, 1, 1, 'ayanami')`
- sql2 = `INSERT INTO stats (id) VALUES ('${message.author.id}')`
- message.member.addRole(RRole); message.member.removeRole(NRole)
- message.channel.send(embedAyanami)
- } else {
- sql1 = sqlFill; sql2 = sqlFill
- message.channel.send("You have already registered, theres no need to register again.")
- }
- con.query(sql1); con.query(sql2);
- });
- } else {
- // Laffey -------------------------------
- if (args[0].toLowerCase() === "laffey") {
- let embedLaffey = new Discord.RichEmbed()
- .setTitle("You have now registered!")
- .setDescription(`${dWelcome}${message.author.username}!\n${r01Script.laffey.desc}${dHelp}`)
- .setThumbnail(r01Script.laffey.thumbnail)
- .setColor(0x9ffff9);
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql1; let sql2;
- if (rows.length < 1) {
- sql1 = `INSERT INTO account ${sqlAccount} VALUES ('${message.author.id}', 5000, 1500, 1000, 1, 1, 1, 'laffey')`
- sql2 = `INSERT INTO stats (id) VALUES ('${message.author.id}')`
- message.member.addRole(RRole)
- message.member.removeRole(NRole)
- message.channel.send(embedLaffey)
- } else {
- sql1 = sqlFill; sql2 = sqlFill
- message.channel.send("You have already registered, theres no need to register again.")
- }
- con.query(sql1); con.query(sql2);
- });
- } else {
- // Javelin -------------------------------
- if (args[0].toLowerCase() === "javelin") {
- let embedJavelin = +new Discord.RichEmbed()
- .setTitle("You have now registered!")
- .setDescription(`${dWelcome}${message.author.username}!\n${r01Script.javelin.desc}${dHelp}`)
- .setThumbnail(r01Script.javelin.thumbnail)
- .setColor(0x9ffff9);
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql1; let sql2;
- if (rows.length < 1) {
- sql1 = `INSERT INTO account ${sqlAccount} VALUES ('${message.author.id}', 5000, 1500, 1000, 1, 1, 1, 'javelin')`
- sql2 = `INSERT INTO stats (id) VALUES ('${message.author.id}')`
- message.member.addRole(RRole)
- message.member.removeRole(NRole)
- message.channel.send(embedJavelin)
- } else {
- sql1 = sqlFill; sql2 = sqlFill
- message.channel.send("You have already registered, theres no need to register again.")
- }
- con.query(sql1); con.query(sql2);
- });
- } else {
- // Selecetion ----------------------
- message.channel.send(embedSelection)
- }}}
- }
- // Command TXX "NULL" ------------
- if (command === "retired-pick") {
- if(!args[0]) return message.channel.send("What is it that you want to pick?");
- let starters = ["murakumo", "inazuma", "fubuki", "samidare", "sazanami"]
- if (args[0].toLowerCase() === starters) return message.channel.send("Please choose a starter!")
- con.query(`SELECT * FROM stats WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err;
- let sql;
- if (rows.length < 1) {
- sql = `INSERT INTO fill (fill) VALUES ('fill')`
- sql = `DELETE FROM fill`
- message.channel.send("You first need to register!");
- } else {
- sql = `UPDATE stats SET ship = '${args[0].toLowerCase()}' WHERE id = '${message.author.id}'`;
- message.channel.send(`You have set ${args[0]} as your starter!`)
- }
- con.query(sql);
- });
- }
- if (command === "retired-simg") {
- if (!args[0]) return message.channel.send("Please mention a ship so I could display her info!")
- con.query(`SELECT * FROM shiplist WHERE name = '${args[0].toLowerCase()}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send("That is not an actual ship! In-game that is...");
- } else {
- let nm = rows[0].name; let name = nm.charAt(0).toUpperCase() + nm.slice(1);
- let nation = rows[0].nation; let type = rows[0].type; let clas = rows[0].class;
- let desc = rows[0].desc; let imgcard = rows[0].imgcard;
- if (rows[0].intro === "filler") return message.channel.send("Tell Karen to fucking add it smh")
- let embed = new Discord.RichEmbed()
- .addField(`[${nation}] ${name}`, `${type} ${clas} class`)
- .addField("Description", desc)
- .setImage(imgcard)
- .setColor(0xFFFFFF)
- message.channel.send(embed)
- }
- });
- }
- if (command === "retired-sdmg") {
- if (!args[0]) return message.channel.send("Sadist...")
- con.query(`SELECT * FROM shiplist WHERE name = '${args[0].toLowerCase()}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send("Sadist...");
- } else {
- let nm = rows[0].name; let name = nm.charAt(0).toUpperCase() + nm.slice(1);
- let dmg = rows[0].dmg; let imgcarddmg = rows[0].imgcarddmg;
- if (rows[0].intro === "filler") return message.channel.send("Tell Karen to fucking add it smh")
- let embed = new Discord.RichEmbed()
- .addField(name, dmg)
- .setImage(imgcarddmg)
- .setColor(0xFFFFFF)
- message.channel.send(embed)
- }
- });
- }
- if (command === "retired-sbnr") {
- if (!args[0]) return message.channel.send("Specify a ship.")
- con.query(`SELECT * FROM shiplist WHERE name = '${args[0].toLowerCase()}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send("The ship was not found.");
- } else {
- let nm = rows[0].name; let name = nm.charAt(0).toUpperCase() + nm.slice(1);
- let dmg = rows[0].dmg; let imgcardbnr = rows[0].imgbanner;
- if (rows[0].intro === "filler") return message.channel.send("Tell Karen to fucking add it smh")
- let embed = new Discord.RichEmbed()
- .addField(name, "Banner is shown in combat.")
- .setImage(imgcardbnr)
- .setColor(0xFFFFFF)
- message.channel.send(embed)
- }
- });
- }
- if (command === "retired-list") {
- con.query(`SELECT * FROM shiplist`, (err, rows) => {
- let hgf = rows.name
- message.channel.send(hgf.toString())
- });
- }
- // Command R02 "Refuel" ----------
- if (command === "refuel") {
- let sqlFill = "DELETE FROM fill"
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql;
- if (rows.length < 1) {
- sql = sqlFill
- message.channel.send("You first need to register!");
- } else {
- let fuel = rows[0].fuel;
- let fuelup = rows[0].fuelup;
- sql = `UPDATE account SET fuel = ${fuel+75+(fuelup*25)} WHERE id = '${message.author.id}'`;
- message.channel.send(`You have refueled **${75+(fuelup*25)}**${IconFuel} !`)
- }
- con.query(sql);
- });
- }
- // Command TXX "Ship" ------------
- if (command === "ship") {
- if (!args[0]) return message.channel.send("Specify a ship.")
- con.query(`SELECT * FROM azurlist WHERE source = '${message.content.toLowerCase().replace(";ship ", "").replace(" ", "")}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send("That's not an actual ship!");
- } else {
- let id = rows[0].id; let source = rows[0].source; let name = rows[0].name;
- let type1 = rows[0].type1; let type2 = rows[0].type2; let type3 = rows[0].type3;
- let nation1 = rows[0].nation1; let nation2 = rows[0].nation2; let nation3 = rows[0].nation3;
- let rarity1 = rows[0].rarity1; let rarity2 = rows[0].rarity2; let rarity3 = rows[0].rarity3;
- let status1 = rows[0].status1; let status2 = rows[0].status2;
- let thumbnail = rows[0].thumbnail; let image = rows[0].imagecg;
- let type4 = bot.emojis.find("name", `${type3}`)
- //let type4 = eval('({' + str + '})');
- let embed = new Discord.RichEmbed()
- .setTitle(`[${status1}] ${name}`)
- .setDescription(`${name} is a ${type2} from the ${nation2}.\nShe has a ${rarity2} rarity and can be obtained through construction.`)
- .addField("Type", `[**${type1}**] ${type4}${type2}`)
- .addField("Rarity", `[**${rarity1}**] ${rarity2}`)
- .addField("Nation", `[**${nation1}**] ${nation2}`)
- .setThumbnail(thumbnail)
- .setImage(image)
- .setColor(0x9ffff9)
- message.channel.send(embed)
- }
- });
- }
- // Command TXX "Ship" ------------
- if (command === "myship") {
- if (!args[0]) return message.channel.send("Specify a ship.")
- con.query(`SELECT * FROM azurlist WHERE source = '${message.content.toLowerCase().replace(";ship ", "").replace(" ", "")}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send("That's not an actual ship!");
- } else {
- let id = rows[0].id; let source = rows[0].source; let name = rows[0].name;
- let type1 = rows[0].type1; let type2 = rows[0].type2; let type3 = rows[0].type3;
- let nation1 = rows[0].nation1; let nation2 = rows[0].nation2; let nation3 = rows[0].nation3;
- let rarity1 = rows[0].rarity1; let rarity2 = rows[0].rarity2; let rarity3 = rows[0].rarity3;
- let status1 = rows[0].status1; let status2 = rows[0].status2;
- let thumbnail = rows[0].thumbnail; let image = rows[0].imagecg;
- let type4 = bot.emojis.find("name", `${type3}`)
- //let type4 = eval('({' + str + '})');
- let embed = new Discord.RichEmbed()
- .setTitle(`[${status1}] ${name}`)
- .setDescription(`${name} is a ${type2} from the ${nation2}.\nShe has a ${rarity2} rarity and can be obtained through construction.`)
- .addField("Type", `[**${type1}**] ${type4}${type2}`)
- .addField("Rarity", `[**${rarity1}**] ${rarity2}`)
- .addField("Nation", `[**${nation1}**] ${nation2}`)
- .setThumbnail(thumbnail)
- .setImage(image)
- .setColor(0x9ffff9)
- message.channel.send(embed)
- }
- });
- }
- // Command TXX "Tcoin" -----------
- if (command === "tcoin") {
- let sqlFill = "DELETE FROM fill"
- if (isNaN(args[0])) return message.channel.send("numbers fag");
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql;
- if (rows.length < 1) {
- sql = sqlFill
- message.channel.send("You first need to register!");
- } else {
- let coin = rows[0].coin;
- sql = `UPDATE account SET coin = ${clamp(coin + Number(args[0]), -9999999, 9999999)} WHERE id = '${message.author.id}'`;
- message.channel.send(`given ${clamp(Number(args[0]), -9999999, 9999999)} coins to your bal nts remove command`)
- }
- con.query(sql);
- });
- }
- // Command U01 "Upgrade" ---------
- if (command === "upgrade") {
- let sqlfill = `DELETE FROM fill`
- if (message.member.roles.find("name", "Non-Registered Member")) return message.channel.send("You have not registered");
- if (!args[0]) return message.channel.send("`Type in ;help upgrade for assistance.`");
- // Upgrade for fuel
- if (args[0].toLowerCase() === "fuel") {
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err; let sql1; let sql2;
- if (rows.length < 1) {
- sql1 = sqlfill; sql2 = sqlfill
- message.channel.send("You first need to register!");
- } else {
- let coin = rows[0].coin;
- let fuel = rows[0].fuel;
- let fuelup = rows[0].fuelup;
- if (coin >= fuelup*500) {
- sql1 = `UPDATE account SET coin = ${coin-(fuelup*500)} WHERE id = '${message.author.id}'`
- sql2 = `UPDATE account SET fuelup = ${fuelup+1} WHERE id = '${message.author.id}'`;
- message.channel.send(`You have upgraded your tank to yield more fuel!\nIt costed you ${fuelup*500} coins!\nRefuel level ${fuelup+1}`)
- } else {
- sql1 = sqlfill; sql2 = sqlfill
- message.channel.send(`You dont have enough coins! You need ${fuelup*500} coins to upgrade`)
- }
- }
- con.query(sql1); con.query(sql2);
- });
- } else {
- // Upgrade others
- message.channel.send("`You can only upgrade your fuel station atm`")
- }
- }
- // Command E01 "Expedition" ------
- if (command === "expedition") {
- let sqlfill = `DELETE FROM fill`
- if (message.member.roles.find("name", "Non-Registered Member")) return message.channel.send("You have not registered");
- if (!args[0]) return message.channel.send("`Type in ;help upgrade for assistance.`");
- // Upgrade for fuel
- if (args[0].toLowerCase() === "fuel") {
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- let coin = rows[0].coin;
- let fuel = rows[0].fuel;
- let fuelup = rows[0].fuelup;
- if (err) throw err;
- let sql1; let sql2;
- if (rows.length < 1) {
- sql1 = sqlfill; sql2 = sqlfill
- message.channel.send("You first need to register!");
- } else {
- if (coin >= fuelup*500) {
- sql1 = `UPDATE account SET coin = ${coin-(fuelup*500)} WHERE id = '${message.author.id}'`
- sql2 = `UPDATE account SET fuelup = ${fuelup+1} WHERE id = '${message.author.id}'`;
- message.channel.send(`You have upgraded your tank to yield more fuel!\nIt costed you ${fuelup*500} coins!\nRefuel level ${fuelup+1}`)
- } else {
- sql1 = sqlfill; sql2 = sqlfill
- message.channel.send(`You dont have enough coins! You need ${fuelup*500} coins to upgrade`)
- }
- }
- con.query(sql1); con.query(sql2);
- });
- } else {
- // Upgrade others
- message.channel.send("`You can only upgrade your fuel station atm`")
- }
- }
- // Command I01 "Information" -----
- if (command === "info") {
- con.query(`SELECT * FROM account WHERE id = '${message.author.id}'`, (err, rows) => {
- if (err) throw err;
- if (rows.length < 1) {
- message.channel.send("You first need to register!");
- } else {
- let coin = rows[0].coin; let fuel = rows[0].fuel; let ruby = rows[0].ruby;
- let cube = rows[0].blue; let drill = rows[0].drill;
- let fuelup = rows[0].fuelup;
- let secretary = rows[0].secretary;
- let embed = new Discord.RichEmbed()
- .setTitle(`${message.author.username}'s account`)
- // .setDescription(`${message.author.username}, you currently have ${coin} coins, ${fuel}, fuel and ${ruby} rubies! Your current secretary ship is ----`)
- .setDescription(`Refuel station level ${fuelup}.\nYou get ${75+(fuelup*25)} per refuel`)
- .addField("Balance and Fuel", `**${coin}** ${IconCoin} **${fuel}** ${IconFuel} **${ruby}** ${IconRuby}`)
- // .addField("Coin", `**${coin}** ${IconCoin}`)
- // .addField("Fuel", `**${fuel}** ${IconFuel}`)
- // .addField("Ruby", `**${ruby}** ${IconRuby}`)
- .addField("Construction Materials", `**${cube}** ${IconCube} **${drill}** ${IconDrill}`)
- .addField("Secretary Ship", secretary)
- .setThumbnail(message.author.avatarURL)
- .setColor(0x9ffff9)
- message.channel.send(embed)
- }
- });
- }
- // --------END-----------------------
- });
- bot.on("message", async message => {
- if (message.author.bot) return;
- if (message.channel.type === "dm") return;
- if (!message.content.startsWith(prefix)) return;
- const args = message.content.slice(prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- if (command === "test") {
- let embed = new Discord.RichEmbed()
- .setTitle(`${message.author.username}'s account`)
- .setThumbnail("https://azurlane.koumakan.jp/w/images/thumb/0/0c/Universal_BullinShipyardIcon.png/100px-Universal_BullinShipyardIcon.png")
- .setImage("https://azurlane.koumakan.jp/w/images/thumb/0/0c/Universal_BullinShipyardIcon.png/100px-Universal_BullinShipyardIcon.png")
- message.channel.send(embed)
- }
- if (command === "cleardb") {
- con.query(`DELETE FROM account WHERE id;`);
- con.query(`DELETE FROM stats;`);
- message.channel.send("Cleared databse nts; remove this command when done debugging")
- }
- if (command === "clearrole") {
- let RRole = message.guild.roles.find("name", "Registered Member")
- let NRole = message.guild.roles.find("name", "Non-Registered Member")
- message.member.removeRole(RRole)
- message.member.addRole(NRole)
- message.channel.send("Reset your role nts; remove this command when done debugging")
- }
- if (command === "clearall") {
- con.query(`DELETE FROM account;`);
- con.query(`DELETE FROM stats;`);
- let RRole = message.guild.roles.find("name", "Registered Member")
- let NRole = message.guild.roles.find("name", "Non-Registered Member")
- message.member.removeRole(RRole)
- message.member.addRole(NRole)
- message.channel.send("Cleared databse and your role has been reset nts; remove this command when done debugging")
- }
- });
- bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement