mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 09:55:39 +01:00
commit
0429aed636
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
# Data folder.
|
||||
data/
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
@ -4,20 +4,20 @@ var data = require('../data.js');
|
||||
var logger = require('../logging.js');
|
||||
var UserBan = require('../models/UserBan.js');
|
||||
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret', 'CitraBot'];
|
||||
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
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.`);
|
||||
logger.info(`${message.author.toString()} has banned ${user.toString()}.`);
|
||||
app.logChannel.sendMessage(`${message.author} has banned ${user} [${count} + 1].`);
|
||||
message.channel.sendMessage(`${user} ${user.username}, You will now be banned from this channel.`);
|
||||
logger.info(`${message.author.toString()} has banned ${user.toString()} ${user} ${user.username}.`);
|
||||
app.logChannel.sendMessage(`${message.author} has banned ${user} ${user.username} [${count}].`);
|
||||
|
||||
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);
|
||||
app.logChannel.sendMessage(`Error banning ${user} ${user.username}`);
|
||||
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
||||
});
|
||||
data.flushBans();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
var app = require('../app.js');
|
||||
var logger = require('../logging.js');
|
||||
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret'];
|
||||
exports.roles = ['Admins', 'Moderators'];
|
||||
exports.command = function(message, reply) {
|
||||
let replyMessage = 'Hello.';
|
||||
if (reply == null) {
|
||||
|
@ -4,7 +4,7 @@ var data = require('../data.js');
|
||||
var logger = require('../logging.js');
|
||||
var UserWarning = require('../models/UserWarning.js');
|
||||
|
||||
exports.roles = ['Admins', 'Moderators', 'Secret', 'Helpers'];
|
||||
exports.roles = ['Admins', 'Moderators'];
|
||||
exports.command = function(message) {
|
||||
message.mentions.users.map((user) => {
|
||||
var count = app.warnings.filter(x => x.id == user.id && !x.cleared).length || 0;
|
||||
|
@ -19,7 +19,7 @@ var logger = new winston.Logger({
|
||||
exitOnError: false
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV == 'production') {
|
||||
if (process.env.NODE_ENV == 'production' && config.logdnaKey) {
|
||||
// Setup logging for LogDNA cloud logging.
|
||||
logger.add(winston.transports.Logdna, {
|
||||
level: 'info',
|
||||
|
21
server.js
21
server.js
@ -17,6 +17,10 @@ function findArray(haystack, arr) {
|
||||
});
|
||||
};
|
||||
|
||||
process.on('unhandledRejection', function onError(err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
// Initalize app channels.
|
||||
app.logChannel = client.channels.get(config.logChannel);
|
||||
@ -66,12 +70,19 @@ client.on('message', message => {
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
// Warn after running command?
|
||||
try {
|
||||
// Check if the command requires a warning.
|
||||
if (cmd != 'warn' && cachedModule.warn == true) {
|
||||
cachedModules['warn.js'].command(message);
|
||||
// Access check to see if the user has privilages to warn.
|
||||
let warnCommand = cachedModules['warn.js'];
|
||||
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.
|
||||
warnCommand.command(message);
|
||||
}
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
} else {
|
||||
// Not a valid command.
|
||||
}
|
||||
@ -95,9 +106,13 @@ cachedModules = [];
|
||||
require("fs").readdirSync('./commands/').forEach(function(file) {
|
||||
// Load the module if it's a script.
|
||||
if (path.extname(file) == '.js') {
|
||||
if (file.includes('.disabled')) {
|
||||
logger.info(`Did not load disabled module: ${file}`);
|
||||
} else {
|
||||
logger.info(`Loaded module: ${file}`);
|
||||
cachedModules[file] = require(`./commands/${file}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Cache all triggers.
|
||||
@ -105,9 +120,13 @@ cachedTriggers = [];
|
||||
require("fs").readdirSync('./triggers/').forEach(function(file) {
|
||||
// Load the trigger if it's a script.
|
||||
if (path.extname(file) == '.js') {
|
||||
if (file.includes('.disabled')) {
|
||||
logger.info(`Did not load disabled trigger: ${file}`);
|
||||
} else {
|
||||
logger.info(`Loaded trigger: ${file}`);
|
||||
cachedTriggers.push(require(`./triggers/${file}`));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
data.readWarnings();
|
||||
|
Loading…
Reference in New Issue
Block a user