aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-29 19:04:41 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-29 19:04:41 -0400
commit51b9c15e6dddda210476944525b1ca4bd08c796b (patch)
treebb6d05ddc51bb9135d27cc1128dc4c994458221c
parenta51dc607be54e600248c8c3c86f9881470ff4158 (diff)
downloadtanzanite-51b9c15e6dddda210476944525b1ca4bd08c796b.tar.gz
tanzanite-51b9c15e6dddda210476944525b1ca4bd08c796b.tar.bz2
tanzanite-51b9c15e6dddda210476944525b1ca4bd08c796b.zip
renamed settings command to config and made minor fixes
-rw-r--r--src/commands/config/config.ts (renamed from src/commands/config/settings.ts)107
-rw-r--r--src/commands/info/help.ts6
-rw-r--r--yarn.lock16
3 files changed, 80 insertions, 49 deletions
diff --git a/src/commands/config/settings.ts b/src/commands/config/config.ts
index 8a5f290..7e0ddf1 100644
--- a/src/commands/config/settings.ts
+++ b/src/commands/config/config.ts
@@ -1,6 +1,7 @@
import { BushCommand, BushMessage, BushSlashMessage, GuildSettings, guildSettingsObj, settingsArr } from '@lib';
import { ArgumentOptions, Flag } from 'discord-akairo';
import {
+ Formatters,
Message,
MessageActionRow,
MessageButton,
@@ -13,15 +14,15 @@ import _ from 'lodash';
export default class SettingsCommand extends BushCommand {
public constructor() {
- super('settings', {
- aliases: ['settings', 'setting', 'configure', 'config'],
+ super('config', {
+ aliases: ['config', 'settings', 'setting', 'configure'],
category: 'config',
description: {
- content: 'Configure server options.',
+ content: 'Configure server settings.',
usage: `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map(
(s) => `\`${s}\``
)})`,
- examples: ['settings']
+ examples: ['settings', 'config prefix set -']
},
slash: true,
slashOptions: settingsArr.map((setting) => {
@@ -113,34 +114,35 @@ export default class SettingsCommand extends BushCommand {
}
};
- const action = yield {
- id: 'action',
- type: guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
- ? ['view', 'add', 'remove']
- : ['view', 'set'],
- prompt: {
- start: `Would you like to ${util.oxford(
- (guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
- ? ['view', 'add', 'remove']
- : ['view', 'set']
- ).map((a) => `\`${a}\``),
- 'or'
- )} the \`${setting}\` setting?`,
- retry: `{error} Choose one of the following actions to perform on the \`${setting}\` setting: ${util.oxford(
- (guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
+ const action = setting
+ ? yield {
+ id: 'action',
+ type: guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
? ['view', 'add', 'remove']
- : ['view', 'set']
- ).map((a) => `\`${a}\``),
- 'or'
- )}`,
- optional: message.util.parsed!.alias === 'settings'
- }
- };
+ : ['view', 'set'],
+ prompt: {
+ start: `Would you like to ${util.oxford(
+ (guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
+ ? ['view', 'add', 'remove']
+ : ['view', 'set']
+ ).map((a) => `\`${a}\``),
+ 'or'
+ )} the \`${setting}\` setting?`,
+ retry: `{error} Choose one of the following actions to perform on the \`${setting}\` setting: ${util.oxford(
+ (guildSettingsObj[setting as unknown as GuildSettings].type.includes('-array')
+ ? ['view', 'add', 'remove']
+ : ['view', 'set']
+ ).map((a) => `\`${a}\``),
+ 'or'
+ )}`,
+ optional: message.util.parsed!.alias === 'settings'
+ }
+ }
+ : undefined;
const value =
- action === 'view'
- ? undefined
- : yield {
+ setting && action && action !== 'view'
+ ? yield {
id: 'value',
type: 'string',
match: 'restContent',
@@ -161,7 +163,8 @@ export default class SettingsCommand extends BushCommand {
}.`,
optional: message.util.parsed!.alias === 'settings'
}
- };
+ }
+ : undefined;
return { setting, action, value };
}
@@ -250,8 +253,9 @@ export default class SettingsCommand extends BushCommand {
feature?: undefined | keyof typeof guildSettingsObj
): Promise<MessageOptions> {
if (!message.guild) throw new Error('message.guild is null');
- const settingsEmbed = new MessageEmbed().setTitle(`${message.guild!.name}'s Settings`).setColor(util.colors.default);
+ const settingsEmbed = new MessageEmbed().setColor(util.colors.default);
if (!feature) {
+ settingsEmbed.setTitle(`${message.guild!.name}'s Settings`);
const desc = settingsArr.map((s) => `**${guildSettingsObj[s].name}**`).join('\n');
settingsEmbed.setDescription(desc);
@@ -271,22 +275,36 @@ export default class SettingsCommand extends BushCommand {
);
return { embeds: [settingsEmbed], components: [selMenu] };
} else {
+ settingsEmbed.setTitle(guildSettingsObj[feature].name);
const generateCurrentValue = async (
type: 'string' | 'channel' | 'channel-array' | 'role' | 'role-array'
): Promise<string> => {
const feat = await message.guild!.getSetting(feature);
console.debug(feat);
+ console.debug(type.replace('-array', ''));
switch (type.replace('-array', '') as 'string' | 'channel' | 'role') {
case 'string': {
return Array.isArray(feat)
- ? feat.map((feat) => util.discord.escapeInlineCode(util.inspectAndRedact(feat))).join('\n')
- : util.discord.escapeInlineCode(util.inspectAndRedact(feat));
+ ? feat.length
+ ? feat.map((feat) => util.discord.escapeInlineCode(util.inspectAndRedact(feat))).join('\n')
+ : '[Empty Array]'
+ : feat !== null
+ ? util.discord.escapeInlineCode(util.inspectAndRedact(feat))
+ : '[No Value Set]';
}
case 'channel': {
- return Array.isArray(feat) ? feat.map((feat) => `<#${feat}>`).join('\n') : `<#${feat}>`;
+ return Array.isArray(feat)
+ ? feat.length
+ ? feat.map((feat) => `<#${feat}>`).join('\n')
+ : '[Empty Array]'
+ : `<#${feat}>`;
}
case 'role': {
- return Array.isArray(feat) ? feat.map((feat) => `<@&${feat}>`).join('\n') : `<@&${feat}>`;
+ return Array.isArray(feat)
+ ? feat.length
+ ? feat.map((feat) => `<@&${feat}>`).join('\n')
+ : '[Empty Array]'
+ : `<@&${feat}>`;
}
}
};
@@ -294,17 +312,26 @@ export default class SettingsCommand extends BushCommand {
const components = new MessageActionRow().addComponents(
new MessageButton().setStyle('PRIMARY').setCustomId('command_settingsBack').setLabel('Back')
);
- settingsEmbed.setDescription(guildSettingsObj[feature].description);
+ settingsEmbed.setDescription(
+ `${Formatters.italic(guildSettingsObj[feature].description)}\n\n**Type**: ${guildSettingsObj[feature].type}`
+ );
settingsEmbed.setFooter(
- `Run "${message.util.isSlash ? '/' : await message.guild.getSetting('prefix')}settings ${feature} ${
+ `Run "${
+ message.util.isSlash
+ ? '/'
+ : client.config.isDevelopment
+ ? 'dev '
+ : message.util.parsed?.prefix ?? client.config.prefix
+ }settings ${feature} ${
guildSettingsObj[feature].type.includes('-array') ? 'add/remove' : 'set'
} <value>" to set this setting.`
);
settingsEmbed.addField(
- guildSettingsObj[feature].name,
- (await generateCurrentValue(feature as 'string' | 'channel' | 'channel-array' | 'role' | 'role-array')) ||
- '[No Value Set]'
+ 'value',
+ (await generateCurrentValue(
+ guildSettingsObj[feature].type as 'string' | 'channel' | 'channel-array' | 'role' | 'role-array'
+ )) || '[No Value Set]'
);
return { embeds: [settingsEmbed], components: [components] };
}
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 97811da..ad4e00f 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -47,7 +47,11 @@ export default class HelpCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: { command: BushCommand | string; showHidden?: boolean }
): Promise<unknown> {
- const prefix = client.config.isDevelopment ? 'dev ' : message.util.parsed?.prefix ?? client.config.prefix;
+ const prefix = message.util.isSlash
+ ? '/'
+ : client.config.isDevelopment
+ ? 'dev '
+ : message.util.parsed?.prefix ?? client.config.prefix;
const row = new MessageActionRow();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
diff --git a/yarn.lock b/yarn.lock
index ce84919..2afdde8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -359,9 +359,9 @@ __metadata:
linkType: hard
"@types/node@npm:*":
- version: 16.7.4
- resolution: "@types/node@npm:16.7.4"
- checksum: da7813e6c37e7813645a9d40de6d9f803fbadb2975748d307ec31d8e4f9baabccf49b667a39e4b1288d477ec7d34a339e8a41d8703a1d7ab0ec8eb2516073f27
+ version: 16.7.6
+ resolution: "@types/node@npm:16.7.6"
+ checksum: a8533386a1d4ca0ed67885413001af8789c63948df288f3d36e31bd8fccffacf5dffb95e190c8cd57bb40385f010fb9a30f596bad6bb26b2bb88737d54d8ed95
languageName: node
linkType: hard
@@ -1117,12 +1117,12 @@ discord-akairo-message-util@NotEnoughUpdates/discord-akairo-message-util:
discord-akairo@NotEnoughUpdates/discord-akairo:
version: 8.2.2
- resolution: "discord-akairo@https://github.com/NotEnoughUpdates/discord-akairo.git#commit=ef17d029e98f6aa10b153a97ad8aa41adbe1ef44"
+ resolution: "discord-akairo@https://github.com/NotEnoughUpdates/discord-akairo.git#commit=30de76ee857660939fff5194e40f5bb5d7332cb5"
dependencies:
discord-akairo-message-util: NotEnoughUpdates/discord-akairo-message-util
lodash: ^4.17.21
source-map-support: ^0.5.19
- checksum: 38fb8103a93bfb913da881d05074f0219c0297b8e19ed88a79ed134ab81a1fff664c46d516c856c8e1b217adc5273355b668717b25dac8c0dbeaf4c83486ac4c
+ checksum: c2cfc469240a48ef8726036d5dfcb0246e32c84fde228deebfac7ed43540ac7451403fbf880eee1335d56f3b5257584ee68c6042e2c2bc6047c176fe2ba2ca31
languageName: node
linkType: hard
@@ -3377,8 +3377,8 @@ typescript@^4.4.2:
linkType: hard
"ws@npm:^7.4.4, ws@npm:^7.5.1":
- version: 7.5.3
- resolution: "ws@npm:7.5.3"
+ version: 7.5.4
+ resolution: "ws@npm:7.5.4"
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: ^5.0.2
@@ -3387,7 +3387,7 @@ typescript@^4.4.2:
optional: true
utf-8-validate:
optional: true
- checksum: 423dc0d859fa74020f5555140905b862470a60ea1567bb9ad55a087263d7718b9c94f69678be1cee9868925c570f1e6fc79d09f90c39057bc63fa2edbb2c547b
+ checksum: 48582e4feb1fc6b6b977a0ee6136e5cd1c6a14bc5cb6ce5acf596652b34be757cdf0c225235b3263d56d057bc5d6e528dbe27fc88a3d09828aa803c6696f4b2c
languageName: node
linkType: hard