mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 15:45:37 +01:00
Updated folder structure. Added back responses.json into src. Tweaked includes.
This commit is contained in:
parent
c259926855
commit
8e576e2a3f
@ -14,4 +14,4 @@ RUN addgroup -S app -g 50000 && \
|
|||||||
adduser -S -g app -u 50000 app
|
adduser -S -g app -u 50000 app
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
ENTRYPOINT [ "node", "server.js" ]
|
ENTRYPOINT [ "node", "src/server.js" ]
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
var discord = require('discord.js');
|
|
||||||
var app = require('../app.js');
|
|
||||||
var data = require('../data.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
var UserBan = require('../models/UserBan.js');
|
|
||||||
|
|
||||||
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} ${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} ${user.username}`);
|
|
||||||
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
|
||||||
});
|
|
||||||
|
|
||||||
data.flushBans();
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
var discord = require('discord.js');
|
|
||||||
var app = require('../app.js');
|
|
||||||
var data = require('../data.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
var UserWarning = require('../models/UserWarning.js');
|
|
||||||
|
|
||||||
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;
|
|
||||||
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].`);
|
|
||||||
|
|
||||||
app.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
|
||||||
data.flushWarnings();
|
|
||||||
|
|
||||||
app.stats.warnings += 1;
|
|
||||||
|
|
||||||
if (count + 1 >= 3) {
|
|
||||||
app.logChannel.sendMessage(`.ban ${user}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
var app = require('../app.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
|
|
||||||
exports.command = function(message) {
|
|
||||||
message.mentions.users.map((user) => {
|
|
||||||
var warnings = app.warnings.filter(x => x.id == user.id && !x.cleared);
|
|
||||||
message.channel.sendMessage(`${user}, you have ${warnings.length} total warnings.`);
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
var app = require('../app.js');
|
|
||||||
|
|
||||||
exports.roles = ['Admins', 'Moderators'];
|
|
||||||
exports.command = function (message, reply) {
|
|
||||||
app.logChannel.sendMessage(`I am running under ${process.env.USER}.`);
|
|
||||||
};
|
|
41
data.js
41
data.js
@ -1,41 +0,0 @@
|
|||||||
var fs = require('fs');
|
|
||||||
var app = require('./app.js');
|
|
||||||
var logger = require('./logging.js');
|
|
||||||
|
|
||||||
function readWarnings () {
|
|
||||||
// Load the warnings file into the bans variable.
|
|
||||||
fs.readFile('./data/discordWarnings.json', 'utf8', function (err, data) {
|
|
||||||
if (err && err.code === 'ENOENT') { return; }
|
|
||||||
if (err) { logger.error(err); }
|
|
||||||
app.warnings = JSON.parse(data);
|
|
||||||
logger.debug('Loaded warnings file.');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function readBans () {
|
|
||||||
// Load the ban file into the bans variable.
|
|
||||||
fs.readFile('./data/discordBans.json', 'utf8', function (err, data) {
|
|
||||||
if (err && err.code === 'ENOENT') { return; }
|
|
||||||
if (err) { logger.error(err); }
|
|
||||||
app.bans = JSON.parse(data);
|
|
||||||
logger.debug('Loaded bans file.');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function flushWarnings () {
|
|
||||||
var warningsJson = JSON.stringify(app.warnings, null, 4);
|
|
||||||
if (!fs.existsSync('./data/')) fs.mkdirSync('./data/');
|
|
||||||
fs.writeFile('./data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
|
||||||
if (err) { logger.error(err); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function flushBans () {
|
|
||||||
var bansJson = JSON.stringify(app.bans, null, 4);
|
|
||||||
if (!fs.existsSync('./data/')) fs.mkdirSync('./data/');
|
|
||||||
fs.writeFile('./data/discordBans.json', bansJson, 'utf8', function (err) {
|
|
||||||
if (err) { logger.error(err); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { readWarnings: readWarnings, readBans: readBans, flushWarnings: flushWarnings, flushBans: flushBans };
|
|
24
src/commands/ban.js
Normal file
24
src/commands/ban.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const state = require('../state.js');
|
||||||
|
const data = require('../data.js');
|
||||||
|
const logger = require('../logging.js');
|
||||||
|
const UserBan = require('../models/UserBan.js');
|
||||||
|
|
||||||
|
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
|
exports.command = function (message) {
|
||||||
|
message.mentions.users.map((user) => {
|
||||||
|
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.`);
|
||||||
|
logger.info(`${message.author.toString()} has banned ${user.toString()} ${user} ${user.username}.`);
|
||||||
|
state.logChannel.sendMessage(`${message.author} has banned ${user} ${user.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) {
|
||||||
|
state.logChannel.sendMessage(`Error banning ${user} ${user.username}`);
|
||||||
|
logger.error(`Error banning ${user.toString()} ${user} ${user.username}.`, error);
|
||||||
|
});
|
||||||
|
|
||||||
|
data.flushBans();
|
||||||
|
});
|
||||||
|
};
|
@ -1,13 +1,13 @@
|
|||||||
var app = require('../app.js');
|
const state = require('../state.js');
|
||||||
var data = require('../data.js');
|
const data = require('../data.js');
|
||||||
var logger = require('../logging.js');
|
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 = app.warnings.filter(x => x.id == user.id && !x.cleared);
|
var 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();
|
||||||
message.channel.sendMessage(`${user}, your warnings have been cleared.`);
|
message.channel.sendMessage(`${user}, your warnings have been cleared.`);
|
||||||
} else {
|
} else {
|
||||||
@ -15,6 +15,6 @@ exports.command = function(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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}].`);
|
||||||
app.logChannel.sendMessage(`${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}].`);
|
||||||
});
|
});
|
||||||
}
|
};
|
@ -1,8 +1,5 @@
|
|||||||
var app = require('../app.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
|
|
||||||
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
exports.roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
exports.command = function(message) {
|
exports.command = function (message) {
|
||||||
var role = '345247291843805185';
|
var role = '345247291843805185';
|
||||||
message.mentions.users.map((user) => {
|
message.mentions.users.map((user) => {
|
||||||
let member = message.guild.member(user);
|
let member = message.guild.member(user);
|
@ -1,15 +1,11 @@
|
|||||||
var app = require('../app.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
|
|
||||||
exports.roles = ['Admins', 'Moderators'];
|
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) {
|
||||||
replyMessage = message.content.substr(message.content.indexOf(' ') + 1);
|
replyMessage = message.content.substr(message.content.indexOf(' ') + 1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
replyMessage = `${message.mentions.users.map(user => `${user}`)} ${reply}`;
|
replyMessage = `${message.mentions.users.map(user => `${user}`)} ${reply}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.channel.sendMessage(replyMessage);
|
message.channel.sendMessage(replyMessage);
|
||||||
}
|
};
|
24
src/commands/warn.js
Normal file
24
src/commands/warn.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const state = require('../state.js');
|
||||||
|
const data = require('../data.js');
|
||||||
|
const logger = require('../logging.js');
|
||||||
|
const UserWarning = require('../models/UserWarning.js');
|
||||||
|
|
||||||
|
exports.roles = ['Admins', 'Moderators'];
|
||||||
|
exports.command = function (message) {
|
||||||
|
message.mentions.users.map((user) => {
|
||||||
|
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.`);
|
||||||
|
|
||||||
|
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.warnings.push(new UserWarning(user.id, user.username, message.author.id, message.author.username, count));
|
||||||
|
data.flushWarnings();
|
||||||
|
|
||||||
|
state.stats.warnings += 1;
|
||||||
|
|
||||||
|
if (count + 1 >= 3) {
|
||||||
|
state.logChannel.sendMessage(`.ban ${user}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
8
src/commands/warnings.js
Normal file
8
src/commands/warnings.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const state = require('../state.js');
|
||||||
|
|
||||||
|
exports.command = function (message) {
|
||||||
|
message.mentions.users.map((user) => {
|
||||||
|
var warnings = state.warnings.filter(x => x.id === user.id && !x.cleared);
|
||||||
|
message.channel.sendMessage(`${user}, you have ${warnings.length} total warnings.`);
|
||||||
|
});
|
||||||
|
};
|
41
src/data.js
Normal file
41
src/data.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const state = require('./state.js');
|
||||||
|
const logger = require('./logging.js');
|
||||||
|
|
||||||
|
function readWarnings () {
|
||||||
|
// Load the warnings file into the bans variable.
|
||||||
|
fs.readFile('data/discordWarnings.json', 'utf8', function (err, data) {
|
||||||
|
if (err && err.code === 'ENOENT') { return; }
|
||||||
|
if (err) { logger.error(err); }
|
||||||
|
state.warnings = JSON.parse(data);
|
||||||
|
logger.debug('Loaded warnings file.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function readBans () {
|
||||||
|
// Load the ban file into the bans variable.
|
||||||
|
fs.readFile('data/discordBans.json', 'utf8', function (err, data) {
|
||||||
|
if (err && err.code === 'ENOENT') { return; }
|
||||||
|
if (err) { logger.error(err); }
|
||||||
|
state.bans = JSON.parse(data);
|
||||||
|
logger.debug('Loaded bans file.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function flushWarnings () {
|
||||||
|
var warningsJson = JSON.stringify(state.warnings, null, 4);
|
||||||
|
if (!fs.existsSync('./data/')) fs.mkdirSync('data');
|
||||||
|
fs.writeFile('data/discordWarnings.json', warningsJson, 'utf8', function (err) {
|
||||||
|
if (err) { logger.error(err); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function flushBans () {
|
||||||
|
var bansJson = JSON.stringify(state.bans, null, 4);
|
||||||
|
if (!fs.existsSync('data')) fs.mkdirSync('data');
|
||||||
|
fs.writeFile('data/discordBans.json', bansJson, 'utf8', function (err) {
|
||||||
|
if (err) { logger.error(err); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { readWarnings: readWarnings, readBans: readBans, flushWarnings: flushWarnings, flushBans: flushBans };
|
@ -1,5 +1,5 @@
|
|||||||
class UserBan {
|
class UserBan {
|
||||||
constructor(id, username, warnedBy, warnedByUsername, priorWarnings) {
|
constructor (id, username, warnedBy, warnedByUsername, priorWarnings) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.date = new Date();
|
this.date = new Date();
|
@ -1,5 +1,5 @@
|
|||||||
class UserWarning {
|
class UserWarning {
|
||||||
constructor(id, username, warnedBy, warnedByUsername, priorWarnings) {
|
constructor (id, username, warnedBy, warnedByUsername, priorWarnings) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.date = new Date();
|
this.date = new Date();
|
22
src/responses.json
Normal file
22
src/responses.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"pmReply": "Please refer to our **Frequently Asked Questions**. <https://citra-emu.org/wiki/faq/>",
|
||||||
|
"quotes": {
|
||||||
|
"faq": { "reply": "Please refer to our **Frequently Asked Questions**. <https://citra-emu.org/wiki/faq/>" },
|
||||||
|
"cpu": { "reply": "Citra requires powerful single-core performance. Refer to your CPU in this graph. Your experience with Citra won't be enjoyable in most games if it's below 1,800. <https://www.cpubenchmark.net/singleThread.html>" },
|
||||||
|
"requirements": { "reply": "Please refer to our **Frequently Asked Questions**. The only requirements for Citra are a GPU that supports at least OpenGL 3.3 and a 64-bit OS, but you definitely want a processor with the highest possible performance per core. <https://citra-emu.org/wiki/faq/>"},
|
||||||
|
"roms": { "warn": true, "reply": "Please read our __community rules__. Warez/downloading games talk is strictly prohibited. To prevent legal issues, you are not allowed to post links or refer to any kind of ROM, NAND, ISO, game, or other copyrighted material that has been illegally obtained or shared. <https://citra-emu.org/rules/>"},
|
||||||
|
"dump-game": { "reply": "Please refer to our __game dumping guides__. <https://citra-emu.org/wiki/dumping-game-cartridges/> & <https://citra-emu.org/wiki/dumping-installed-titles/>"},
|
||||||
|
"dump-system": { "reply": "Please refer to our __system dumping guide__. <https://citra-emu.org/wiki/dumping-system-archives-and-the-shared-fonts-from-a-3ds-console/>"},
|
||||||
|
"pokemon": { "reply": "Click here to view our game compatibility list: <https://citra-emu.org/game/>"},
|
||||||
|
"alpha": { "reply": "*Citra* is currently in very early stages of development. Games usually run less than full-speed even on the best computers. Expect bugs and glitches to appear in most games. Many features found in more mature emulators are still in the works. For any major updates, please visit <https://citra-emu.org/>"},
|
||||||
|
"updates": { "reply": "You can check our latest updates on *Github*. <https://github.com/citra-emu/citra/pulse>"},
|
||||||
|
"download": { "reply": "Please only download from the official *Citra* website, as downloading from other sources is not supported here. <https://citra-emu.org/download/>"},
|
||||||
|
"legal": { "reply": "*Citra* is legal, we don't support illegal activities. Dumping your purchased games and system files from your 3DS is legal. Downloading them is not."},
|
||||||
|
"building": { "reply": "Please refer to our building guides.\nWindows: <https://citra-emu.org/wiki/building-for-windows> \nmacOS: <https://citra-emu.org/wiki/building-for-macos> \nLinux: <https://citra-emu.org/wiki/building-for-linux>"},
|
||||||
|
"controller": { "reply": "This forum topic tells you how to __configure your gamepad / controller__: <https://community.citra-emu.org/t/temporary-controller-configurations-for-citra/1061>"},
|
||||||
|
"issues": { "reply": "This forum topic lists __known issues in games and their workarounds__: <https://community.citra-emu.org/t/known-problems-typical-issues-and-their-workarounds/1317> \nPlease read it carefully. It includes help with most games"},
|
||||||
|
"forum": { "reply": "This question might be more suitable for the *Citra* forum. <https://community.citra-emu.org/>"},
|
||||||
|
"game": { "reply": "Click here to view our game compatibility list: <https://citra-emu.org/game/>"},
|
||||||
|
"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>"}
|
||||||
|
}
|
||||||
|
}
|
@ -4,12 +4,13 @@ require('checkenv').check();
|
|||||||
const discord = require('discord.js');
|
const discord = require('discord.js');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const schedule = require('node-schedule');
|
const schedule = require('node-schedule');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const logger = require('./logging.js');
|
const logger = require('./logging.js');
|
||||||
const app = require('./app.js');
|
const state = require('./state.js');
|
||||||
const data = require('./data.js');
|
const data = require('./data.js');
|
||||||
|
|
||||||
var responses = require('./data/responses.json');
|
var responses = require('./responses.json');
|
||||||
|
|
||||||
var cachedModules = [];
|
var cachedModules = [];
|
||||||
var cachedTriggers = [];
|
var cachedTriggers = [];
|
||||||
@ -27,30 +28,30 @@ function findArray (haystack, arr) {
|
|||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
// Initalize app channels.
|
// Initalize app channels.
|
||||||
app.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
state.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
||||||
app.guild = app.logChannel.guild;
|
state.guild = state.logChannel.guild;
|
||||||
|
|
||||||
logger.info('Bot is now online and connected to server.');
|
logger.info('Bot is now online and connected to server.');
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildMemberAdd', (member) => {
|
client.on('guildMemberAdd', (member) => {
|
||||||
app.stats.joins += 1;
|
state.stats.joins += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildMemberRemove', (member) => {
|
client.on('guildMemberRemove', (member) => {
|
||||||
app.stats.leaves += 1;
|
state.stats.leaves += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Output the stats for app.stats every 24 hours.
|
// Output the stats for state.stats every 24 hours.
|
||||||
// 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()}! ${app.stats.joins} users have joined, ${app.stats.leaves} users have left, ${app.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.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
||||||
app.logChannel.sendMessage(`Here are today's stats for ${(new Date()).toLocaleDateString()}! ${app.stats.joins} users have joined, ${app.stats.leaves} users have left, ${app.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.leaves} users have left, ${state.stats.warnings} warnings have been issued.`);
|
||||||
|
|
||||||
// Clear the stats for the day.
|
// Clear the stats for the day.
|
||||||
app.stats.joins = 0;
|
state.stats.joins = 0;
|
||||||
app.stats.leaves = 0;
|
state.stats.leaves = 0;
|
||||||
app.stats.warnings = 0;
|
state.stats.warnings = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('message', message => {
|
client.on('message', message => {
|
||||||
@ -59,7 +60,7 @@ client.on('message', message => {
|
|||||||
if (message.guild == null && responses.pmReply) {
|
if (message.guild == null && 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}`);
|
||||||
app.logChannel.sendMessage(`${message.author} [PM]: ${message.content}`);
|
state.logChannel.sendMessage(`${message.author} [PM]: ${message.content}`);
|
||||||
message.reply(responses.pmReply);
|
message.reply(responses.pmReply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,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) {
|
||||||
app.logChannel.sendMessage(`${message.author} attempted to use admin command: ${message.content}`);
|
state.logChannel.sendMessage(`${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;
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ client.on('message', message => {
|
|||||||
|
|
||||||
// Cache all command modules.
|
// Cache all command modules.
|
||||||
cachedModules = [];
|
cachedModules = [];
|
||||||
require('fs').readdirSync('./commands/').forEach(function (file) {
|
fs.readdirSync('./src/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')) {
|
if (file.includes('.disabled')) {
|
||||||
@ -141,7 +142,7 @@ require('fs').readdirSync('./commands/').forEach(function (file) {
|
|||||||
|
|
||||||
// Cache all triggers.
|
// Cache all triggers.
|
||||||
cachedTriggers = [];
|
cachedTriggers = [];
|
||||||
require('fs').readdirSync('./triggers/').forEach(function (file) {
|
fs.readdirSync('./src/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')) {
|
if (file.includes('.disabled')) {
|
@ -1,5 +1,5 @@
|
|||||||
/* Application State */
|
/* Application State */
|
||||||
var Application = function () {
|
var State = function () {
|
||||||
this.guild = null;
|
this.guild = null;
|
||||||
this.logChannel = null;
|
this.logChannel = null;
|
||||||
this.warnings = [];
|
this.warnings = [];
|
||||||
@ -11,4 +11,4 @@ var Application = function () {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = new Application();
|
module.exports = new State();
|
@ -1,20 +1,18 @@
|
|||||||
var request = require('request');
|
const request = require('request');
|
||||||
var app = require('../app.js');
|
|
||||||
var logger = require('../logging.js');
|
|
||||||
|
|
||||||
var 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);
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.execute = function(message) {
|
exports.execute = function (message) {
|
||||||
let matcher = new RegExp(regex);
|
let matcher = new RegExp(regex);
|
||||||
let match = matcher.exec(message.content);
|
let match = matcher.exec(message.content);
|
||||||
let matched = [];
|
let matched = [];
|
||||||
|
|
||||||
while(match != null) {
|
while (match != null) {
|
||||||
if(matched.indexOf(match[1]) == -1) {
|
if (matched.indexOf(match[1]) === -1) {
|
||||||
matched.push(match[1]);
|
matched.push(match[1]);
|
||||||
} else {
|
} else {
|
||||||
match = matcher.exec(message.content);
|
match = matcher.exec(message.content);
|
||||||
@ -22,18 +20,18 @@ exports.execute = function(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We do not want to automatically match old issues / PRs.
|
// We do not want to automatically match old issues / PRs.
|
||||||
// This usually happens when someone messes up pining another person or
|
// This usually happens when someone messes up pinging another person or
|
||||||
// in general conversation.
|
// in general conversation.
|
||||||
// ex: You're #1!
|
// ex: You're #1!
|
||||||
if (match[1] <= 2000) { return; }
|
if (match[1] <= 2000) { return; }
|
||||||
|
|
||||||
let url = `https://github.com/citra-emu/citra/pull/${match[1]}`;
|
let url = `https://github.com/citra-emu/citra/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) {
|
||||||
message.channel.sendMessage(`Github Pull Request: ${url}`);
|
message.channel.sendMessage(`Github Pull Request: ${url}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
match = matcher.exec(message.content);
|
match = matcher.exec(message.content);
|
||||||
}
|
}
|
||||||
}
|
};
|
Loading…
Reference in New Issue
Block a user