mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 09:05:41 +01:00
Fix EsLint warnings and add some files to .gitignore (#60)
* Silence git about my local IDE files This was copy-pasted from Citras .gitignore file. * Fix some typos * Prevent coercion warning * Fix the rest of EsLinter warnings Fixes wrong spacing, missing semicolons, unecessary RegEx escapes, unecessary undefined init and unused variables. * Replace var with const or let
This commit is contained in:
parent
c3cc3820d4
commit
9a1a207d2c
7
.gitignore
vendored
7
.gitignore
vendored
@ -42,3 +42,10 @@ jspm_packages
|
|||||||
# Configuration
|
# Configuration
|
||||||
config/production.json
|
config/production.json
|
||||||
config/development.json
|
config/development.json
|
||||||
|
|
||||||
|
# Project/editor files
|
||||||
|
*.swp
|
||||||
|
.idea/
|
||||||
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
CMakeLists.txt.user*
|
||||||
|
@ -6,7 +6,7 @@ const UserBan = require('../models/UserBan.js');
|
|||||||
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
var count = state.warnings.filter(x => x.id === user.id && !x.cleared).length || 0;
|
const count = state.warnings.filter(x => x.id === user.id && !x.cleared).length || 0;
|
||||||
|
|
||||||
logger.info(`${message.author.toString()} has banned ${user.toString()} ${user} ${user.username}.`);
|
logger.info(`${message.author.toString()} has banned ${user.toString()} ${user} ${user.username}.`);
|
||||||
state.logChannel.send(`${message.author} has banned ${user} ${user.username} [${count}].`);
|
state.logChannel.send(`${message.author} has banned ${user} ${user.username} [${count}].`);
|
||||||
|
@ -5,7 +5,7 @@ const logger = require('../logging.js');
|
|||||||
exports.roles = ['Admins', 'Moderators'];
|
exports.roles = ['Admins', 'Moderators'];
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
var count = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
const count = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
||||||
if (count != null && count.length > 0) {
|
if (count != null && count.length > 0) {
|
||||||
count.forEach(warning => { warning.cleared = true; });
|
count.forEach(warning => { warning.cleared = true; });
|
||||||
data.flushWarnings();
|
data.flushWarnings();
|
||||||
|
@ -34,7 +34,7 @@ async function updateDatabase() {
|
|||||||
directory: x.directory,
|
directory: x.directory,
|
||||||
title: x.title,
|
title: x.title,
|
||||||
compatibility: x.compatibility
|
compatibility: x.compatibility
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
state.lastGameDBUpdate = Date.now();
|
state.lastGameDBUpdate = Date.now();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
var role = process.env.DISCORD_DEVELOPER_ROLE
|
const role = process.env.DISCORD_DEVELOPER_ROLE;
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
let member = message.guild.member(user);
|
let member = message.guild.member(user);
|
||||||
let alreadyJoined = member.roles.has(role);
|
let alreadyJoined = member.roles.has(role);
|
||||||
@ -13,4 +13,4 @@ exports.command = function (message) {
|
|||||||
message.channel.send(`${user} has been granted speech in the #development channel.`);
|
message.channel.send(`${user} has been granted speech in the #development channel.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
const request = require('request');
|
const request = require('request');
|
||||||
const logger = require('../logging.js');
|
|
||||||
|
|
||||||
exports.roles = ['Admins', 'Moderators', 'Developers'];
|
exports.roles = ['Admins', 'Moderators', 'Developers'];
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
@ -10,21 +9,18 @@ exports.command = function (message) {
|
|||||||
|
|
||||||
request({ url: url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)' } }, function (error, response, body) {
|
request({ url: url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)' } }, function (error, response, body) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
var pr = JSON.parse(body);
|
const pr = JSON.parse(body);
|
||||||
request({ url: pr.statuses_url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)'}}, function(error, response, body)
|
request({ url: pr.statuses_url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)' } }, function (error, response, body) {
|
||||||
{
|
const statuses = JSON.parse(body);
|
||||||
var statuses = JSON.parse(body);
|
|
||||||
|
|
||||||
if (statuses.length == 0) return;
|
if (statuses.length === 0) return;
|
||||||
|
|
||||||
// Travis CI will give you multiple, identical target URLs so we might as well just check the first one...
|
// Travis CI will give you multiple, identical target URLs so we might as well just check the first one...
|
||||||
var status = statuses[0];
|
const status = statuses[0];
|
||||||
status.target_url = status.target_url.substr(0, status.target_url.indexOf('?'));
|
status.target_url = status.target_url.substr(0, status.target_url.indexOf('?'));
|
||||||
message.channel.sendMessage(`${status.context}: ${status.target_url}: **${status.state}**`);
|
message.channel.sendMessage(`${status.context}: ${status.target_url}: **${status.state}**`);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
message.channel.sendMessage('No such PR.');
|
message.channel.sendMessage('No such PR.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,7 @@ const UserWarning = require('../models/UserWarning.js');
|
|||||||
exports.roles = ['Admins', 'Moderators'];
|
exports.roles = ['Admins', 'Moderators'];
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
var count = state.warnings.filter(x => x.id === user.id && !x.cleared).length || 0;
|
const count = state.warnings.filter(x => x.id === user.id && !x.cleared).length || 0;
|
||||||
message.channel.send(`${user} You have been warned. Additional infractions may result in a ban.`);
|
message.channel.send(`${user} You have been warned. Additional infractions may result in a ban.`);
|
||||||
|
|
||||||
logger.info(`${message.author.username} ${message.author} has warned ${user.username} ${user} [${count} + 1].`);
|
logger.info(`${message.author.username} ${message.author} has warned ${user.username} ${user} [${count} + 1].`);
|
||||||
|
@ -2,7 +2,7 @@ const state = require('../state.js');
|
|||||||
|
|
||||||
exports.command = function (message) {
|
exports.command = function (message) {
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
var warnings = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
const warnings = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
||||||
message.channel.send(`${user}, you have ${warnings.length} total warnings.`);
|
message.channel.send(`${user}, you have ${warnings.length} total warnings.`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ const logger = require('./logging.js');
|
|||||||
|
|
||||||
function readWarnings () {
|
function readWarnings () {
|
||||||
// Load the warnings file into the application state.
|
// Load the warnings file into the application state.
|
||||||
var readFilePath = '/data/discordWarnings.json';
|
const readFilePath = '/data/discordWarnings.json';
|
||||||
fs.readFile(readFilePath, 'utf8', function (err, data) {
|
fs.readFile(readFilePath, 'utf8', function (err, data) {
|
||||||
if (err) { throw err; }
|
if (err) { throw err; }
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -18,7 +18,7 @@ function readWarnings() {
|
|||||||
|
|
||||||
function readBans () {
|
function readBans () {
|
||||||
// Load the ban file into the application state.
|
// Load the ban file into the application state.
|
||||||
var readFilePath = '/data/discordBans.json';
|
const readFilePath = '/data/discordBans.json';
|
||||||
fs.readFile(readFilePath, 'utf8', function (err, data) {
|
fs.readFile(readFilePath, 'utf8', function (err, data) {
|
||||||
if (err) { throw err; }
|
if (err) { throw err; }
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -37,14 +37,14 @@ function readCustomResponses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function flushWarnings () {
|
function flushWarnings () {
|
||||||
var warningsJson = JSON.stringify(state.warnings, null, 4);
|
const warningsJson = JSON.stringify(state.warnings, null, 4);
|
||||||
fs.writeFile('/data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
fs.writeFile('/data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
||||||
if (err) { throw err; }
|
if (err) { throw err; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushBans () {
|
function flushBans () {
|
||||||
var bansJson = JSON.stringify(state.bans, null, 4);
|
const bansJson = JSON.stringify(state.bans, null, 4);
|
||||||
fs.writeFile('/data/discordBans.json', bansJson, 'utf8', function (err) {
|
fs.writeFile('/data/discordBans.json', bansJson, 'utf8', function (err) {
|
||||||
if (err) { throw err; }
|
if (err) { throw err; }
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ const os = require('os');
|
|||||||
|
|
||||||
winston.emitErrs = true;
|
winston.emitErrs = true;
|
||||||
|
|
||||||
var logger = new winston.Logger({
|
const logger = new winston.Logger({
|
||||||
level: 'debug',
|
level: 'debug',
|
||||||
transports: [
|
transports: [
|
||||||
new (winston.transports.Console)()
|
new (winston.transports.Console)()
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"( ͡° ͜ʖ ͡°)": { "reply": "lenny"},
|
"( ͡° ͜ʖ ͡°)": { "reply": "lenny"},
|
||||||
"format": { "reply": "A full description of game formats the yuzu supports and when to use them can be found on our wiki. <https://yuzu-emu.org/wiki/overview-of-switch-game-formats/>"},
|
"format": { "reply": "A full description of game formats the yuzu supports and when to use them can be found on our wiki. <https://yuzu-emu.org/wiki/overview-of-switch-game-formats/>"},
|
||||||
"keys": { "reply": "Most games require encryption keys to boot. You can dump them from your Switch by following this guide. <https://yuzu-emu.org/help/quickstart/#keys>"},
|
"keys": { "reply": "Most games require encryption keys to boot. You can dump them from your Switch by following this guide. <https://yuzu-emu.org/help/quickstart/#keys>"},
|
||||||
"game-updates": { "reply": "Installing and using game updates are a seperate process from the base game. Check out our updates tutorial on our wiki. <https://yuzu-emu.org/wiki/how-to-install-and-use-game-updates/>"},
|
"game-updates": { "reply": "Installing and using game updates are a separate process from the base game. Check out our updates tutorial on our wiki. <https://yuzu-emu.org/wiki/how-to-install-and-use-game-updates/>"},
|
||||||
"log": { "reply": "This forum topic tells you how to __get the log file__: <https://community.citra-emu.org/t/how-to-upload-the-log-file/296>"},
|
"log": { "reply": "This forum topic tells you how to __get the log file__: <https://community.citra-emu.org/t/how-to-upload-the-log-file/296>"},
|
||||||
"pikachu": { "reply": "https://cdn.discordapp.com/attachments/512678820092968971/516372335826042901/yote.png"},
|
"pikachu": { "reply": "https://cdn.discordapp.com/attachments/512678820092968971/516372335826042901/yote.png"},
|
||||||
"quickstart": { "reply": "Please reference the __Quickstart Guide__ in order to dump your games, keys, and system files for use with yuzu. <https://yuzu-emu.org/help/quickstart/>"}
|
"quickstart": { "reply": "Please reference the __Quickstart Guide__ in order to dump your games, keys, and system files for use with yuzu. <https://yuzu-emu.org/help/quickstart/>"}
|
||||||
|
@ -12,9 +12,9 @@ const data = require('./data.js');
|
|||||||
|
|
||||||
state.responses = require('./responses.json');
|
state.responses = require('./responses.json');
|
||||||
|
|
||||||
var cachedModules = [];
|
let cachedModules = [];
|
||||||
var cachedTriggers = [];
|
let cachedTriggers = [];
|
||||||
var client = new discord.Client();
|
const client = new discord.Client();
|
||||||
|
|
||||||
let mediaUsers = new Map();
|
let mediaUsers = new Map();
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ function findArray(haystack, arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
// Initalize app channels.
|
// Initialize app channels.
|
||||||
state.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
state.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
||||||
state.guild = state.logChannel.guild;
|
state.guild = state.logChannel.guild;
|
||||||
|
|
||||||
@ -44,22 +44,22 @@ client.on('ready', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('error', (x) => {
|
client.on('error', (x) => {
|
||||||
logger.error(x)
|
logger.error(x);
|
||||||
logger.error('Restarting process.')
|
logger.error('Restarting process.');
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
})
|
});
|
||||||
client.on('warn', (x) => {
|
client.on('warn', (x) => {
|
||||||
logger.warn(x)
|
logger.warn(x);
|
||||||
})
|
});
|
||||||
|
|
||||||
client.on('debug', (x) => null)
|
client.on('debug', (x) => null);
|
||||||
|
|
||||||
client.on('disconnect', () => {
|
client.on('disconnect', () => {
|
||||||
logger.warn('Disconnected from Discord server.');
|
logger.warn('Disconnected from Discord server.');
|
||||||
})
|
});
|
||||||
client.on('reconnecting', () => {
|
client.on('reconnecting', () => {
|
||||||
logger.warn('Reconnecting...');
|
logger.warn('Reconnecting...');
|
||||||
})
|
});
|
||||||
|
|
||||||
client.on('guildMemberAdd', (member) => {
|
client.on('guildMemberAdd', (member) => {
|
||||||
member.addRole(process.env.DISCORD_RULES_ROLE);
|
member.addRole(process.env.DISCORD_RULES_ROLE);
|
||||||
@ -157,7 +157,7 @@ client.on('message', message => {
|
|||||||
try {
|
try {
|
||||||
// Check if the command requires a warning.
|
// Check if the command requires a warning.
|
||||||
if (cmd !== 'warn' && cachedModule.warn === true) {
|
if (cmd !== 'warn' && cachedModule.warn === true) {
|
||||||
// Access check to see if the user has privilages to warn.
|
// Access check to see if the user has privileges to warn.
|
||||||
let warnCommand = cachedModules['warn.js'];
|
let warnCommand = cachedModules['warn.js'];
|
||||||
if (findArray(message.member.roles.map(function (x) { return x.name; }), warnCommand.roles)) {
|
if (findArray(message.member.roles.map(function (x) { return x.name; }), warnCommand.roles)) {
|
||||||
// They are allowed to warn because they are in warn's roles.
|
// They are allowed to warn because they are in warn's roles.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Application State */
|
/* Application State */
|
||||||
var State = function () {
|
const State = function () {
|
||||||
this.guild = null;
|
this.guild = null;
|
||||||
this.logChannel = null;
|
this.logChannel = null;
|
||||||
this.warnings = [];
|
this.warnings = [];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
const regex = /[^\<\\]\#(\d+)/ig;
|
const regex = /[^<\\]#(\d+)/ig;
|
||||||
|
|
||||||
exports.trigger = function (message) {
|
exports.trigger = function (message) {
|
||||||
return new RegExp(regex).test(message.content);
|
return new RegExp(regex).test(message.content);
|
||||||
@ -33,7 +33,6 @@ exports.execute = function (message) {
|
|||||||
let url = `https://github.com/${repo}/pull/${match[1]}`;
|
let url = `https://github.com/${repo}/pull/${match[1]}`;
|
||||||
request(url, function (error, response, body) {
|
request(url, function (error, response, body) {
|
||||||
if (!error && response.statusCode === 200) {
|
if (!error && response.statusCode === 200) {
|
||||||
|
|
||||||
// Set path to type of comment (issues/pull)
|
// Set path to type of comment (issues/pull)
|
||||||
let path = response.request.uri.pathname.split('/')[3];
|
let path = response.request.uri.pathname.split('/')[3];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user