diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-06 15:20:46 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-06 15:20:46 -0400 |
commit | 13306f17accea5d3653dd4b8670ba0d6ab69c7c5 (patch) | |
tree | 7075dcca19ed1164a166efac19c49311e93ffeee /src/commands/config | |
parent | a8386e756758f243b75e5df4886224d2bf9f241c (diff) | |
download | tanzanite-13306f17accea5d3653dd4b8670ba0d6ab69c7c5.tar.gz tanzanite-13306f17accea5d3653dd4b8670ba0d6ab69c7c5.tar.bz2 tanzanite-13306f17accea5d3653dd4b8670ba0d6ab69c7c5.zip |
evidence command and more logging
Diffstat (limited to 'src/commands/config')
-rw-r--r-- | src/commands/config/blacklist.ts | 2 | ||||
-rw-r--r-- | src/commands/config/config.ts | 38 | ||||
-rw-r--r-- | src/commands/config/disable.ts | 2 | ||||
-rw-r--r-- | src/commands/config/features.ts | 3 | ||||
-rw-r--r-- | src/commands/config/log.ts | 3 |
5 files changed, 33 insertions, 15 deletions
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index ff34567..5dea36a 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -115,7 +115,7 @@ export default class BlacklistCommand extends BushCommand { targetID ); const success = await message.guild - .setSetting(target instanceof User ? 'blacklistedUsers' : 'blacklistedChannels', newValue) + .setSetting(target instanceof User ? 'blacklistedUsers' : 'blacklistedChannels', newValue, message.member!) .catch(() => false); if (!success) return await message.util.reply({ diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 0c466e6..cba4468 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -49,7 +49,11 @@ export default class SettingsCommand extends BushCommand { description: `What would you like to add to the server's ${guildSettingsObj[ setting ].name.toLowerCase()}?'`, - type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as 'ROLE' | 'STRING' | 'CHANNEL', + type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as + | 'ROLE' + | 'STRING' + | 'CHANNEL' + | 'USER', required: true } ] @@ -64,7 +68,11 @@ export default class SettingsCommand extends BushCommand { description: `What would you like to remove from the server's ${guildSettingsObj[ setting ].name.toLowerCase()}?'`, - type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as 'ROLE' | 'STRING' | 'CHANNEL', + type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as + | 'ROLE' + | 'STRING' + | 'CHANNEL' + | 'USER', required: true } ] @@ -86,7 +94,7 @@ export default class SettingsCommand extends BushCommand { description: `What would you like to set the server's ${guildSettingsObj[ setting ].name.toLowerCase()} to?'`, - type: guildSettingsObj[setting].type.toUpperCase() as 'ROLE' | 'STRING' | 'CHANNEL', + type: guildSettingsObj[setting].type.toUpperCase() as 'ROLE' | 'STRING' | 'CHANNEL' | 'USER', required: true } ] @@ -183,7 +191,7 @@ export default class SettingsCommand extends BushCommand { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); if (!message.member?.permissions.has('MANAGE_GUILD')) return await message.util.reply( - `${util.emojis.error} You must have the **MANAGE_GUILD** permissions to run this command.` + `${util.emojis.error} You must have the **MANAGE_GUILD** permission to run this command.` ); const setting = message.util.isSlash ? (_.camelCase(args.subcommandGroup)! as GuildSettings) : args.setting!; const action = message.util.isSlash ? args.subcommand! : args.action!; @@ -217,13 +225,13 @@ export default class SettingsCommand extends BushCommand { case 'remove': { const existing = (await message.guild.getSetting(setting)) as string[]; const updated = util.addOrRemoveFromArray('add', existing, parseVal(value)); - await message.guild.setSetting(setting, updated); + await message.guild.setSetting(setting, updated, message.member); const messageOptions = await this.generateMessageOptions(message, setting); msg = (await message.util.reply(messageOptions)) as Message; break; } case 'set': { - await message.guild.setSetting(setting, parseVal(value)); + await message.guild.setSetting(setting, parseVal(value), message.member); const messageOptions = await this.generateMessageOptions(message, setting); msg = (await message.util.reply(messageOptions)) as Message; break; @@ -289,11 +297,11 @@ export default class SettingsCommand extends BushCommand { } else { settingsEmbed.setTitle(guildSettingsObj[setting].name); const generateCurrentValue = async ( - type: 'string' | 'channel' | 'channel-array' | 'role' | 'role-array' + type: 'string' | 'channel' | 'channel-array' | 'role' | 'role-array' | 'user' | 'user-array' | 'custom' ): Promise<string> => { const feat = await message.guild!.getSetting(setting); - switch (type.replace('-array', '') as 'string' | 'channel' | 'role') { + switch (type.replace('-array', '') as 'string' | 'channel' | 'role' | 'user' | 'custom') { case 'string': { return Array.isArray(feat) ? feat.length @@ -308,14 +316,24 @@ export default class SettingsCommand extends BushCommand { ? feat.length ? feat.map((feat) => `<#${feat}>`).join('\n') : '[Empty Array]' - : `<#${feat}>`; + : `<#${feat as string}>`; } case 'role': { return Array.isArray(feat) ? feat.length ? feat.map((feat) => `<@&${feat}>`).join('\n') : '[Empty Array]' - : `<@&${feat}>`; + : `<@&${feat as string}>`; + } + case 'user': { + return Array.isArray(feat) + ? feat.length + ? feat.map((feat) => `<@${feat}>`).join('\n') + : '[Empty Array]' + : `<@${feat as string}>`; + } + case 'custom': { + return util.inspectAndRedact(feat); } } }; diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index bc6ed47..db4909a 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -103,7 +103,7 @@ export default class DisableCommand extends BushCommand { action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; } const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID); - const success = await message.guild!.setSetting('disabledCommands', newValue).catch(() => false); + const success = await message.guild!.setSetting('disabledCommands', newValue, message.member!).catch(() => false); if (!success) return await message.util.reply({ content: `${util.emojis.error} There was an error **${action.substr( diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 3c607c7..2169177 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -42,12 +42,11 @@ export default class FeaturesCommand extends BushCommand { if (!guildFeaturesArr.includes(selected)) throw new Error('Invalid guild feature selected'); - const newEnabledFeatures = await message.guild.toggleFeature(selected); + const newEnabledFeatures = await message.guild.toggleFeature(selected, message.member!); this.generateDescription(guildFeaturesArr, newEnabledFeatures, featureEmbed); await interaction.update({ embeds: [featureEmbed] }).catch(() => undefined); - return; } else { return await interaction?.deferUpdate().catch(() => undefined); diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index 0bc2189..49db6f8 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -72,7 +72,8 @@ export default class LogCommand extends BushCommand { action ? (currentLogs[args.log_type] = args.channel.id) : delete currentLogs[args.log_type]; - const success = await message.guild.setSetting('logChannels', currentLogs); + const success = await message.guild.setSetting('logChannels', currentLogs, message.member!); + return await message.util.reply( `${ success |