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