small fixes

This commit is contained in:
Erik 2022-05-09 16:17:44 +03:00
parent 5dd4750f54
commit 0cf2c9d88c
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
9 changed files with 20 additions and 13 deletions

View File

@ -12,7 +12,8 @@ class EvalCommand extends Command {
super(client, {
name: 'eval',
aliases: ['e', 'evaluate'],
restricted: true
restricted: true,
module: 'developer'
});
}

View File

@ -11,7 +11,8 @@ class GuildCommand extends SlashCommand {
super(client, {
name: 'server',
description: 'Display server related information',
guildOnly: true
guildOnly: true,
module: 'information'
});
}

View File

@ -15,7 +15,7 @@ class Disabled extends Inhibitor {
if (!invoker.guild) return super._succeed();
const settings = await invoker.guild.settings();
if (settings.disabledCommands?.includes(command.resolveable)) return super._fail({
if (settings.commands.disabled?.includes(command.resolveable)) return super._fail({
modifier: invoker.format('INHIBITOR_DISABLED', { globally: false }, { code: true })
});

View File

@ -8,7 +8,8 @@ class IgnoreSetting extends Setting {
super(client, {
name: 'ignore',
module: 'administration',
display: 'Have the bot ignore commands in given channels',
description: 'Have the bot ignore commands in given channels',
display: 'Ignore channels',
default: {
channels: [],
bypass: []

View File

@ -8,6 +8,7 @@ class ModerationPoints extends Setting {
constructor(client) {
super(client, {
name: 'modpoints',
display: 'Moderation Points',
description: 'Configure severity values for infractions, used by automod',
module: 'moderation',
default: {

View File

@ -6,6 +6,7 @@ class WordWatcher extends FilterSetting {
constructor(client) {
super(client, {
name: 'wordwatcher',
display: 'Word Watcher',
description: 'Flag messages for potentially offensive content instead of deleting automatically',
module: 'moderation',
default: {

View File

@ -25,6 +25,7 @@ class Command extends Component {
this.name = options.name;
this.module = options.module;
if(!options.module) this.client.logger.warn(`Command ${this.name} is missing module information.`);
this.description = options.description || "";
this.tags = options.tags || [];

View File

@ -49,7 +49,7 @@ class SettingsCommand extends SlashCommand {
const subCommand = new CommandOption({
name: setting.name,
description: setting.description,
type: 'SUB_COMMAND',
type: setting.commandType, //'SUB_COMMAND',
options: setting.commandOptions
});
this.options.push(subCommand);
@ -80,8 +80,8 @@ class SettingsCommand extends SlashCommand {
async execute(invoker, opts) {
const { guild } = invoker;
const settingName = invoker.subcommand.name;
const { guild, subcommand, subcommandGroup } = invoker;
const settingName = subcommandGroup?.name || subcommand.name;
if (settingName === 'list') return this._listSettings(invoker);
@ -92,14 +92,14 @@ class SettingsCommand extends SlashCommand {
const missing = guild.me.permissions.missing(setting.clientPermissions);
if (missing.length) return invoker.reply({
emoji: 'failure',
index: 'SETTING_MISSINGCLIENTPERMISSIONS',
index: 'SETTING_MISSING_CLIENTPERMISSIONS',
params: { permissions: missing.map((m) => `\`${PermissionNames[m]}\``).join(', ') }
});
}
await invoker.deferReply();
const settings = await guild.settings();
if (!Object.keys(opts).length) return this._showSetting(invoker, setting);
if (!Object.keys(opts).length && this.subcommand(subcommand.name).options.length) return this._showSetting(invoker, setting);
try {
// Pass setting values copy so the changes don't persist unless successful and actually saved
@ -167,8 +167,8 @@ class SettingsCommand extends SlashCommand {
async _showSetting(invoker, setting) {
const { guild } = invoker;
const embed = setting.usageEmbed(guild);
const { guild, subcommand } = invoker;
const embed = setting.usageEmbed(guild, null, this.subcommand(subcommand.name));
const dataFields = await setting.fields(guild);
// eslint-disable-next-line no-return-assign
dataFields.forEach((field) => {

View File

@ -200,7 +200,7 @@ class SettingsMigrator {
autorole: result.autorole,
stickyrole: result.stickyrole ? { ...result.stickyrole, enabled: Boolean(result.stickyrole.roles.length) } : undefined,
welcomer: result.welcomer,
disabledCommands: result.disabledCommands,
commands: { disabled: result.disabledCommands, custom: {} },
prefix: result.prefix
};
return settings;
@ -322,7 +322,8 @@ class SettingsMigrator {
for(const cmd of cmds) if(!resolved.includes(cmd)) resolved.push(cmd);
}
}
settings.disabledCommands = resolved;
// TODO Add custom command imports
settings.commands = { disabled: resolved, custom: {} };
}
if (modpoints) {