forked from Galactic/galactic-bot
misc fixes
This commit is contained in:
parent
6ca8ca58b8
commit
6f0e3459e7
@ -350,7 +350,7 @@ Attached the JSON-formatted moderation file in the file below.
|
|||||||
You may want to format this file for easier viewing.
|
You may want to format this file for easier viewing.
|
||||||
|
|
||||||
[COMMAND_HISTORY_FAILEXPORT]
|
[COMMAND_HISTORY_FAILEXPORT]
|
||||||
Unable to upload JSON file, the file is too large to upload here. **\`[amount/max]\`**
|
Unable to upload JSON file, the file is too large to upload here. **`[{amount}/{max}]`**
|
||||||
If you absolutely need this, contact a bot developer in our support server.
|
If you absolutely need this, contact a bot developer in our support server.
|
||||||
|
|
||||||
//Case Command
|
//Case Command
|
||||||
|
@ -72,7 +72,7 @@ class HistoryCommand extends SlashCommand {
|
|||||||
const { guild } = invoker;
|
const { guild } = invoker;
|
||||||
const { user, moderator, channel, before, after, verbose, oldest,
|
const { user, moderator, channel, before, after, verbose, oldest,
|
||||||
export: exp, private: priv, type: infType, pagesize, page } = opts;
|
export: exp, private: priv, type: infType, pagesize, page } = opts;
|
||||||
if (exp?.value) return this._exportLogs(invoker, priv?.value);
|
if (exp?.value) return this._exportLogs(invoker, user?.value, priv?.value);
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
guild: invoker.guild.id,
|
guild: invoker.guild.id,
|
||||||
@ -215,11 +215,13 @@ class HistoryCommand extends SlashCommand {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _exportLogs(invoker, priv = false) {
|
async _exportLogs(invoker, user = null, priv = false) {
|
||||||
|
|
||||||
const member = await invoker.memberWrapper().catch(() => null);
|
const member = await invoker.memberWrapper().catch(() => null);
|
||||||
if(!member || !member.isAdmin()) return { emoji: 'failure', index: 'COMMAND_HISTORY_NO_EXPORT_PERMS' };
|
if(!member || !member.isAdmin()) return { emoji: 'failure', index: 'COMMAND_HISTORY_NO_EXPORT_PERMS' };
|
||||||
const logs = await this.client.storageManager.mongodb.infractions.find({ guild: invoker.guild.id }, { projection: { _id: 0 } });
|
const logs = await this.client.storageManager.mongodb.infractions.find({
|
||||||
|
guild: invoker.guild.id, target: user?.id
|
||||||
|
}, { projection: { _id: 0 } });
|
||||||
const string = JSON.stringify(logs);
|
const string = JSON.stringify(logs);
|
||||||
const attachment = new AttachmentBuilder(Buffer.from(string), { name: `${invoker.guild.id}-moderation.json` });
|
const attachment = new AttachmentBuilder(Buffer.from(string), { name: `${invoker.guild.id}-moderation.json` });
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ class CommandOption {
|
|||||||
this.slashOption = options.slashOption || false;
|
this.slashOption = options.slashOption || false;
|
||||||
this.flag = options.flag ?? false; // used with message based command options
|
this.flag = options.flag ?? false; // used with message based command options
|
||||||
this.valueOptional = options.valueOptional ?? false;
|
this.valueOptional = options.valueOptional ?? false;
|
||||||
|
if (this.valueOptional && options.defaultValue === undefined) throw new Error(`${this.name} Optional values are only valid if passed with a default value`);
|
||||||
this.defaultValue = options.defaultValue ?? null;
|
this.defaultValue = options.defaultValue ?? null;
|
||||||
this.valueAsAlias = options.choices?.length && (options.valueAsAlias ?? false);
|
this.valueAsAlias = options.choices?.length && (options.valueAsAlias ?? false);
|
||||||
// this.words = options.words ?? null; // Used when parsing strings if the command has multiple string types that aren't flags
|
// this.words = options.words ?? null; // Used when parsing strings if the command has multiple string types that aren't flags
|
||||||
@ -173,10 +174,15 @@ class CommandOption {
|
|||||||
// console.log('-------PARSE BEGIN---------');
|
// console.log('-------PARSE BEGIN---------');
|
||||||
// console.log('1', this.name, this._rawValue, this.valueOptional);
|
// console.log('1', this.name, this._rawValue, this.valueOptional);
|
||||||
const { removed, value, error } = await this.types[this.type]();
|
const { removed, value, error } = await this.types[this.type]();
|
||||||
|
if (this.valueOptional && error) {
|
||||||
|
this.value = this.defaultValue;
|
||||||
|
} else {
|
||||||
|
if(error) return { error };
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('2', removed, value, error);
|
// console.log('2', removed, value, error);
|
||||||
// console.log('--------PARSE END----------');
|
// console.log('--------PARSE END----------');
|
||||||
if(error) return { error };
|
|
||||||
this.value = value;
|
|
||||||
return removed || [];
|
return removed || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class ModerationCommand extends SlashCommand {
|
|||||||
description: 'How many messages to prune',
|
description: 'How many messages to prune',
|
||||||
minimum: 2,
|
minimum: 2,
|
||||||
maximum: 100,
|
maximum: 100,
|
||||||
flag
|
flag, valueOptional: true, defaultValue: 100
|
||||||
}, {
|
}, {
|
||||||
name: 'force',
|
name: 'force',
|
||||||
type: 'BOOLEAN',
|
type: 'BOOLEAN',
|
||||||
|
@ -36,16 +36,20 @@ class SettingsCommand extends SlashCommand {
|
|||||||
// const modules = new Set(allSettings.map((set) => set.module.name));
|
// const modules = new Set(allSettings.map((set) => set.module.name));
|
||||||
|
|
||||||
for (const setting of settings.values()) {
|
for (const setting of settings.values()) {
|
||||||
const subCommand = new CommandOption({
|
try {
|
||||||
name: setting.name,
|
const subCommand = new CommandOption({
|
||||||
description: setting.description,
|
name: setting.name,
|
||||||
type: setting.commandType, //'SUB_COMMAND',
|
description: setting.description,
|
||||||
options: setting.commandOptions,
|
type: setting.commandType, //'SUB_COMMAND',
|
||||||
client: this.client
|
options: setting.commandOptions,
|
||||||
});
|
client: this.client
|
||||||
this.options.push(subCommand);
|
});
|
||||||
// Overwrite the setting options with the built CommandOption structures
|
this.options.push(subCommand);
|
||||||
setting.commandOptions = subCommand.options;
|
// Overwrite the setting options with the built CommandOption structures
|
||||||
|
setting.commandOptions = subCommand.options;
|
||||||
|
} catch (err) {
|
||||||
|
this.client.logger.error(`Setting ${setting.name} errored during options build:\n${err.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (const module of modules) {
|
// for (const module of modules) {
|
||||||
|
Loading…
Reference in New Issue
Block a user