Code Style Corrections

pull/33/head
Trivernis 6 years ago
parent c0efaf2e80
commit d095922926

@ -197,15 +197,24 @@ class Bot {
// shuts down the bot after destroying the client // shuts down the bot after destroying the client
cmd.createGlobalCommand(prefix + 'shutdown', (msg) => { cmd.createGlobalCommand(prefix + 'shutdown', (msg) => {
msg.reply('Shutting down...').finally(() => { msg.reply('Shutting down...').catch((err) => {
logger.error(err.message);
logger.debug(err.stack);
}).finally(() => {
logger.debug('Destroying client...'); logger.debug('Destroying client...');
this.client.destroy().finally(() => { this.client.destroy().catch((err) => {
logger.error(err.message);
logger.debug(err.stack);
}).finally(() => {
logger.debug('Exiting server...'); logger.debug('Exiting server...');
this.webServer.stop().then(() => { this.webServer.stop().then(() => {
logger.debug(`Exiting Process...`); logger.debug(`Exiting Process...`);
process.exit(0); process.exit(0);
}).catch(() => { }).catch((err) => {
logger.error(err.message);
logger.debug(err.stack);
process.exit(0); process.exit(0);
}); });
}); });
@ -251,15 +260,14 @@ class Bot {
resolve("It's not save here! Try again via PM."); resolve("It's not save here! Try again via PM.");
} else if (argv.username && argv.scope) { } else if (argv.username && argv.scope) {
logger.debug(`Creating user entry ${argv.username}, scope: ${argv.scope}`); logger.debug(`Creating user entry ${argv.username}, scope: ${argv.scope}`);
this.webServer.createUser(argv.username, argv.password, argv.scope, false).then((token) => { this.webServer.createUser(argv.username, argv.password, argv.scope, false).then((token) => {
resolve(`Created entry resolve(`Created entry
username: ${argv.username}, username: ${argv.username},
scope: ${argv.scope}, scope: ${argv.scope},
token: ${token} token: ${token}
`); `);
}).catch((err) => { }).catch((err) => reject(err.message));
reject(err.message);
});
} }
}); });
}, ['username', 'password', 'scope'], 'Generates a token for a username and returns it.', 'owner'); }, ['username', 'password', 'scope'], 'Generates a token for a username and returns it.', 'owner');
@ -271,15 +279,17 @@ class Bot {
rotatePresence() { rotatePresence() {
let pr = this.presences.shift(); let pr = this.presences.shift();
this.presences.push(pr); this.presences.push(pr);
this.client.user.setPresence({ this.client.user.setPresence({
game: {name: `${gamepresence} | ${pr}`, type: "PLAYING"}, game: {name: `${gamepresence} | ${pr}`, type: "PLAYING"},
status: 'online' status: 'online'
}).then(() => logger.debug(`Presence rotation to ${pr}`)); }).then(() => logger.debug(`Presence rotation to ${pr}`))
.catch((err) => logger.warn(err.message));
} }
/** /**
* Registeres callbacks for client events * Registeres callbacks for client events message and ready
*/ */
registerCallbacks() { registerCallbacks() {
this.client.on('error', (err) => { this.client.on('error', (err) => {

@ -51,27 +51,49 @@
"jquery": true, "jquery": true,
"es6": true "es6": true
}, },
"extends": ["eslint:recommended", "plugin:promise/recommended"], "extends": [
"eslint:recommended",
"plugin:promise/recommended"
],
"rules": { "rules": {
"semi": "error", "semi": "error",
"semi-style": [ "semi-style": [
"error", "error",
"last" "last"
], ],
"no-async-promise-executer": "warn",
"no-await-in-loop": "warn", "no-await-in-loop": "warn",
"curly": [ "curly": [
"warn", "warn",
"multi", "multi",
"consistent" "consistent"
], ],
"block-spacing": ["warn", "always"], "block-spacing": [
"array-bracket-newline": ["warn", "consistent"], "warn",
"camelcase": ["error", {"properties": "always"}], "always"
"comma-spacing": ["error", {"after": true}], ],
"brace-style": ["error", "1tbs"], "array-bracket-newline": [
"warn",
"consistent"
],
"camelcase": [
"error",
{
"properties": "always"
}
],
"comma-spacing": [
"error",
{
"after": true
}
],
"brace-style": [
"error",
"1tbs"
],
"promise/no-promise-in-callback": "off", "promise/no-promise-in-callback": "off",
"promise/always-return": "off" "promise/always-return": "off",
"promise/catch-or-return": "off"
}, },
"plugins": [ "plugins": [
"eslint-plugin-graphql", "eslint-plugin-graphql",

@ -68,7 +68,7 @@ function queryGuilds() {
} }
}`; }`;
postQuery(query).then((res) => { postQuery(query).then((res) => {
for (let guild of res.data.client.guilds) { for (let guild of res.data.client.guilds)
if ($(`option[value=${guild.id}]`).length === 0) { if ($(`option[value=${guild.id}]`).length === 0) {
let option = document.createElement('option'); let option = document.createElement('option');
option.setAttribute('value', guild.id); option.setAttribute('value', guild.id);
@ -77,7 +77,7 @@ function queryGuilds() {
let guildSelect = document.querySelector('#guild-select'); let guildSelect = document.querySelector('#guild-select');
guildSelect.appendChild(option); guildSelect.appendChild(option);
} }
}
}); });
} }
@ -220,11 +220,11 @@ function queryStatus() {
document.querySelector('#client-guildCount').innerText = d.client.guildCount; document.querySelector('#client-guildCount').innerText = d.client.guildCount;
document.querySelector('#client-vcCount').innerText = d.client.voiceConnectionCount; document.querySelector('#client-vcCount').innerText = d.client.voiceConnectionCount;
if (d.client.status !== 0) { if (d.client.status !== 0)
document.querySelector('#status-indicator').setAttribute('status', 'offline'); document.querySelector('#status-indicator').setAttribute('status', 'offline');
} else { else
document.querySelector('#status-indicator').setAttribute('status', d.client.user.presence.status); document.querySelector('#status-indicator').setAttribute('status', d.client.user.presence.status);
}
document.querySelector('#user-game').innerText = d.client.user.presence.game; document.querySelector('#user-game').innerText = d.client.user.presence.game;
setTimeout(() => { setTimeout(() => {
@ -247,7 +247,7 @@ function queryLogs(count) {
}`; }`;
postQuery(query).then((res) => { postQuery(query).then((res) => {
let d = res.data; let d = res.data;
for (let logEntry of d.logs) { for (let logEntry of d.logs)
if (!latestLogs.find((x) => x.id === logEntry.id)) { if (!latestLogs.find((x) => x.id === logEntry.id)) {
let entryElem = document.createElement('div'); let entryElem = document.createElement('div');
entryElem.setAttribute('class', 'logEntry text-left'); entryElem.setAttribute('class', 'logEntry text-left');
@ -272,15 +272,15 @@ function queryLogs(count) {
let logContainer = document.querySelector('#log-container'); let logContainer = document.querySelector('#log-container');
logContainer.insertBefore(entryElem, logContainer.firstChild); logContainer.insertBefore(entryElem, logContainer.firstChild);
} }
}
latestLogs = d.logs; latestLogs = d.logs;
}); });
} }
function startUpdating() { function startUpdating() {
if (!localStorage.apiToken || localStorage.apiToken.length < 0) { if (!localStorage.apiToken || localStorage.apiToken.length < 0)
localStorage.apiToken = prompt('Please provide an api token: '); localStorage.apiToken = prompt('Please provide an api token: ');
}
queryStatic(); queryStatic();
setInterval(queryStatic, 3600000); setInterval(queryStatic, 3600000);
queryStatus(); queryStatus();

Loading…
Cancel
Save