mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-12-23 08:35:28 +00:00
Updated sendMessage to sendMessage. Updated data.js to throw errors.
This commit is contained in:
parent
d3422138ca
commit
7638e40554
|
@ -8,14 +8,14 @@ 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;
|
var count = state.warnings.filter(x => x.id === user.id && !x.cleared).length || 0;
|
||||||
|
|
||||||
message.channel.sendMessage(`${user} ${user.username}, You will now be banned from this channel.`);
|
message.channel.send(`${user} ${user.username}, You will now be banned from this channel.`);
|
||||||
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.sendMessage(`${message.author} has banned ${user} ${user.username} [${count}].`);
|
state.logChannel.send(`${message.author} has banned ${user} ${user.username} [${count}].`);
|
||||||
|
|
||||||
state.bans.push(new UserBan(user.id, user.username, message.author.id, message.author.username, count));
|
state.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) {
|
||||||
state.logChannel.sendMessage(`Error banning ${user} ${user.username}`);
|
state.logChannel.send(`Error banning ${user} ${user.username}`);
|
||||||
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ exports.command = function (message) {
|
||||||
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();
|
||||||
message.channel.sendMessage(`${user}, your warnings have been cleared.`);
|
message.channel.send(`${user}, your warnings have been cleared.`);
|
||||||
} else {
|
} else {
|
||||||
message.channel.sendMessage(`${user}, you have no warnings to clear.`);
|
message.channel.send(`${user}, you have no warnings to clear.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
logger.info(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
||||||
state.logChannel.sendMessage(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
state.logChannel.send(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count}].`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@ exports.command = function (message) {
|
||||||
|
|
||||||
if (alreadyJoined) {
|
if (alreadyJoined) {
|
||||||
member.removeRole(role);
|
member.removeRole(role);
|
||||||
message.channel.sendMessage(`${user}'s speech has been revoked in the #development channel.`);
|
message.channel.send(`${user}'s speech has been revoked in the #development channel.`);
|
||||||
} else {
|
} else {
|
||||||
member.addRole(role);
|
member.addRole(role);
|
||||||
message.channel.sendMessage(`${user} has been granted speech in the #development channel.`);
|
message.channel.send(`${user} has been granted speech in the #development channel.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,5 @@ exports.command = function (message, reply) {
|
||||||
replyMessage = `${message.mentions.users.map(user => `${user}`)} ${reply}`;
|
replyMessage = `${message.mentions.users.map(user => `${user}`)} ${reply}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.channel.sendMessage(replyMessage);
|
message.channel.send(replyMessage);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@ 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;
|
var count = state.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.`);
|
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].`);
|
||||||
state.logChannel.sendMessage(`${message.author} has warned ${user} [${count} + 1].`);
|
state.logChannel.send(`${message.author} has warned ${user} [${count} + 1].`);
|
||||||
|
|
||||||
state.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
state.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
||||||
data.flushWarnings();
|
data.flushWarnings();
|
||||||
|
@ -18,7 +18,7 @@ exports.command = function (message) {
|
||||||
state.stats.warnings += 1;
|
state.stats.warnings += 1;
|
||||||
|
|
||||||
if (count + 1 >= 3) {
|
if (count + 1 >= 3) {
|
||||||
state.logChannel.sendMessage(`.ban ${user}`);
|
state.logChannel.send(`.ban ${user}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,6 @@ 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);
|
var warnings = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
||||||
message.channel.sendMessage(`${user}, you have ${warnings.length} total warnings.`);
|
message.channel.send(`${user}, you have ${warnings.length} total warnings.`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
12
src/data.js
12
src/data.js
|
@ -5,7 +5,7 @@ const logger = require('./logging.js');
|
||||||
function readWarnings () {
|
function readWarnings () {
|
||||||
// Load the warnings file into the bans variable.
|
// Load the warnings file into the bans variable.
|
||||||
fs.readFile('/data/discordWarnings.json', 'utf8', function (err, data) {
|
fs.readFile('/data/discordWarnings.json', 'utf8', function (err, data) {
|
||||||
if (err) { throw err; }
|
if (err) { logger.error(err); throw err; }
|
||||||
state.warnings = JSON.parse(data);
|
state.warnings = JSON.parse(data);
|
||||||
logger.debug('Loaded warnings file.');
|
logger.debug('Loaded warnings file.');
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ function readWarnings () {
|
||||||
function readBans () {
|
function readBans () {
|
||||||
// Load the ban file into the bans variable.
|
// Load the ban file into the bans variable.
|
||||||
fs.readFile('/data/discordBans.json', 'utf8', function (err, data) {
|
fs.readFile('/data/discordBans.json', 'utf8', function (err, data) {
|
||||||
if (err) { throw err; }
|
if (err) { logger.error(err); throw err; }
|
||||||
state.bans = JSON.parse(data);
|
state.bans = JSON.parse(data);
|
||||||
logger.debug('Loaded bans file.');
|
logger.debug('Loaded bans file.');
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ function readCustomResponses()
|
||||||
{
|
{
|
||||||
// Load the responses file into the responses variable.
|
// Load the responses file into the responses variable.
|
||||||
fs.readFile('/data/responses.json', 'utf8', function (err, data) {
|
fs.readFile('/data/responses.json', 'utf8', function (err, data) {
|
||||||
if (err) { throw err; }
|
if (err) { logger.error(err); throw err; }
|
||||||
state.responses = JSON.parse(data);
|
state.responses = JSON.parse(data);
|
||||||
logger.debug('Loaded responses file from external source.');
|
logger.debug('Loaded responses file from external source.');
|
||||||
});
|
});
|
||||||
|
@ -33,16 +33,18 @@ function readCustomResponses()
|
||||||
function flushWarnings () {
|
function flushWarnings () {
|
||||||
var warningsJson = JSON.stringify(state.warnings, null, 4);
|
var warningsJson = JSON.stringify(state.warnings, null, 4);
|
||||||
if (!fs.existsSync('./data/')) fs.mkdirSync('data');
|
if (!fs.existsSync('./data/')) fs.mkdirSync('data');
|
||||||
|
|
||||||
fs.writeFile('/data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
fs.writeFile('/data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
||||||
if (err) { logger.error(err); }
|
if (err) { logger.error(err); throw err; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushBans () {
|
function flushBans () {
|
||||||
var bansJson = JSON.stringify(state.bans, null, 4);
|
var bansJson = JSON.stringify(state.bans, null, 4);
|
||||||
if (!fs.existsSync('data')) fs.mkdirSync('data');
|
if (!fs.existsSync('data')) fs.mkdirSync('data');
|
||||||
|
|
||||||
fs.writeFile('/data/discordBans.json', bansJson, 'utf8', function (err) {
|
fs.writeFile('/data/discordBans.json', bansJson, 'utf8', function (err) {
|
||||||
if (err) { logger.error(err); }
|
if (err) { logger.error(err); throw err; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ client.on('guildMemberRemove', (member) => {
|
||||||
// Server is in UTC mode, 11:30 EST would be 03:30 UTC.
|
// Server is in UTC mode, 11:30 EST would be 03:30 UTC.
|
||||||
schedule.scheduleJob({ hour: 3, minute: 30 }, function () {
|
schedule.scheduleJob({ hour: 3, minute: 30 }, function () {
|
||||||
logger.info(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${state.stats.joins} users have joined, ${state.stats.ruleAccepts} users have accepted the rules, ${state.stats.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
logger.info(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${state.stats.joins} users have joined, ${state.stats.ruleAccepts} users have accepted the rules, ${state.stats.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
||||||
state.logChannel.sendMessage(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${state.stats.joins} users have joined, ${state.stats.ruleAccepts} users have accepted the rules, ${state.stats.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
state.logChannel.send(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${state.stats.joins} users have joined, ${state.stats.ruleAccepts} users have accepted the rules, ${state.stats.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
||||||
|
|
||||||
// Clear the stats for the day.
|
// Clear the stats for the day.
|
||||||
state.stats.joins = 0;
|
state.stats.joins = 0;
|
||||||
|
@ -68,7 +68,7 @@ client.on('message', message => {
|
||||||
if (message.guild == null && state.responses.pmReply) {
|
if (message.guild == null && state.responses.pmReply) {
|
||||||
// We want to log PM attempts.
|
// We want to log PM attempts.
|
||||||
logger.info(`${message.author.username} ${message.author} [PM]: ${message.content}`);
|
logger.info(`${message.author.username} ${message.author} [PM]: ${message.content}`);
|
||||||
state.logChannel.sendMessage(`${message.author} [PM]: ${message.content}`);
|
state.logChannel.send(`${message.author} [PM]: ${message.content}`);
|
||||||
message.reply(state.responses.pmReply);
|
message.reply(state.responses.pmReply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ client.on('message', message => {
|
||||||
if (cachedModule) {
|
if (cachedModule) {
|
||||||
// Check access permissions.
|
// Check access permissions.
|
||||||
if (cachedModule.roles !== undefined && findArray(message.member.roles.map(function (x) { return x.name; }), cachedModule.roles) === false) {
|
if (cachedModule.roles !== undefined && findArray(message.member.roles.map(function (x) { return x.name; }), cachedModule.roles) === false) {
|
||||||
state.logChannel.sendMessage(`${message.author} attempted to use admin command: ${message.content}`);
|
state.logChannel.send(`${message.author} attempted to use admin command: ${message.content}`);
|
||||||
logger.info(`${message.author.username} ${message.author} attempted to use admin command: ${message.content}`);
|
logger.info(`${message.author.username} ${message.author} attempted to use admin command: ${message.content}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ exports.execute = function (message) {
|
||||||
// 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];
|
||||||
|
|
||||||
message.channel.sendMessage(`Github ${map[path]}: ${url}`);
|
message.channel.send(`Github ${map[path]}: ${url}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue