Skip to content

Commit

Permalink
refactor(*): cleaning up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
alhassanv committed Aug 23, 2020
1 parent f84a122 commit 613cf2b
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 411 deletions.
45 changes: 45 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2019
},
"rules": {
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
"indent": ["error", "tab"],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
}
}
85 changes: 39 additions & 46 deletions commands/credentials.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
exports.run = (client, message, args) => {
const Discord = require("discord.js");
const mysql = require('mysql')
exports.run = (client, message) => {
const Discord = require('discord.js');
const con = require('../utils/dbConnector');

const con = mysql.createConnection({
connectionLimit: 20,
host: client.config.mysqlHOST,
port: "3306",
user: client.config.mysqlUSER,
password: client.config.mysqlPASS,
database: client.config.mysqlDB,
});

var userid = message.author.id;
con.query(`SELECT * FROM users WHERE discord_id = '${userid}'`, function (err, result, fields) {

let noCon = new Discord.MessageEmbed()
.setAuthor("CloudServer ¦ Credentials", client.user.avatarURL())
.setColor("FF0009")
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription("```There was an error connecting to the database. Please report this issue to a member of the staffteam```")
const userid = message.author.id;
con.query(`SELECT * FROM users WHERE discord_id = '${userid}'`, (err, result) => {

if (err) return message.channel.send(noCon);

if (result.length == 0) {
let noReg = new Discord.MessageEmbed()
.setAuthor("CloudServer ¦ Credentials", client.user.avatarURL())
.setColor("FF0009")
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription("```You are not a registered user. Please register yourself with "+client.config.prefix+"register to unlock this command```")
message.channel.send(noReg);
} else {
var Database = JSON.parse(JSON.stringify(result[0]));
let sent = new Discord.MessageEmbed()
.setAuthor("CloudServer ¦ Credentials", client.user.avatarURL())
.setColor("DE4BFF")
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription("```Your credentials has been sent to you```")
message.channel.send(sent);

let embed = new Discord.MessageEmbed()
.setAuthor("CloudServer ¦ Credentials", client.user.avatarURL())
.setColor("DE4BFF")
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription("**__User Credentials For CloudServer__**```Email: "+Database.email+"\nUsername: "+Database.pterodactyl_username+"\nPassword: "+Database.pterodactyl_password+"```")
message.author.send(embed);
}
});
}
const noCon = new Discord.MessageEmbed()
.setAuthor('CloudServer ¦ Credentials', client.user.avatarURL())
.setColor('FF0009')
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription('```There was an error connecting to the database. Please report this issue to a member of the staffteam```');

if (err) return message.channel.send(noCon);

if (result.length == 0) {
const noReg = new Discord.MessageEmbed()
.setAuthor('CloudServer ¦ Credentials', client.user.avatarURL())
.setColor('FF0009')
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription('```You are not a registered user. Please register yourself with ' + client.config.prefix + 'register to unlock this command```');
message.channel.send(noReg);
}
else {
const Database = JSON.parse(JSON.stringify(result[0]));
const sent = new Discord.MessageEmbed()
.setAuthor('CloudServer ¦ Credentials', client.user.avatarURL())
.setColor('DE4BFF')
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription('```Your credentials has been sent to you```');
message.channel.send(sent);

const embed = new Discord.MessageEmbed()
.setAuthor('CloudServer ¦ Credentials', client.user.avatarURL())
.setColor('DE4BFF')
.setFooter(`💕CloudServer Alpha | CodeCannibals\nRequested By ➤ ${message.author.tag}`, client.user.avatarURL())
.setDescription('**__User Credentials For CloudServer__**```Email: ' + Database.email + '\nUsername: ' + Database.pterodactyl_username + '\nPassword: ' + Database.pterodactyl_password + '```');
message.author.send(embed);
}
});
};
Loading

0 comments on commit 613cf2b

Please sign in to comment.