aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-28 09:27:41 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-11-28 09:27:41 -0500
commit453683b57b8ff013ff25e2aaa4aa1d2e047edcb7 (patch)
tree8b98d2f30dbb6a8448602446cfacf9091667cc33 /src/commands/config
parentde4c3dcaf172804d34ae708be1ed3e75af42f4d5 (diff)
downloadtanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.tar.gz
tanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.tar.bz2
tanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.zip
a few small changes
Diffstat (limited to 'src/commands/config')
-rw-r--r--src/commands/config/blacklist.ts62
-rw-r--r--src/commands/config/config.ts14
-rw-r--r--src/commands/config/customAutomodPhrases.ts8
-rw-r--r--src/commands/config/disable.ts134
-rw-r--r--src/commands/config/features.ts8
-rw-r--r--src/commands/config/levelRoles.ts24
-rw-r--r--src/commands/config/log.ts33
7 files changed, 115 insertions, 168 deletions
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index f0173a4..8bb778c 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -6,45 +6,43 @@ export default class BlacklistCommand extends BushCommand {
super('blacklist', {
aliases: ['blacklist', 'unblacklist'],
category: 'config',
- description: {
- content: 'A command to blacklist users and channels.',
- usage: ['blacklist|unblacklist <user|channel>'],
- examples: ['blacklist @user', 'unblacklist #channel']
- },
+ description: 'A command to blacklist users and channels.',
+ usage: ['blacklist|unblacklist <user|channel>'],
+ examples: ['blacklist @user', 'unblacklist #channel'],
args: [
{
+ id: 'action',
+ description: 'Whether to blacklist or unblacklist the target.',
+ readableType: "'blacklist'|'unblacklist'",
+ prompt: 'Would you like to add or remove someone or something from/to the blacklist?',
+ slashType: 'STRING',
+ choices: [
+ { name: 'blacklist', value: 'blacklist' },
+ { name: 'unblacklist', value: 'unblacklist' }
+ ],
+ only: 'slash'
+ },
+ {
id: 'target',
+ description: 'The channel/user to blacklist.',
customType: util.arg.union('channel', 'user'),
- prompt: {
- start: 'What channel or user that you would like to blacklist/unblacklist?',
- retry: '{error} Pick a valid user or channel.'
- }
+ readableType: 'channel|user',
+ prompt: 'What channel or user that you would like to blacklist/unblacklist?',
+ retry: '{error} Pick a valid user or channel.',
+ slashType: 'STRING'
},
{
id: 'global',
+ description: 'Blacklist the target globally.',
match: 'flag',
- flag: '--global'
+ flag: '--global',
+ optional: true,
+ slashType: false,
+ only: 'text',
+ ownerOnly: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'action',
- description: 'Would you like to add or remove someone or something from/to the blacklist?',
- type: 'STRING',
- choices: [
- { name: 'blacklist', value: 'blacklist' },
- { name: 'unblacklist', value: 'unblacklist' }
- ],
- required: true
- },
- {
- name: 'target',
- description: 'What channel or user that you would like to blacklist/unblacklist?',
- type: 'STRING',
- required: true
- }
- ],
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: ['MANAGE_GUILD']
@@ -82,14 +80,14 @@ export default class BlacklistCommand extends BushCommand {
.catch(() => false);
if (!success)
return await message.util.reply({
- content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.bold(
+ content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.input(
target?.tag ?? target.name
)}.`,
allowedMentions: AllowedMentions.none()
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${action}ed ${util.format.bold(target?.tag ?? target.name)} globally.`,
+ content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)} globally.`,
allowedMentions: AllowedMentions.none()
});
// guild disable
@@ -110,12 +108,12 @@ export default class BlacklistCommand extends BushCommand {
.catch(() => false);
if (!success)
return await message.util.reply({
- content: `${util.emojis.error} There was an error ${action}ing ${util.format.bold(target?.tag ?? target.name)}.`,
+ content: `${util.emojis.error} There was an error ${action}ing ${util.format.input(target?.tag ?? target.name)}.`,
allowedMentions: AllowedMentions.none()
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${action}ed ${util.format.bold(target?.tag ?? target.name)}.`,
+ content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)}.`,
allowedMentions: AllowedMentions.none()
});
}
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 2ce4246..6af5895 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -22,15 +22,11 @@ export default class SettingsCommand extends BushCommand {
super('config', {
aliases: ['config', 'settings', 'setting', 'configure'],
category: 'config',
- description: {
- content: 'Configure server settings.',
- usage: [
- `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map(
- (s) => `\`${s}\``
- )})`
- ],
- examples: ['settings', 'config prefix set -']
- },
+ description: 'Configure server settings.',
+ usage: [
+ `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map((s) => `\`${s}\``)})`
+ ],
+ examples: ['settings', 'config prefix set -'],
slash: true,
slashOptions: settingsArr.map((setting) => {
return {
diff --git a/src/commands/config/customAutomodPhrases.ts b/src/commands/config/customAutomodPhrases.ts
index 9fbebf5..cf37595 100644
--- a/src/commands/config/customAutomodPhrases.ts
+++ b/src/commands/config/customAutomodPhrases.ts
@@ -5,11 +5,9 @@
// super('customAutomodPhrases', {
// aliases: ['custom-automod-phrases'],
// category: 'config',
-// description: {
-// content: 'Configure additional phrases to be used for automod.',
-// usage: ['custom-automod-phrases <requiredArg> [optionalArg]'],
-// examples: ['custom-automod-phrases 1 2']
-// },
+// description: 'Configure additional phrases to be used for automod.',
+// usage: ['custom-automod-phrases <requiredArg> [optionalArg]'],
+// examples: ['custom-automod-phrases 1 2'],
// args: [
// {
// id: 'required_argument',
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index 83b4608..333ae19 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -5,52 +5,40 @@ export default class DisableCommand extends BushCommand {
super('disable', {
aliases: ['disable', 'enable'],
category: 'config',
- description: {
- content: 'A command to disable and enable commands.',
- usage: ['disable|enable <command>'],
- examples: ['enable ban', 'disable kick']
- },
+ description: 'A command to disable and enable commands.',
+ usage: ['disable|enable <command>'],
+ examples: ['enable ban', 'disable kick'],
args: [
{
+ id: 'action',
+ description: 'Whether to disable or enable the command.',
+ readableType: "'blacklist'|'unblacklist",
+ prompt: 'Would you like to disable or enable a command?',
+ slashType: 'STRING',
+ choices: ['blacklist', 'unblacklist'].map((v) => ({ name: v, value: v })),
+ only: 'slash'
+ },
+ {
id: 'command',
+ description: 'The command to disable/enable.',
customType: util.arg.union('commandAlias', 'command'),
- prompt: {
- start: 'What command would you like to enable/disable?',
- retry: '{error} Pick a valid command.',
- optional: false
- }
+ readableType: 'command|commandAlias',
+ prompt: 'What command would you like to enable/disable?',
+ retry: '{error} Pick a valid command.',
+ slashType: 'STRING'
},
{
id: 'global',
+ description: 'Disable the command globally.',
match: 'flag',
- flag: '--global'
+ flag: '--global',
+ optional: true,
+ slashType: false,
+ only: 'text',
+ ownerOnly: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'action',
- description: 'Would you like to disable or enable a command?',
- type: 'STRING',
- choices: [
- {
- name: 'enable',
- value: 'enable'
- },
- {
- name: 'disable',
- value: 'disable'
- }
- ],
- required: true
- },
- {
- name: 'command',
- description: 'What command would you like to enable/disable?',
- type: 'STRING',
- required: true
- }
- ],
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: ['MANAGE_GUILD']
@@ -67,57 +55,31 @@ export default class DisableCommand extends BushCommand {
const global = args.global && message.author.isOwner();
const commandID = (args.command as BushCommand).id;
- if (global) {
- if (action === 'toggle') {
- const disabledCommands = (
- (await Global.findByPk(client.config.environment)) ?? (await Global.create({ environment: client.config.environment }))
- ).disabledCommands;
- action = disabledCommands.includes(commandID) ? 'disable' : 'enable';
- }
- const success = await util
- .insertOrRemoveFromGlobal(action === 'disable' ? 'remove' : 'add', 'disabledCommands', commandID)
- .catch(() => false);
- if (!success)
- return await message.util.reply({
- content: `${util.emojis.error} There was an error globally **${action.substring(
- 0,
- action.length - 2
- )}ing** the **${commandID}** command.`,
- allowedMentions: AllowedMentions.none()
- });
- else
- return await message.util.reply({
- content: `${util.emojis.success} Successfully **${action.substring(
- 0,
- action.length - 2
- )}ed** the **${commandID}** command globally.`,
- allowedMentions: AllowedMentions.none()
- });
+ const disabledCommands = global
+ ? ((await Global.findByPk(client.config.environment)) ?? (await Global.create({ environment: client.config.environment })))
+ .disabledCommands
+ : await message.guild!.getSetting('disabledCommands');
- // guild disable
- } else {
- const disabledCommands = await message.guild!.getSetting('disabledCommands');
- if (action === 'toggle') {
- action = disabledCommands.includes(commandID) ? 'disable' : 'enable';
- }
- const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID);
- 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(
- 0,
- action.length - 2
- )}ing** the **${commandID}** command.`,
- allowedMentions: AllowedMentions.none()
- });
- else
- return await message.util.reply({
- content: `${util.emojis.success} Successfully **${action.substr(
- 0,
- action.length - 2
- )}ed** the **${commandID}** command.`,
- allowedMentions: AllowedMentions.none()
- });
- }
+ if (action === 'toggle') action = disabledCommands.includes(commandID) ? 'disable' : 'enable';
+ const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID);
+ const success = global
+ ? await util.setGlobal('disabledCommands', newValue).catch(() => false)
+ : 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${global ? ' globally' : ''} **${action.substring(
+ 0,
+ action.length - 2
+ )}ing** the **${commandID}** command.`,
+ allowedMentions: AllowedMentions.none()
+ });
+ else
+ return await message.util.reply({
+ content: `${util.emojis.success} Successfully **${action.substring(
+ 0,
+ action.length - 2
+ )}ed** the **${commandID}** command${global ? ' globally' : ''}.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
}
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index 095d985..894c90a 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -13,11 +13,9 @@ export default class FeaturesCommand extends BushCommand {
super('features', {
aliases: ['features'],
category: 'config',
- description: {
- content: 'Toggle features the server.',
- usage: ['features'],
- examples: ['features']
- },
+ description: 'Toggle features the server.',
+ usage: ['features'],
+ examples: ['features'],
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
diff --git a/src/commands/config/levelRoles.ts b/src/commands/config/levelRoles.ts
index e7b4505..7f99580 100644
--- a/src/commands/config/levelRoles.ts
+++ b/src/commands/config/levelRoles.ts
@@ -5,11 +5,9 @@
// super('levelRole', {
// aliases: ['level-role', 'level-roles', 'lr'],
// category: 'config',
-// description: {
-// content: 'Configure roles to be assigned to users upon reaching certain levels.',
-// usage: ['level-role add <level> <role>', 'level-role remove <level>'],
-// examples: ['level-role 1 2']
-// },
+// description: 'Configure roles to be assigned to users upon reaching certain levels.',
+// usage: ['level-role add <level> <role>', 'level-role remove <level>'],
+// examples: ['level-role 1 2'],
// args: [
// {
// id: 'action',
@@ -18,20 +16,16 @@
// {
// id: 'role',
// type: 'role',
-// prompt: {
-// start: 'What would you like to set your first argument to be?',
-// retry: '{error} Pick a valid argument.',
-// optional: false
-// }
+// prompt: 'What would you like to set your first argument to be?',
+// retry: '{error} Pick a valid argument.',
+// optional: false
// },
// {
// id: 'level',
// type: 'integer',
-// prompt: {
-// start: 'What would you like to set your second argument to be?',
-// retry: '{error} Pick a valid argument.',
-// optional: false
-// }
+// prompt: 'What would you like to set your second argument to be?',
+// retry: '{error} Pick a valid argument.',
+// optional: false
// }
// ],
// slash: true,
diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts
index cccef8c..6121ad7 100644
--- a/src/commands/config/log.ts
+++ b/src/commands/config/log.ts
@@ -7,25 +7,26 @@ export default class LogCommand extends BushCommand {
super('log', {
aliases: ['log', 'logging'],
category: 'config',
- description: {
- content: 'Set or remove a log channel.',
- usage: ['log <logType> [channel]'],
- examples: ['log automod #automod-logs']
- },
+ description: 'Set or remove a log channel.',
+ usage: ['log <logType> [channel]'],
+ examples: ['log automod #automod-logs'],
slash: true,
- slashOptions: [
+ args: [
{
- name: 'log_type',
- description: 'What log type would you like to change?',
- type: 'STRING',
- required: true,
- choices: guildLogsArr.map((log) => ({ name: log, value: log }))
+ id: 'log_type',
+ description: 'The log type to change.',
+ prompt: 'What log type would you like to change?',
+ slashType: 'STRING',
+ choices: guildLogsArr.map((log) => ({ name: log, value: log })),
+ only: 'slash'
},
{
- name: 'channel',
- description: 'What channel would you like these logs to be sent in?',
- type: 'CHANNEL',
- required: false
+ id: 'channel',
+ description: 'The channel to have logs of the seleted type to be sent in.',
+ type: 'channel',
+ prompt: 'What channel would you like these logs to be sent in?',
+ slashType: 'CHANNEL',
+ channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD']
}
],
channel: 'guild',
@@ -36,7 +37,7 @@ export default class LogCommand extends BushCommand {
override *args(): IterableIterator<ArgumentOptions | Flag> {
const log_type = yield {
- id: 'log',
+ id: 'log_type',
type: guildLogsArr,
prompt: {
start: 'What log type would you like to change?',