various fixes

This commit is contained in:
Erik 2021-06-08 23:28:52 +03:00
parent 6299a2ec50
commit eaf7972879
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
6 changed files with 71 additions and 7 deletions

View File

@ -59,7 +59,13 @@
"id-blacklist": "warn",
"id-match": "warn",
"implicit-arrow-linebreak": "warn",
"indent": "warn",
"indent": [
"warn",
4,
{
"SwitchCase": 1
}
],
"init-declarations": "warn",
"jsx-quotes": "warn",
"key-spacing": "warn",

View File

@ -1,6 +1,7 @@
const { EventEmitter } = require('events');
// eslint-disable-next-line no-unused-vars
const { inspect } = require('util');
const os = require('os');
const ShardManager = require('./middleware/ShardManager.js');
const Logger = require('./middleware/logger/Logger.js');
@ -27,8 +28,11 @@ class Manager extends EventEmitter {
_handleMessage(shard, message) {
if (message._mEval) return this.eval(shard, message);
// Messages coming from the API that have the _logger flag will be caught here, i.e. both flags should be on
if (message._logger) return this.logger._handleMessage(shard, message);
if (message._webhook) return undefined; //todo
if (message._api) return this.apiRequest(shard, message);
}
async build() {
@ -82,6 +86,46 @@ class Manager extends EventEmitter {
}
async apiRequest(shard, message) {
const { type } = message;
switch (type) {
case 'statsQuery':
// TODO: Figure out best strategy for stats querying - push/pull, prometheus, simple polling
//return this.aggregateStatistics();
}
}
async aggregateStatistics() {
const managerData = {
memory: process.memoryUsage().heapUsed, // Bytes
uptime: Date.now() - this.readyAt,
library: {
name: 'Discord.js',
versionersion: require('discord.js').version
},
managedShards: this.shardManager.shards.size
};
const CPU = os.cpus();
const freeMemory = os.freemem();
const totalMemory = os.totalmem();
const systemData = {
cpu: CPU[0].model,
cores: CPU.length,
memory: {
used: totalMemory - freeMemory,
total: totalMemory
},
osType: os.type(),
uptime: os.uptime(),
hostname: os.hostname()
};
}
get uptime() {
return this.readyAt !== null ? Date.now() - this.readyAt : 0;
}

View File

@ -13,7 +13,8 @@ class ClientPermissions extends Inhibitor {
}
execute(message, command) {
async execute(message, command) {
if (!message.guild.me) message.guild.me = await message.guild.members.fetch(message.client.user);
const missing = message.channel.permissionsFor(message.guild.me).missing(command.clientPermissions);
if(missing.length > 0) {
return super._fail({ missing: missing.join(', ') });

View File

@ -93,7 +93,7 @@ module.exports = class AutoModeration extends Observer {
const { bypass, ignore, enabled, silent, explicit, fuzzy, regex, whitelist, actions } = setting;
const roles = member?.roles.cache.map((r) => r.id) || [];
if (!enabled || roles.some((r) => bypass.includes(r.id)) || ignore.includes(channel.id)) return;
if (!enabled || roles.some((r) => bypass.includes(r)) || ignore.includes(channel.id)) return;
// Which message obj to work with
const msg = edited || message;

View File

@ -665,7 +665,8 @@ For instance the mute setting has a `createmute` (`{prefix}settings createmute <
`{prefix}help [ command / setting ]`
** Links**
[Documentation](https://docs.corgi.wtf/)
[Documentation](https://galactic.corgi.wtf/documentation)
[Dashboard](https://galactic.corgi.wtf/dashboard) **[NON-FUNCTIONAL PRE-ALPHA]**
[Support & Info server](https://discord.gg/SvJgtEj)
[@BotGalactic Twitter](https://twitter.com/BotGalactic)
[GalacticBot Patreon](https://www.patreon.com/galacticbot)

View File

@ -288,6 +288,18 @@ Successfully set the explicit word filter to `{changed}`.
[S_WORDFILTER_EXPLICIT_RESET]
Successfully reset the explicit word filter.
[S_WORDFILTER_WHITELIST_ADD]
Successfully added `{changed}` to the whitelist.
[S_WORDFILTER_WHITELIST_REMOVE]
Successfully removed `{changed}` from the whitelist.
[S_WORDFILTER_WHITELIST_SET]
Successfully set the whitelist to `{changed}`.
[S_WORDFILTER_WHITELIST_RESET]
Successfully reset the whitelist.
[S_WORDFILTER_FUZZY_ADD]
Successfully added `{changed}` to the fuzzy word filter.
@ -316,13 +328,13 @@ Successfully reset the regex word filter.
Successfully toggled the word filter **{toggle}**.
[S_WORDFILTER_IGNORE_ADD]
Successfully added {changed} to be ignored by the word filter.
Successfully added **{changed}** to be ignored by the word filter.
[S_WORDFILTER_IGNORE_REMOVE]
Successfully removed {changed} from being ignored by the word filter.
Successfully removed **{changed}** from being ignored by the word filter.
[S_WORDFILTER_IGNORE_SET]
Successfully set {changed} to be ignored by the word filter.
Successfully set **{changed}** to be ignored by the word filter.
[S_WORDFILTER_IGNORE_RESET]
Successfully reset the ignored channels for the word filter.