Added count, added some new playing lines, fixed security issue with hackban
This commit is contained in:
parent
e9f4109f43
commit
c65a8115aa
6 changed files with 94 additions and 4 deletions
|
@ -39,6 +39,9 @@ module.exports = async (message) => {
|
|||
// actually run the command
|
||||
logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`);
|
||||
try {
|
||||
const global = (await database.global.findOne({}).exec());
|
||||
global.cmdCounts.set(collections.aliases.has(command) ? collections.aliases.get(command) : command, global.cmdCounts.get(command) + 1);
|
||||
await global.save();
|
||||
const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
|
||||
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
|
||||
await client.createMessage(message.channel.id, result);
|
||||
|
|
|
@ -2,6 +2,7 @@ const gm = require("gm");
|
|||
const { promisify } = require("util");
|
||||
const client = require("../utils/client.js");
|
||||
const database = require("../utils/database.js");
|
||||
const collections = require("../utils/collections.js");
|
||||
const logger = require("../utils/logger.js");
|
||||
const messages = require("../messages.json");
|
||||
const misc = require("../utils/misc.js");
|
||||
|
@ -16,11 +17,11 @@ module.exports = async () => {
|
|||
for (const [id] of client.guilds) {
|
||||
const guildDB = (
|
||||
await database.guilds
|
||||
.find({
|
||||
.findOne({
|
||||
id: id,
|
||||
})
|
||||
.exec()
|
||||
)[0];
|
||||
);
|
||||
if (!guildDB) {
|
||||
logger.log(`Registering guild database entry for guild ${id}...`);
|
||||
const newGuild = new database.guilds({
|
||||
|
@ -44,6 +45,25 @@ module.exports = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const global = (await database.global.findOne({}).exec());
|
||||
if (!global) {
|
||||
const countObject = {};
|
||||
for (const command of collections.commands.keys()) {
|
||||
countObject[command] = 0;
|
||||
}
|
||||
const newGlobal = new database.global({
|
||||
cmdCounts: countObject
|
||||
});
|
||||
await newGlobal.save();
|
||||
} else {
|
||||
for (const command of collections.commands.keys()) {
|
||||
if (!global.cmdCounts.has(command)) {
|
||||
global.cmdCounts.set(command, 0);
|
||||
await global.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// generate docs
|
||||
if (helpGenerator) {
|
||||
await helpGenerator(process.env.OUTPUT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue