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.
|
||||
|
||||
[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.
|
||||
|
||||
//Case Command
|
||||
|
@ -72,7 +72,7 @@ class HistoryCommand extends SlashCommand {
|
||||
const { guild } = invoker;
|
||||
const { user, moderator, channel, before, after, verbose, oldest,
|
||||
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 = {
|
||||
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);
|
||||
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 attachment = new AttachmentBuilder(Buffer.from(string), { name: `${invoker.guild.id}-moderation.json` });
|
||||
|
||||
|
@ -99,6 +99,7 @@ class CommandOption {
|
||||
this.slashOption = options.slashOption || false;
|
||||
this.flag = options.flag ?? false; // used with message based command options
|
||||
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.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
|
||||
@ -173,10 +174,15 @@ class CommandOption {
|
||||
// console.log('-------PARSE BEGIN---------');
|
||||
// console.log('1', this.name, this._rawValue, this.valueOptional);
|
||||
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('--------PARSE END----------');
|
||||
if(error) return { error };
|
||||
this.value = value;
|
||||
return removed || [];
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class ModerationCommand extends SlashCommand {
|
||||
description: 'How many messages to prune',
|
||||
minimum: 2,
|
||||
maximum: 100,
|
||||
flag
|
||||
flag, valueOptional: true, defaultValue: 100
|
||||
}, {
|
||||
name: 'force',
|
||||
type: 'BOOLEAN',
|
||||
|
@ -36,16 +36,20 @@ class SettingsCommand extends SlashCommand {
|
||||
// const modules = new Set(allSettings.map((set) => set.module.name));
|
||||
|
||||
for (const setting of settings.values()) {
|
||||
const subCommand = new CommandOption({
|
||||
name: setting.name,
|
||||
description: setting.description,
|
||||
type: setting.commandType, //'SUB_COMMAND',
|
||||
options: setting.commandOptions,
|
||||
client: this.client
|
||||
});
|
||||
this.options.push(subCommand);
|
||||
// Overwrite the setting options with the built CommandOption structures
|
||||
setting.commandOptions = subCommand.options;
|
||||
try {
|
||||
const subCommand = new CommandOption({
|
||||
name: setting.name,
|
||||
description: setting.description,
|
||||
type: setting.commandType, //'SUB_COMMAND',
|
||||
options: setting.commandOptions,
|
||||
client: this.client
|
||||
});
|
||||
this.options.push(subCommand);
|
||||
// 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user