mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-21 22:25:41 +01:00
Use arrow functions, code cleanup.
This commit is contained in:
parent
ab25b2599c
commit
2dbe3421af
@ -7,22 +7,18 @@ var UserBan = require('../models/UserBan.js');
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret', 'CitraBot'];
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
var count = app.warnings.filter(function(x) { return x.id == user.id && !x.cleared }).length || 0;
|
||||
var count = app.warnings.filter(x => x.id == user.id && !x.cleared).length || 0;
|
||||
|
||||
message.channel.sendMessage(`${user} You will now be banned from this channel.`).catch(function (error) {
|
||||
logger.error('Error sending #admin-log message.', error);
|
||||
});
|
||||
|
||||
logger.info(`${message.author.username} ${message.author} has banned ${user.username} ${user}.`);
|
||||
app.logChannel.sendMessage(`${message.author} has banned ${user} [${count} + 1].`).catch(function (error) {
|
||||
logger.error('Error sending #admin-log message.', error);
|
||||
});
|
||||
|
||||
message.guild.member(user).ban().catch(function (error) {
|
||||
logger.error(`Error banning ${user.username} ${user.id}.`, error);
|
||||
});
|
||||
message.channel.sendMessage(`${user} You will now be banned from this channel.`);
|
||||
logger.info(`${message.author.toString()} has banned ${user.toString()}.`);
|
||||
app.logChannel.sendMessage(`${message.author} has banned ${user} [${count} + 1].`);
|
||||
|
||||
app.bans.push(new UserBan(user.id, user.username, message.author.id, message.author.username, count));
|
||||
|
||||
message.guild.member(user).ban().catch(function (error) {
|
||||
app.logChannel.sendMessage(`Error banning ${user.toString()}`);
|
||||
logger.error(`Error banning ${user.toString()}.`, error);
|
||||
});
|
||||
data.flushBans();
|
||||
});
|
||||
}
|
||||
|
@ -5,14 +5,13 @@ var logger = require('../logging.js');
|
||||
exports.roles = ['Admins', 'Moderators'];
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
var count = app.warnings.filter(function(x) { return x.id == user.id && !x.cleared }).length || 0;
|
||||
count.forEach(function(warning) {
|
||||
warning.cleared = true;
|
||||
});
|
||||
var count = app.warnings.filter(x => x.id == user.id && !x.cleared).length || 0;
|
||||
|
||||
count.forEach(warning => warning.cleared = true);
|
||||
data.flushWarnings();
|
||||
|
||||
|
||||
message.channel.sendMessage(`${user}, your warnings have been cleared.`);
|
||||
app.logChannel.sendMessage(`${message.author} has cleared all warnings for ${user} [${count}].`);
|
||||
logger.info(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
||||
app.logChannel.sendMessage(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
||||
});
|
||||
}
|
||||
|
@ -4,10 +4,12 @@ var logger = require('../logging.js');
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret'];
|
||||
exports.command = function(message, reply) {
|
||||
let replyMessage = 'Hello.';
|
||||
if (reply == null) { replyMessage = message.content.substr(message.content.indexOf(' ') + 1); }
|
||||
else { replyMessage = `${message.mentions.users.map(function (user) { return `${user}`; })} ${reply}`; }
|
||||
if (reply == null) {
|
||||
replyMessage = message.content.substr(message.content.indexOf(' ') + 1);
|
||||
}
|
||||
else {
|
||||
replyMessage = `${message.mentions.users.map(user => `${user}`)} ${reply}`;
|
||||
}
|
||||
|
||||
message.channel.sendMessage(replyMessage).catch(function (error) {
|
||||
logger.error('Unable to send reply message to quote.', error);
|
||||
});
|
||||
message.channel.sendMessage(replyMessage);
|
||||
}
|
||||
|
@ -2,14 +2,14 @@ var app = require('../app.js');
|
||||
var logger = require('../logging.js');
|
||||
|
||||
exports.command = function(message) {
|
||||
var roleId = '254036987508424714';
|
||||
var alreadyJoined = app.guild.roles.get(roleId).members.find(function(member) { return member.id == message.member.id });
|
||||
|
||||
var role = '254036987508424714';
|
||||
var alreadyJoined = app.guild.roles.get(role).members.find(member => member.id == message.member.id);
|
||||
|
||||
if (alreadyJoined != null) {
|
||||
message.member.removeRole(roleId);
|
||||
message.member.removeRole(role);
|
||||
message.reply('You are no longer part of the testing group.');
|
||||
} else {
|
||||
message.member.addRole(roleId);
|
||||
message.member.addRole(role);
|
||||
message.reply('You are now part of the testing group.');
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,12 @@ var UserWarning = require('../models/UserWarning.js');
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret', 'Helpers'];
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
var count = app.warnings.filter(function(x) { return x.id == user.id && !x.cleared }).length || 0;
|
||||
|
||||
message.channel.sendMessage(`${user} You have been warned. Additional infractions may result in a ban.`).catch(function (error) {
|
||||
logger.error('Error sending #admin-log message.', error);
|
||||
});
|
||||
var count = app.warnings.filter(x => x.id == user.id && !x.cleared).length || 0;
|
||||
message.channel.sendMessage(`${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].`);
|
||||
app.logChannel.sendMessage(`${message.author} has warned ${user} [${count} + 1].`).catch(function (error) {
|
||||
logger.error('Error sending #admin-log message.', error);
|
||||
});
|
||||
|
||||
app.logChannel.sendMessage(`${message.author} has warned ${user} [${count} + 1].`);
|
||||
|
||||
app.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
||||
data.flushWarnings();
|
||||
|
||||
|
@ -3,10 +3,7 @@ var logger = require('../logging.js');
|
||||
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
var count = app.warnings.filter(function(x) { return x.id == user.id && !x.cleared }).length || 0;
|
||||
|
||||
message.channel.sendMessage(`${user}, you have ${count} warnings.`).catch(function (error) {
|
||||
logger.error('Error sending #admin-log message.', error);
|
||||
});
|
||||
var count = app.warnings.filter(x => x.id == user.id && !x.cleared).length || 0;
|
||||
message.channel.sendMessage(`${user}, you have ${count} warnings.`);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user