aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-20 22:50:45 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-20 22:50:45 -0500
commit8fb88c737e49321ff2b612a9d0e0e059c64c272a (patch)
tree6d22573479b7e7e047eceb85dbb7520b616a5a45 /src/commands
parentd4a401ed2315a7b5e7dfa390836f2ebae1299976 (diff)
downloadtanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.tar.gz
tanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.tar.bz2
tanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.zip
do some fixes or something
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/admin/channelPermissions.ts6
-rw-r--r--src/commands/config/blacklist.ts23
-rw-r--r--src/commands/config/disable.ts2
-rw-r--r--src/commands/info/avatar.ts2
-rw-r--r--src/commands/info/color.ts19
-rw-r--r--src/commands/info/guildInfo.ts2
-rw-r--r--src/commands/info/userInfo.ts2
-rw-r--r--src/commands/moderation/ban.ts6
-rw-r--r--src/commands/moderation/modlog.ts2
-rw-r--r--src/commands/moderation/mute.ts2
-rw-r--r--src/commands/moderation/purge.ts2
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts2
-rw-r--r--src/commands/moderation/slowmode.ts4
-rw-r--r--src/commands/moulberry-bush/rule.ts2
-rw-r--r--src/commands/utilities/activity.ts2
-rw-r--r--src/commands/utilities/steal.ts6
-rw-r--r--src/commands/utilities/viewRaw.ts2
17 files changed, 50 insertions, 36 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts
index b44ae21..17bea40 100644
--- a/src/commands/admin/channelPermissions.ts
+++ b/src/commands/admin/channelPermissions.ts
@@ -14,7 +14,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
{
id: 'target',
description: 'The user/role to change the permissions of.',
- customType: util.arg.union('member', 'role'),
+ type: util.arg.union('member', 'role'),
readableType: 'member|role',
prompt: 'What user/role would you like to change?',
retry: '{error} Choose a valid user/role to change.',
@@ -58,7 +58,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: {
target: Role | GuildMember;
- permission: PermissionString | string;
+ permission: PermissionString;
state: 'true' | 'false' | 'neutral';
}
) {
@@ -67,7 +67,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`);
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
- const permission: PermissionString = message.util.isSlashMessage(message)
+ const permission = message.util.isSlashMessage(message)
? await util.arg.cast('permission', message, args.permission)
: args.permission;
if (!permission) return await message.util.reply(`${util.emojis.error} Invalid permission.`);
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index 8bb778c..da4ad18 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -1,5 +1,6 @@
import { AllowedMentions, BushCommand, Global, type BushMessage, type BushSlashMessage } from '#lib';
-import { User, type Channel } from 'discord.js';
+import { GuildTextBasedChannels } from 'discord-akairo';
+import { User } from 'discord.js';
export default class BlacklistCommand extends BushCommand {
public constructor() {
@@ -25,7 +26,7 @@ export default class BlacklistCommand extends BushCommand {
{
id: 'target',
description: 'The channel/user to blacklist.',
- customType: util.arg.union('channel', 'user'),
+ type: util.arg.union('channel', 'user'),
readableType: 'channel|user',
prompt: 'What channel or user that you would like to blacklist/unblacklist?',
retry: '{error} Pick a valid user or channel.',
@@ -51,14 +52,14 @@ export default class BlacklistCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { action: 'blacklist' | 'unblacklist'; target: Channel | User | string; global: boolean }
+ args: { action: 'blacklist' | 'unblacklist'; target: GuildTextBasedChannels | User | string; global: boolean }
) {
let action: 'blacklist' | 'unblacklist' | 'toggle' =
args.action ?? (message?.util?.parsed?.alias as 'blacklist' | 'unblacklist') ?? 'toggle';
const global = args.global && message.author.isOwner();
const target =
typeof args.target === 'string'
- ? (await util.arg.cast('channel', message, args.target)) ?? (await util.arg.cast('user', message, args.target))
+ ? (await util.arg.cast('textChannel', message, args.target)) ?? (await util.arg.cast('user', message, args.target))
: args.target;
if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`);
const targetID = target.id;
@@ -81,13 +82,15 @@ export default class BlacklistCommand extends BushCommand {
if (!success)
return await message.util.reply({
content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.input(
- target?.tag ?? target.name
+ target instanceof User ? target.tag : target.name
)}.`,
allowedMentions: AllowedMentions.none()
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)} globally.`,
+ content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(
+ target instanceof User ? target.tag : target.name
+ )} globally.`,
allowedMentions: AllowedMentions.none()
});
// guild disable
@@ -108,12 +111,16 @@ 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.input(target?.tag ?? target.name)}.`,
+ content: `${util.emojis.error} There was an error ${action}ing ${util.format.input(
+ target instanceof User ? target.tag : target.name
+ )}.`,
allowedMentions: AllowedMentions.none()
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)}.`,
+ content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(
+ target instanceof User ? target.tag : target.name
+ )}.`,
allowedMentions: AllowedMentions.none()
});
}
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index 333ae19..a30652a 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -21,7 +21,7 @@ export default class DisableCommand extends BushCommand {
{
id: 'command',
description: 'The command to disable/enable.',
- customType: util.arg.union('commandAlias', 'command'),
+ type: util.arg.union('commandAlias', 'command'),
readableType: 'command|commandAlias',
prompt: 'What command would you like to enable/disable?',
retry: '{error} Pick a valid command.',
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index 87ea0cc..36504f8 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -13,7 +13,7 @@ export default class AvatarCommand extends BushCommand {
{
id: 'user',
description: 'The user you would like to find the avatar of.',
- customType: util.arg.union('member', 'globalUser'),
+ type: util.arg.union('member', 'globalUser'),
readableType: 'member|user',
prompt: 'Who would you like to see the avatar of?',
retry: '{error} Choose a valid user.',
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index cb612b5..4277d56 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -1,9 +1,16 @@
-import { AllowedMentions, BushCommand, type BushGuildMember, type BushMessage, type BushRole, type BushSlashMessage } from '#lib';
-import { Argument } from 'discord-akairo';
-import { MessageEmbed, Role, type Message } from 'discord.js';
+import {
+ AllowedMentions,
+ BushArgumentTypeCaster,
+ BushCommand,
+ type BushGuildMember,
+ type BushMessage,
+ type BushRole,
+ type BushSlashMessage
+} from '#lib';
+import { MessageEmbed, Role } from 'discord.js';
import tinycolor from 'tinycolor2';
-const isValidTinyColor = (_message: Message, phase: string) => {
+const isValidTinyColor: BushArgumentTypeCaster<string | null> = (_message, phase) => {
// if the phase is a number it converts it to hex incase it could be representing a color in decimal
const newPhase = isNaN(phase as any) ? phase : `#${Number(phase).toString(16)}`;
return tinycolor(newPhase).isValid() ? newPhase : null;
@@ -21,7 +28,7 @@ export default class ColorCommand extends BushCommand {
{
id: 'color',
description: 'The color string, role, or member to find the color of.',
- customType: Argument.union(isValidTinyColor, 'role', 'member'),
+ type: util.arg.union(isValidTinyColor as any, 'role', 'member'),
readableType: 'color|role|member',
match: 'restContent',
prompt: 'What color code, role, or user would you like to find the color of?',
@@ -41,7 +48,7 @@ export default class ColorCommand extends BushCommand {
public override async exec(message: BushMessage | BushSlashMessage, args: { color: string | BushRole | BushGuildMember }) {
const _color = message.util.isSlashMessage(message)
- ? ((await util.arg.cast(Argument.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as
+ ? ((await util.arg.cast(util.arg.union(isValidTinyColor as any, 'role', 'member'), message, args.color as string)) as
| string
| BushRole
| BushGuildMember)
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index a38a446..ab09741 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -21,7 +21,7 @@ export default class GuildInfoCommand extends BushCommand {
{
id: 'guild',
description: 'The guild to find information about.',
- customType: util.arg.union('guild', 'snowflake'),
+ type: util.arg.union('guild', 'snowflake'),
readableType: 'guild|snowflake',
prompt: 'What server would you like to find information about?',
retry: '{error} Choose a valid server to find information about.',
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 89d3c23..2d7fcfb 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -14,7 +14,7 @@ export default class UserInfoCommand extends BushCommand {
{
id: 'user',
description: 'The user you would like to find information about.',
- customType: util.arg.union('user', 'snowflake'),
+ type: util.arg.union('user', 'snowflake'),
readableType: 'user|snowflake',
prompt: 'What user would you like to find information about?',
retry: '{error} Choose a valid user to find information about.',
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 3d68a97..506a7c3 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -13,7 +13,7 @@ export default class BanCommand extends BushCommand {
{
id: 'user',
description: 'The user that will be banned.',
- customType: util.arg.union('user', 'snowflake'),
+ type: util.arg.union('user', 'snowflake'),
prompt: 'What user would you like to ban?',
retry: '{error} Choose a valid user to ban.',
slashType: 'USER'
@@ -35,7 +35,7 @@ export default class BanCommand extends BushCommand {
match: 'option',
prompt: "How many days of the user's messages would you like to delete?",
retry: '{error} Choose between 0 and 7 days to delete messages from the user for.',
- customType: util.arg.range('integer', 0, 7, true),
+ type: util.arg.range('integer', 0, 7, true),
optional: true,
slashType: 'INTEGER',
choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v }))
@@ -91,7 +91,7 @@ export default class BanCommand extends BushCommand {
return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`);
}
- let time: number;
+ let time: number | null;
if (args.reason) {
time = typeof args.reason === 'string' ? await util.arg.cast('duration', message, args.reason) : args.reason.duration;
}
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 474eaa9..0f2d33c 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -13,7 +13,7 @@ export default class ModlogCommand extends BushCommand {
{
id: 'search',
description: 'The case id or user to search for modlogs by.',
- customType: util.arg.union('user', 'string'),
+ type: util.arg.union('user', 'string'),
prompt: 'What case id or user would you like to see?',
retry: '{error} Choose a valid case id or user.',
slashType: 'STRING'
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index a18c04e..c7091b3 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -49,7 +49,7 @@ export default class MuteCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: { user: BushUser; reason?: { duration: number | null; contentWithoutTime: string } | string; force: boolean }
) {
- const reason: { duration: number | null; contentWithoutTime: string } = args.reason
+ const reason: { duration: number | null; contentWithoutTime: string | null } = args.reason
? typeof args.reason === 'string'
? await util.arg.cast('contentWithDuration', message, args.reason)
: args.reason
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
index 21b9a3a..f039046 100644
--- a/src/commands/moderation/purge.ts
+++ b/src/commands/moderation/purge.ts
@@ -13,7 +13,7 @@ export default class PurgeCommand extends BushCommand {
{
id: 'amount',
description: 'The amount of messages to purge.',
- customType: util.arg.range('integer', 1, 100, true),
+ type: util.arg.range('integer', 1, 100, true),
readableType: 'integer',
prompt: 'How many messages would you like to purge?',
retry: '{error} Please pick a number between 1 and 100.',
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index d543f60..4ada9d5 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -21,7 +21,7 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
{
id: 'emoji',
description: 'The emoji to remove all the reactions of from a message.',
- customType: util.arg.union('emoji', 'snowflake'),
+ type: util.arg.union('emoji', 'snowflake'),
readableType: 'emoji|snowflake',
match: 'restContent',
prompt: 'What emoji would you like to remove?',
diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts
index 949038c..f4ab822 100644
--- a/src/commands/moderation/slowmode.ts
+++ b/src/commands/moderation/slowmode.ts
@@ -21,7 +21,7 @@ export default class SlowModeCommand extends BushCommand {
{
id: 'length',
description: 'The amount of time to set the slowmode of a channel to.',
- customType: Argument.union('duration', 'durationSeconds', 'off', 'none', 'disable'),
+ type: Argument.union('duration', 'durationSeconds', 'off', 'none', 'disable'),
readableType: "duration|durationSeconds|'off'|'none'|'disable'",
prompt: 'What would you like to set the slowmode to?',
retry: '{error} Please set the slowmode to a valid length.',
@@ -52,7 +52,7 @@ export default class SlowModeCommand extends BushCommand {
length,
channel
}: {
- length: number | 'off' | 'none' | 'disable';
+ length: number | 'off' | 'none' | 'disable' | null;
channel: TextChannel | ThreadChannel | BushTextChannel | BushNewsChannel | BushThreadChannel | NewsChannel;
}
) {
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index a88b323..2404c4d 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -62,7 +62,7 @@ export default class RuleCommand extends BushCommand {
{
id: 'rule',
description: 'The rule to view.',
- customType: util.arg.range('integer', 1, rules.length, true),
+ type: util.arg.range('integer', 1, rules.length, true),
readableType: 'integer',
prompt: 'What rule would you like to have cited?',
retry: '{error} Choose a valid rule.',
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 6829757..2ab56cc 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -112,7 +112,7 @@ export default class YouTubeCommand extends BushCommand {
id: 'activity',
description: 'The activity to create an invite for.',
match: 'rest',
- customType: activityTypeCaster,
+ type: activityTypeCaster,
prompt: 'What activity would you like to play?',
retry: `{error} You must choose one of the following options: ${Object.values(activityMap)
.flatMap((a) => a.aliases)
diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts
index 190277a..6a15d71 100644
--- a/src/commands/utilities/steal.ts
+++ b/src/commands/utilities/steal.ts
@@ -1,5 +1,5 @@
import { BushCommand, BushSlashMessage, type BushMessage } from '#lib';
-import { ArgumentOptions, Flag } from 'discord-akairo';
+import { ArgumentOptions, ArgumentType, ArgumentTypeCaster, Flag } from 'discord-akairo';
import { type Snowflake } from 'discord.js';
import _ from 'lodash';
@@ -15,7 +15,7 @@ export default class StealCommand extends BushCommand {
{
id: 'emoji',
description: 'The emoji to steal.',
- customType: util.arg.union('discordEmoji', 'snowflake', 'url'),
+ type: util.arg.union('discordEmoji', 'snowflake', 'url'),
readableType: 'discordEmoji|snowflake|url',
prompt: 'What emoji would you like to steal?',
retry: '{error} Pick a valid emoji, emoji id, or image url.',
@@ -47,7 +47,7 @@ export default class StealCommand extends BushCommand {
? message.attachments.first()!.url
: yield {
id: 'emoji',
- type: util.arg.union('discordEmoji', 'snowflake', 'url'),
+ type: util.arg.union('discordEmoji', 'snowflake', 'url') as ArgumentType | ArgumentTypeCaster,
prompt: {
start: 'What emoji would you like to steal?',
retry: '{error} Pick a valid emoji, emoji id, or image url.'
diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts
index c934e2e..0809a39 100644
--- a/src/commands/utilities/viewRaw.ts
+++ b/src/commands/utilities/viewRaw.ts
@@ -13,7 +13,7 @@ export default class ViewRawCommand extends BushCommand {
{
id: 'message',
description: 'The message to view the raw content of.',
- customType: util.arg.union('guildMessage', 'messageLink'),
+ type: util.arg.union('guildMessage', 'messageLink'),
readableType: 'guildMessage|messageLink',
prompt: 'What message would you like to view?',
retry: '{error} Choose a valid message.',