aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/commands
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/_fake-command/ironmoon.ts6
-rw-r--r--src/commands/admin/channelPermissions.ts10
-rw-r--r--src/commands/admin/roleAll.ts5
-rw-r--r--src/commands/config/_customAutomodPhrases.ts8
-rw-r--r--src/commands/config/blacklist.ts12
-rw-r--r--src/commands/config/config.ts15
-rw-r--r--src/commands/config/disable.ts6
-rw-r--r--src/commands/config/features.ts8
-rw-r--r--src/commands/config/log.ts4
-rw-r--r--src/commands/dev/__template.ts4
-rw-r--r--src/commands/dev/debug.ts4
-rw-r--r--src/commands/dev/dm.ts4
-rw-r--r--src/commands/dev/eval.ts30
-rw-r--r--src/commands/dev/javascript.ts9
-rw-r--r--src/commands/dev/reload.ts8
-rw-r--r--src/commands/dev/say.ts6
-rw-r--r--src/commands/dev/servers.ts7
-rw-r--r--src/commands/dev/sh.ts8
-rw-r--r--src/commands/dev/superUser.ts23
-rw-r--r--src/commands/dev/syncAutomod.ts4
-rw-r--r--src/commands/dev/test.ts300
-rw-r--r--src/commands/fun/coinFlip.ts4
-rw-r--r--src/commands/fun/dice.ts4
-rw-r--r--src/commands/fun/eightBall.ts4
-rw-r--r--src/commands/fun/minesweeper.ts24
-rw-r--r--src/commands/info/avatar.ts7
-rw-r--r--src/commands/info/botInfo.ts4
-rw-r--r--src/commands/info/color.ts33
-rw-r--r--src/commands/info/guildInfo.ts28
-rw-r--r--src/commands/info/help.ts14
-rw-r--r--src/commands/info/icon.ts4
-rw-r--r--src/commands/info/links.ts4
-rw-r--r--src/commands/info/ping.ts12
-rw-r--r--src/commands/info/pronouns.ts4
-rw-r--r--src/commands/info/snowflake.ts16
-rw-r--r--src/commands/info/userInfo.ts41
-rw-r--r--src/commands/leveling/leaderboard.ts4
-rw-r--r--src/commands/leveling/level.ts16
-rw-r--r--src/commands/leveling/levelRoles.ts4
-rw-r--r--src/commands/leveling/setLevel.ts4
-rw-r--r--src/commands/leveling/setXp.ts4
-rw-r--r--src/commands/moderation/_activePunishments.ts149
-rw-r--r--src/commands/moderation/ban.ts12
-rw-r--r--src/commands/moderation/block.ts11
-rw-r--r--src/commands/moderation/evidence.ts47
-rw-r--r--src/commands/moderation/hideCase.ts4
-rw-r--r--src/commands/moderation/kick.ts9
-rw-r--r--src/commands/moderation/lockdown.ts18
-rw-r--r--src/commands/moderation/massBan.ts8
-rw-r--r--src/commands/moderation/massEvidence.ts4
-rw-r--r--src/commands/moderation/modlog.ts6
-rw-r--r--src/commands/moderation/mute.ts10
-rw-r--r--src/commands/moderation/purge.ts16
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts6
-rw-r--r--src/commands/moderation/role.ts17
-rw-r--r--src/commands/moderation/slowmode.ts17
-rw-r--r--src/commands/moderation/timeout.ts8
-rw-r--r--src/commands/moderation/unban.ts10
-rw-r--r--src/commands/moderation/unblock.ts11
-rw-r--r--src/commands/moderation/unlockdown.ts13
-rw-r--r--src/commands/moderation/unmute.ts13
-rw-r--r--src/commands/moderation/untimeout.ts10
-rw-r--r--src/commands/moderation/warn.ts10
-rw-r--r--src/commands/moulberry-bush/capePermissions.ts4
-rw-r--r--src/commands/moulberry-bush/capes.ts15
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts4
-rw-r--r--src/commands/moulberry-bush/moulHammer.ts6
-rw-r--r--src/commands/moulberry-bush/report.ts4
-rw-r--r--src/commands/moulberry-bush/rule.ts4
-rw-r--r--src/commands/moulberry-bush/serverStatus.ts4
-rw-r--r--src/commands/utilities/_poll.ts149
-rw-r--r--src/commands/utilities/activity.ts11
-rw-r--r--src/commands/utilities/calculator.ts4
-rw-r--r--src/commands/utilities/decode.ts5
-rw-r--r--src/commands/utilities/hash.ts4
-rw-r--r--src/commands/utilities/highlight-!.ts12
-rw-r--r--src/commands/utilities/highlight-add.ts7
-rw-r--r--src/commands/utilities/highlight-block.ts9
-rw-r--r--src/commands/utilities/highlight-clear.ts4
-rw-r--r--src/commands/utilities/highlight-matches.ts8
-rw-r--r--src/commands/utilities/highlight-remove.ts4
-rw-r--r--src/commands/utilities/highlight-show.ts4
-rw-r--r--src/commands/utilities/highlight-unblock.ts9
-rw-r--r--src/commands/utilities/price.ts8
-rw-r--r--src/commands/utilities/remind.ts6
-rw-r--r--src/commands/utilities/reminders.ts7
-rw-r--r--src/commands/utilities/steal.ts20
-rw-r--r--src/commands/utilities/suicide.ts4
-rw-r--r--src/commands/utilities/uuid.ts18
-rw-r--r--src/commands/utilities/viewRaw.ts19
-rw-r--r--src/commands/utilities/whoHasRole.ts8
-rw-r--r--src/commands/utilities/wolframAlpha.ts7
92 files changed, 741 insertions, 752 deletions
diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts
index 1f63c06..cb50c7e 100644
--- a/src/commands/_fake-command/ironmoon.ts
+++ b/src/commands/_fake-command/ironmoon.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
export default class IronmoonCommand extends BushCommand {
public constructor() {
@@ -13,13 +13,13 @@ export default class IronmoonCommand extends BushCommand {
});
}
- public override condition(message: BushMessage): boolean {
+ public override condition(message: CommandMessage): boolean {
return false;
if (message.content.toLowerCase().includes('ironmoon')) return true;
else return false;
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
return await message.util.reply('Your message included the word ironmoon.');
}
}
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts
index d58a7da..f6240a5 100644
--- a/src/commands/admin/channelPermissions.ts
+++ b/src/commands/admin/channelPermissions.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -57,12 +57,8 @@ export default class ChannelPermissionsCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: {
- target: ArgType<'member'> | ArgType<'role'>;
- permission: ArgType<'permission'>;
- state: 'true' | 'false' | 'neutral';
- }
+ message: CommandMessage | SlashMessage,
+ args: { target: ArgType<'member' | 'role'>; permission: ArgType<'permission'>; state: 'true' | 'false' | 'neutral' }
) {
assert(message.inGuild());
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts
index 7cb7346..80952cc 100644
--- a/src/commands/admin/roleAll.ts
+++ b/src/commands/admin/roleAll.ts
@@ -1,4 +1,5 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js';
@@ -39,7 +40,7 @@ export default class RoleAllCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'boolean'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'flag'> }) {
assert(message.inGuild());
if (!message.member!.permissions.has(PermissionFlagsBits.Administrator) && !message.member!.user.isOwner())
return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`);
diff --git a/src/commands/config/_customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts
index bd9bab5..13887ae 100644
--- a/src/commands/config/_customAutomodPhrases.ts
+++ b/src/commands/config/_customAutomodPhrases.ts
@@ -1,5 +1,5 @@
-// import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-// import { PermissionFlagsBits } from 'discord.js';
+// import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
+// import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
// export default class CustomAutomodPhrasesCommand extends BushCommand {
// public constructor() {
@@ -36,7 +36,7 @@
// }
// public override async exec(
-// message: BushMessage | BushSlashMessage,
-// args: { required_argument: string; optional_argument: string }
+// message: CommandMessage | SlashMessage,
+// args: { required_argument: ArgType<'string'>; optional_argument: OptArgType<'string'> }
// ) {}
// }
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index ba2d24a..de457c0 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -1,6 +1,6 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, PermissionFlagsBits, User } from 'discord.js';
+import { ApplicationCommandOptionType, GuildMember, PermissionFlagsBits, User } from 'discord.js';
export default class BlacklistCommand extends BushCommand {
public constructor() {
@@ -47,11 +47,11 @@ export default class BlacklistCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
action?: 'blacklist' | 'unblacklist';
- target: ArgType<'channel'> | ArgType<'user'> | string; // there is no way to combine channel and user in slash commands without making subcommands
- global: ArgType<'boolean'>;
+ target: ArgType<'channel' | 'user'> | string; // there is no way to combine channel and user in slash commands without making subcommands
+ global: ArgType<'flag'>;
}
) {
let action: 'blacklist' | 'unblacklist' | 'toggle' =
@@ -88,7 +88,7 @@ export default class BlacklistCommand extends BushCommand {
const success = await (global
? util.setGlobal(key, newValue)
- : message.guild!.setSetting(key, newValue, message.member!)
+ : message.guild!.setSetting(key, newValue, message.member as GuildMember)
).catch(() => false);
if (!success)
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index e203d12..689a3af 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -4,12 +4,13 @@ import {
guildSettingsObj,
settingsArr,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
+ type CommandMessage,
type GuildSettings,
- type GuildSettingType
+ type GuildSettingType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
+
import { type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo';
import {
ActionRowBuilder,
@@ -149,7 +150,7 @@ export default class ConfigCommand extends BushCommand {
});
}
- public override *args(message: BushMessage): ArgumentGeneratorReturn {
+ public override *args(message: CommandMessage): ArgumentGeneratorReturn {
const optional = message.util.parsed!.alias === 'settings';
const setting: GuildSettings = yield {
id: 'setting',
@@ -205,13 +206,13 @@ export default class ConfigCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
setting?: GuildSettings;
subcommandGroup?: GuildSettings;
action?: Action;
subcommand?: Action;
- value: ArgType<'channel'> | ArgType<'role'> | string;
+ value: ArgType<'channel' | 'role'> | string;
}
) {
assert(message.inGuild());
@@ -305,7 +306,7 @@ export default class ConfigCommand extends BushCommand {
}
public async generateMessageOptions(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
setting?: undefined | keyof typeof guildSettingsObj
): Promise<MessageOptions & InteractionUpdateOptions> {
assert(message.inGuild());
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index dea7b0f..373b5f6 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js';
import Fuse from 'fuse.js';
@@ -54,8 +54,8 @@ export default class DisableCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { action?: 'enable' | 'disable'; command: ArgType<'commandAlias'> | string; global: boolean }
+ message: CommandMessage | SlashMessage,
+ args: { action?: 'enable' | 'disable'; command: ArgType<'commandAlias'> | string; global: ArgType<'flag'> }
) {
assert(message.inGuild());
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index 2eee0fe..95ae544 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -2,9 +2,9 @@ import {
BushCommand,
guildFeaturesArr,
guildFeaturesObj,
- type BushMessage,
- type BushSlashMessage,
- type GuildFeatures
+ type CommandMessage,
+ type GuildFeatures,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import {
@@ -32,7 +32,7 @@ export default class FeaturesCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
assert(message.inGuild());
const featureEmbed = new EmbedBuilder().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default);
diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts
index f99f007..7c76bdf 100644
--- a/src/commands/config/log.ts
+++ b/src/commands/config/log.ts
@@ -1,4 +1,4 @@
-import { BushCommand, guildLogsArr, type ArgType, type BushMessage, type BushSlashMessage, type GuildLogType } from '#lib';
+import { BushCommand, guildLogsArr, type ArgType, type CommandMessage, type GuildLogType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ArgumentGeneratorReturn } from 'discord-akairo';
import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js';
@@ -70,7 +70,7 @@ export default class LogCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { log_type: GuildLogType; channel: ArgType<'textChannel'> }
) {
assert(message.inGuild());
diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts
index ace8802..7bcce32 100644
--- a/src/commands/dev/__template.ts
+++ b/src/commands/dev/__template.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class TemplateCommand extends BushCommand {
@@ -39,7 +39,7 @@ export default class TemplateCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { required_argument: ArgType<'string'>; optional_argument: OptArgType<'string'> }
) {
return await message.util.reply(`${util.emojis.error} Do not use the template command.`);
diff --git a/src/commands/dev/debug.ts b/src/commands/dev/debug.ts
index f8c614d..682a93d 100644
--- a/src/commands/dev/debug.ts
+++ b/src/commands/dev/debug.ts
@@ -1,4 +1,4 @@
-// import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+// import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
// import { ApplicationCommandOptionType, AutocompleteInteraction, ChatInputCommandInteraction } from 'discord.js';
// import Fuse from 'fuse.js';
@@ -29,7 +29,7 @@
// });
// }
-// public override async exec(message: BushMessage | BushSlashMessage, args: { action: ArgType<'string'> }) {
+// public override async exec(message: CommandMessage | SlashMessage, args: { action: ArgType<'string'> }) {
// if (args.action === 'util.reply') {
// return await message.util.reply(`This is a util.reply`);
// } else if (args.action === 'util.reply-object') {
diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts
index 0646f59..468fb20 100644
--- a/src/commands/dev/dm.ts
+++ b/src/commands/dev/dm.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class DMCommand extends BushCommand {
@@ -37,7 +37,7 @@ export default class DMCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { user: ArgType<'user'>; content: ArgType<'string'> }
) {
try {
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 8af280d..b8ee9e4 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -3,8 +3,6 @@ import {
ActivePunishment,
BushCommand,
BushInspectOptions,
- BushMessage,
- BushSlashMessage,
CodeBlockLang,
Global,
Guild,
@@ -12,7 +10,9 @@ import {
ModLog,
Shared,
StickyRole,
- type ArgType
+ type ArgType,
+ type CommandMessage,
+ type SlashMessage
} from '#lib';
import { Snowflake as Snowflake_ } from '@sapphire/snowflake';
import assert from 'assert';
@@ -57,7 +57,7 @@ const { transpile } = ts,
/* eslint-enable @typescript-eslint/no-unused-vars */
// prettier-ignore
-util.assertAll(ActivePunishment, BushCommand, BushMessage, BushSlashMessage, Global, Guild, Level, ModLog, Shared, StickyRole, Snowflake_, Canvas, exec, ActionRow, ButtonComponent, ButtonInteraction, Collection, Collector, CommandInteraction, ContextMenuCommandInteraction, DMChannel, Embed, Emoji, Interaction, InteractionCollector, Message, Attachment, MessageCollector, OAuth2Scopes, PermissionFlagsBits, PermissionsBitField, ReactionCollector, SelectMenuComponent, Util, path, ts, fileURLToPath, promisify, assert, got, transpile, emojis, colors, sh, SnowflakeUtil, __dirname);
+util.assertAll(ActivePunishment, BushCommand, Global, Guild, Level, ModLog, Shared, StickyRole, Snowflake_, Canvas, exec, ActionRow, ButtonComponent, ButtonInteraction, Collection, Collector, CommandInteraction, ContextMenuCommandInteraction, DMChannel, Embed, Emoji, Interaction, InteractionCollector, Message, Attachment, MessageCollector, OAuth2Scopes, PermissionFlagsBits, PermissionsBitField, ReactionCollector, SelectMenuComponent, Util, path, ts, fileURLToPath, promisify, assert, got, transpile, emojis, colors, sh, SnowflakeUtil, __dirname);
export default class EvalCommand extends BushCommand {
public constructor() {
@@ -180,7 +180,7 @@ export default class EvalCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{
code: argCode,
sel_depth: selDepth,
@@ -196,15 +196,15 @@ export default class EvalCommand extends BushCommand {
}: {
code: ArgType<'string'>;
sel_depth: ArgType<'integer'>;
- sudo: ArgType<'boolean'>;
- silent: ArgType<'boolean'>;
- delete_msg: ArgType<'boolean'>;
- typescript: ArgType<'boolean'>;
- hidden: ArgType<'boolean'>;
- show_proto: ArgType<'boolean'>;
- show_methods: ArgType<'boolean'>;
- async: ArgType<'boolean'>;
- no_inspect_strings: ArgType<'boolean'>;
+ sudo: ArgType<'flag'>;
+ silent: ArgType<'flag'>;
+ delete_msg: ArgType<'flag'>;
+ typescript: ArgType<'flag'>;
+ hidden: ArgType<'flag'>;
+ show_proto: ArgType<'flag'>;
+ show_methods: ArgType<'flag'>;
+ async: ArgType<'flag'>;
+ no_inspect_strings: ArgType<'flag'>;
}
) {
if (!message.author.isOwner())
@@ -322,5 +322,3 @@ interface CodeBlockCustomOptions extends CodeBlockOptions {
prototype?: boolean;
methods?: boolean;
}
-
-/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuCommandInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|ActionRow|Attachment|ButtonComponent|MessageCollector|SelectMenuComponent|ReactionCollector|Util|Canvas|Shared|PermissionsBitField|got} VSCodePleaseDontRemove */
diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts
index be8fdce..fd1894b 100644
--- a/src/commands/dev/javascript.ts
+++ b/src/commands/dev/javascript.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js';
import { VM } from 'vm2';
@@ -41,11 +41,8 @@ export default class JavascriptCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: {
- sel_depth: ArgType<'integer'>;
- code: string;
- }
+ message: CommandMessage | SlashMessage,
+ args: { code: ArgType<'string'>; sel_depth: OptArgType<'integer'> }
) {
if (!message.author.isSuperUser())
return await message.util.reply(`${util.emojis.error} Only super users can run this command.`);
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 17802b0..96c395f 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
export default class ReloadCommand extends BushCommand {
public constructor() {
@@ -13,7 +13,7 @@ export default class ReloadCommand extends BushCommand {
// id: 'fast',
// description: 'Whether or not to use esbuild for fast compiling.',
// match: 'flag',
- // flag: '--fast',
+ // flag: ['--fast'],
// prompt: 'Would you like to use esbuild for fast compiling?',
// optional: true,
// slashType: ApplicationCommandOptionType.Boolean
@@ -27,14 +27,14 @@ export default class ReloadCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage /* { fast }: { fast: boolean } */) {
+ public override async exec(message: CommandMessage | SlashMessage /* args: { fast: ArgType<'flag'> } */) {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
let output: { stdout: string; stderr: string };
try {
const s = new Date();
- output = await util.shell(`yarn build:${/* fast ? 'esbuild' : */ 'tsc'}`);
+ output = await util.shell(`yarn build:${/* args.fast ? 'esbuild' : */ 'tsc'}`);
await Promise.all([
client.commandHandler.reloadAll(),
client.listenerHandler.reloadAll(),
diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts
index bbada0c..a452126 100644
--- a/src/commands/dev/say.ts
+++ b/src/commands/dev/say.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class SayCommand extends BushCommand {
@@ -27,7 +27,7 @@ export default class SayCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { content: string }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { content: ArgType<'string'> }) {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
@@ -35,7 +35,7 @@ export default class SayCommand extends BushCommand {
await message.util.send({ content: args.content, allowedMentions: AllowedMentions.none() }).catch(() => null);
}
- public override async execSlash(message: BushSlashMessage, args: { content: string }) {
+ public override async execSlash(message: SlashMessage, args: { content: string }) {
if (!client.config.owners.includes(message.author.id)) {
return await message.interaction.reply({
content: `${util.emojis.error} Only my developers can run this command.`,
diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts
index 0701158..e99bcda 100644
--- a/src/commands/dev/servers.ts
+++ b/src/commands/dev/servers.ts
@@ -1,7 +1,6 @@
-import { BushCommand, ButtonPaginator, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, type CommandMessage, type SlashMessage } from '#lib';
import { stripIndent } from '#tags';
-import type { APIEmbed } from 'discord-api-types/v10';
-import type { Guild } from 'discord.js';
+import { type APIEmbed, type Guild } from 'discord.js';
export default class ServersCommand extends BushCommand {
public constructor() {
@@ -17,7 +16,7 @@ export default class ServersCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const guilds = [...client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).values()];
const chunkedGuilds: Guild[][] = util.chunk(guilds, 10);
const embeds: APIEmbed[] = chunkedGuilds.map((chunk) => {
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts
index d47ecd2..8c62f5d 100644
--- a/src/commands/dev/sh.ts
+++ b/src/commands/dev/sh.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { ArgType, BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
import { exec } from 'child_process';
@@ -40,10 +40,10 @@ export default class ShCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, { command }: { command: string }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { command: ArgType<'string'> }) {
if (!client.config.owners.includes(message.author.id))
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
- const input = clean(command);
+ const input = clean(args.command);
const embed = new EmbedBuilder()
.setColor(util.colors.gray)
@@ -65,7 +65,7 @@ export default class ShCommand extends BushCommand {
return abc.replace(new RegExp(pattern, 'g'), '');
} */
try {
- const output = await sh(command, { env: { ...process.env, FORCE_COLOR: 'true' } });
+ const output = await sh(args.command, { env: { ...process.env, FORCE_COLOR: 'true' } });
const stdout = /* strip( */ clean(output.stdout); /* ) */
const stderr = /* strip( */ clean(output.stderr); /* ) */
diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts
index d62ac8e..6a2b745 100644
--- a/src/commands/dev/superUser.ts
+++ b/src/commands/dev/superUser.ts
@@ -1,6 +1,5 @@
-import { BushCommand, type ArgType, type BushMessage } from '#lib';
-import { ArgumentGeneratorReturn } from 'discord-akairo';
-import { ArgumentTypeCasterReturn } from 'discord-akairo/dist/src/struct/commands/arguments/Argument.js';
+import { BushCommand, type ArgType, type CommandMessage } from '#lib';
+import { type ArgumentGeneratorReturn, type ArgumentTypeCasterReturn } from 'discord-akairo';
export default class SuperUserCommand extends BushCommand {
public constructor() {
@@ -54,30 +53,30 @@ export default class SuperUserCommand extends BushCommand {
return { action, user };
}
- public override async exec(message: BushMessage, { action, user }: { action: 'add' | 'remove'; user: ArgType<'user'> }) {
+ public override async exec(message: CommandMessage, args: { action: 'add' | 'remove'; user: ArgType<'user'> }) {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
const superUsers: string[] = util.getShared('superUsers');
- if (action === 'add' ? superUsers.includes(user.id) : !superUsers.includes(user.id))
+ if (args.action === 'add' ? superUsers.includes(args.user.id) : !superUsers.includes(args.user.id))
return message.util.reply(
- `${util.emojis.warn} ${util.format.input(user.tag)} is ${action === 'add' ? 'already' : 'not'} a superuser.`
+ `${util.emojis.warn} ${util.format.input(args.user.tag)} is ${args.action === 'add' ? 'already' : 'not'} a superuser.`
);
- const success = await util.insertOrRemoveFromShared(action, 'superUsers', user.id).catch(() => false);
+ const success = await util.insertOrRemoveFromShared(args.action, 'superUsers', args.user.id).catch(() => false);
if (success) {
return await message.util.reply(
- `${util.emojis.success} ${action == 'remove' ? '' : 'made'} ${util.format.input(user.tag)} ${
- action == 'remove' ? 'is no longer ' : ''
+ `${util.emojis.success} ${args.action == 'remove' ? '' : 'made'} ${util.format.input(args.user.tag)} ${
+ args.action == 'remove' ? 'is no longer ' : ''
}a superuser.`
);
} else {
return await message.util.reply(
- `${util.emojis.error} There was an error ${action == 'remove' ? `removing` : 'making'} ${util.format.input(user.tag)} ${
- action == 'remove' ? `from` : 'to'
- } the superuser list.`
+ `${util.emojis.error} There was an error ${args.action == 'remove' ? `removing` : 'making'} ${util.format.input(
+ args.user.tag
+ )} ${args.action == 'remove' ? `from` : 'to'} the superuser list.`
);
}
}
diff --git a/src/commands/dev/syncAutomod.ts b/src/commands/dev/syncAutomod.ts
index 4d4a6d7..9954e70 100644
--- a/src/commands/dev/syncAutomod.ts
+++ b/src/commands/dev/syncAutomod.ts
@@ -1,4 +1,4 @@
-import { BushCommand, Shared, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, Shared, type CommandMessage, type SlashMessage } from '#lib';
import got from 'got';
import typescript from 'typescript';
import { NodeVM } from 'vm2';
@@ -18,7 +18,7 @@ export default class SyncAutomodCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
if (!message.author.isOwner() && message.author.id !== '497789163555389441')
return await message.util.reply(`${util.emojis.error} Only a very select few may use this command.`);
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index 2d7b1f8..d54d544 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -1,11 +1,11 @@
-import { BushCommand, ButtonPaginator, Shared, type BushMessage } from '#lib';
-import { Routes } from 'discord-api-types/rest/v9';
+import { BushCommand, ButtonPaginator, OptArgType, Shared, type CommandMessage } from '#lib';
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
EmbedBuilder,
GatewayDispatchEvents,
+ Routes,
type ApplicationCommand,
type Collection
} from 'discord.js';
@@ -38,7 +38,7 @@ export default class TestCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage, args: { feature: string }) {
+ public override async exec(message: CommandMessage, args: { feature: OptArgType<'string'> }) {
const responses = [
'Yes master.',
'Test it your self bitch, I am hungry.',
@@ -51,166 +51,168 @@ export default class TestCommand extends BushCommand {
return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);
}
- if (['button', 'buttons'].includes(args.feature?.toLowerCase())) {
- const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder({ style: ButtonStyle.Primary, customId: 'primaryButton', label: 'Primary' }),
- new ButtonBuilder({ style: ButtonStyle.Secondary, customId: 'secondaryButton', label: 'Secondary' }),
- new ButtonBuilder({ style: ButtonStyle.Success, customId: 'successButton', label: 'Success' }),
- new ButtonBuilder({ style: ButtonStyle.Danger, customId: 'dangerButton', label: 'Danger' }),
- new ButtonBuilder({ style: ButtonStyle.Link, label: 'Link', url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
- ]);
- return await message.util.reply({ content: 'buttons', components: [buttonRow] });
- } else if (['embed', 'button embed'].includes(args.feature?.toLowerCase())) {
- const embed = new EmbedBuilder()
- .addFields([{ name: 'Field Name', value: 'Field Content' }])
- .setAuthor({ name: 'Author', iconURL: 'https://www.w3schools.com/w3css/img_snowtops.jpg', url: 'https://google.com/' })
- .setColor(message.member?.displayColor ?? util.colors.default)
- .setDescription('Description')
- .setFooter({ text: 'Footer', iconURL: message.author.avatarURL() ?? undefined })
- .setURL('https://duckduckgo.com/')
- .setTimestamp()
- .setImage('https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png')
- .setThumbnail(
- 'https://images.unsplash.com/photo-1501183007986-d0d080b147f9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2134&q=80'
- )
- .setTitle('Title');
+ if (args.feature) {
+ if (['button', 'buttons'].includes(args.feature?.toLowerCase())) {
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder({ style: ButtonStyle.Primary, customId: 'primaryButton', label: 'Primary' }),
+ new ButtonBuilder({ style: ButtonStyle.Secondary, customId: 'secondaryButton', label: 'Secondary' }),
+ new ButtonBuilder({ style: ButtonStyle.Success, customId: 'successButton', label: 'Success' }),
+ new ButtonBuilder({ style: ButtonStyle.Danger, customId: 'dangerButton', label: 'Danger' }),
+ new ButtonBuilder({ style: ButtonStyle.Link, label: 'Link', url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
+ ]);
+ return await message.util.reply({ content: 'buttons', components: [buttonRow] });
+ } else if (['embed', 'button embed'].includes(args.feature?.toLowerCase())) {
+ const embed = new EmbedBuilder()
+ .addFields([{ name: 'Field Name', value: 'Field Content' }])
+ .setAuthor({ name: 'Author', iconURL: 'https://www.w3schools.com/w3css/img_snowtops.jpg', url: 'https://google.com/' })
+ .setColor(message.member?.displayColor ?? util.colors.default)
+ .setDescription('Description')
+ .setFooter({ text: 'Footer', iconURL: message.author.avatarURL() ?? undefined })
+ .setURL('https://duckduckgo.com/')
+ .setTimestamp()
+ .setImage('https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png')
+ .setThumbnail(
+ 'https://images.unsplash.com/photo-1501183007986-d0d080b147f9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2134&q=80'
+ )
+ .setTitle('Title');
- const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder({ style: ButtonStyle.Link, label: 'Link', url: 'https://google.com/' })
- ]);
- return await message.util.reply({ content: 'Test', embeds: [embed], components: [buttonRow] });
- } else if (['lots of buttons'].includes(args.feature?.toLowerCase())) {
- const buttonRows: ActionRowBuilder<ButtonBuilder>[] = [];
- for (let a = 1; a <= 5; a++) {
- const row = new ActionRowBuilder<ButtonBuilder>();
- for (let b = 1; b <= 5; b++) {
- const id = (a + 5 * (b - 1)).toString();
- const button = new ButtonBuilder({ style: ButtonStyle.Primary, customId: id, label: id });
- row.addComponents([button]);
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder({ style: ButtonStyle.Link, label: 'Link', url: 'https://google.com/' })
+ ]);
+ return await message.util.reply({ content: 'Test', embeds: [embed], components: [buttonRow] });
+ } else if (['lots of buttons'].includes(args.feature?.toLowerCase())) {
+ const buttonRows: ActionRowBuilder<ButtonBuilder>[] = [];
+ for (let a = 1; a <= 5; a++) {
+ const row = new ActionRowBuilder<ButtonBuilder>();
+ for (let b = 1; b <= 5; b++) {
+ const id = (a + 5 * (b - 1)).toString();
+ const button = new ButtonBuilder({ style: ButtonStyle.Primary, customId: id, label: id });
+ row.addComponents([button]);
+ }
+ buttonRows.push(row);
}
- buttonRows.push(row);
- }
- return await message.util.reply({ content: 'buttons', components: buttonRows });
- } else if (['paginate'].includes(args.feature?.toLowerCase())) {
- const embeds = [];
- for (let i = 1; i <= 5; i++) {
- embeds.push(new EmbedBuilder().setDescription(i.toString()));
- }
- return await ButtonPaginator.send(message, embeds);
- } else if (['lots of embeds'].includes(args.feature?.toLowerCase())) {
- const description = 'This is a description.';
- const _avatar = message.author.avatarURL() ?? undefined;
- const author = { name: 'This is a author', iconURL: _avatar };
- const footer = { text: 'This is a footer', iconURL: _avatar };
- const fields = Array(25)
- .fill(0)
- .map((_, i) => ({ name: `Field ${i}`, value: 'Field Value' }));
- const c = util.colors;
- const o = { description, author, footer, fields, time: Date.now() };
+ return await message.util.reply({ content: 'buttons', components: buttonRows });
+ } else if (['paginate'].includes(args.feature?.toLowerCase())) {
+ const embeds = [];
+ for (let i = 1; i <= 5; i++) {
+ embeds.push(new EmbedBuilder().setDescription(i.toString()));
+ }
+ return await ButtonPaginator.send(message, embeds);
+ } else if (['lots of embeds'].includes(args.feature?.toLowerCase())) {
+ const description = 'This is a description.';
+ const _avatar = message.author.avatarURL() ?? undefined;
+ const author = { name: 'This is a author', iconURL: _avatar };
+ const footer = { text: 'This is a footer', iconURL: _avatar };
+ const fields = Array(25)
+ .fill(0)
+ .map((_, i) => ({ name: `Field ${i}`, value: 'Field Value' }));
+ const c = util.colors;
+ const o = { description, author, footer, fields, time: Date.now() };
- const colors = [c.red, c.orange, c.gold, c.yellow, c.green, c.darkGreen, c.aqua, c.blue, c.purple, c.pink];
+ const colors = [c.red, c.orange, c.gold, c.yellow, c.green, c.darkGreen, c.aqua, c.blue, c.purple, c.pink];
- const embeds = colors.map((c, i) => ({ ...o, title: `Embed Title ${i}`, color: c }));
+ const embeds = colors.map((c, i) => ({ ...o, title: `Embed Title ${i}`, color: c }));
- const ButtonRows: ActionRowBuilder<ButtonBuilder>[] = [];
- for (let a = 1; a <= 5; a++) {
- const row = new ActionRowBuilder<ButtonBuilder>();
- for (let b = 1; b <= 5; b++) {
- const id = (a + 5 * (b - 1)).toString();
- const button = new ButtonBuilder({ style: ButtonStyle.Secondary, customId: id, label: id });
- row.addComponents([button]);
+ const ButtonRows: ActionRowBuilder<ButtonBuilder>[] = [];
+ for (let a = 1; a <= 5; a++) {
+ const row = new ActionRowBuilder<ButtonBuilder>();
+ for (let b = 1; b <= 5; b++) {
+ const id = (a + 5 * (b - 1)).toString();
+ const button = new ButtonBuilder({ style: ButtonStyle.Secondary, customId: id, label: id });
+ row.addComponents([button]);
+ }
+ ButtonRows.push(row);
}
- ButtonRows.push(row);
- }
- return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds });
- } else if (['delete slash commands'].includes(args.feature?.toLowerCase())) {
- if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`);
- await client.guilds.fetch();
- const promises: Promise<Collection<string, ApplicationCommand>>[] = [];
- client.guilds.cache.each((guild) => {
- promises.push(guild.commands.set([]));
- });
- await Promise.all(promises);
+ return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds });
+ } else if (['delete slash commands'].includes(args.feature?.toLowerCase())) {
+ if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`);
+ await client.guilds.fetch();
+ const promises: Promise<Collection<string, ApplicationCommand>>[] = [];
+ client.guilds.cache.each((guild) => {
+ promises.push(guild.commands.set([]));
+ });
+ await Promise.all(promises);
- await client.application!.commands.fetch();
- await client.application!.commands.set([]);
+ await client.application!.commands.fetch();
+ await client.application!.commands.set([]);
- return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`);
- } else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args.feature?.toLowerCase())) {
- return message.util.reply(`${util.emojis.error} no`);
- } else if (['sync automod'].includes(args.feature?.toLowerCase())) {
- const row = (await Shared.findByPk(0))!;
- row.badLinks = badLinksArray;
- row.badLinksSecret = badLinksSecretArray;
- row.badWords = badWords;
- await row.save();
- return await message.util.reply(`${util.emojis.success} Synced automod.`);
- } else if (['modal'].includes(args.feature?.toLowerCase())) {
- const m = await message.util.reply({
- content: 'Click for modal',
- components: [
- new ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder({ style: ButtonStyle.Primary, label: 'Modal', customId: 'test;modal' })
- ])
- ]
- });
+ return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`);
+ } else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args.feature?.toLowerCase())) {
+ return message.util.reply(`${util.emojis.error} no`);
+ } else if (['sync automod'].includes(args.feature?.toLowerCase())) {
+ const row = (await Shared.findByPk(0))!;
+ row.badLinks = badLinksArray;
+ row.badLinksSecret = badLinksSecretArray;
+ row.badWords = badWords;
+ await row.save();
+ return await message.util.reply(`${util.emojis.success} Synced automod.`);
+ } else if (['modal'].includes(args.feature?.toLowerCase())) {
+ const m = await message.util.reply({
+ content: 'Click for modal',
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder({ style: ButtonStyle.Primary, label: 'Modal', customId: 'test;modal' })
+ ])
+ ]
+ });
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- client.ws.on(GatewayDispatchEvents.InteractionCreate, async (i: any) => {
- if (i?.data?.custom_id !== 'test;modal' || i?.data?.component_type !== 2) return;
- if (i?.message?.id !== m.id) return;
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ client.ws.on(GatewayDispatchEvents.InteractionCreate, async (i: any) => {
+ if (i?.data?.custom_id !== 'test;modal' || i?.data?.component_type !== 2) return;
+ if (i?.message?.id !== m.id) return;
- const text = { type: 4, style: 1, min_length: 1, max_length: 4000, required: true };
+ const text = { type: 4, style: 1, min_length: 1, max_length: 4000, required: true };
- await this.client.rest.post(Routes.interactionCallback(i.id, i.token), {
- body: {
- type: 9,
- data: {
- custom_id: 'test;login',
- title: 'Login (real)',
- components: [
- {
- type: 1,
- components: [
- {
- ...text,
- custom_id: 'test;login;email',
- label: 'Email',
- placeholder: 'Email'
- }
- ]
- },
- {
- type: 1,
- components: [
- {
- ...text,
- custom_id: 'test;login;password',
- label: 'Password',
- placeholder: 'Password'
- }
- ]
- },
- {
- type: 1,
- components: [
- {
- ...text,
- custom_id: 'test;login;2fa',
- label: 'Enter Discord Auth Code',
- min_length: 6,
- max_length: 6,
- placeholder: '6-digit authentication code'
- }
- ]
- }
- ]
+ await this.client.rest.post(Routes.interactionCallback(i.id, i.token), {
+ body: {
+ type: 9,
+ data: {
+ custom_id: 'test;login',
+ title: 'Login (real)',
+ components: [
+ {
+ type: 1,
+ components: [
+ {
+ ...text,
+ custom_id: 'test;login;email',
+ label: 'Email',
+ placeholder: 'Email'
+ }
+ ]
+ },
+ {
+ type: 1,
+ components: [
+ {
+ ...text,
+ custom_id: 'test;login;password',
+ label: 'Password',
+ placeholder: 'Password'
+ }
+ ]
+ },
+ {
+ type: 1,
+ components: [
+ {
+ ...text,
+ custom_id: 'test;login;2fa',
+ label: 'Enter Discord Auth Code',
+ min_length: 6,
+ max_length: 6,
+ placeholder: '6-digit authentication code'
+ }
+ ]
+ }
+ ]
+ }
}
- }
+ });
});
- });
- return;
+ return;
+ }
}
return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);
}
diff --git a/src/commands/fun/coinFlip.ts b/src/commands/fun/coinFlip.ts
index b0805cd..fea5cb5 100644
--- a/src/commands/fun/coinFlip.ts
+++ b/src/commands/fun/coinFlip.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
export default class CoinFlipCommand extends BushCommand {
public constructor() {
@@ -14,7 +14,7 @@ export default class CoinFlipCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const random = Math.random();
let result: string;
const fall = message.author.id === '322862723090219008' ? 0.1 : 0.001; //dw about it
diff --git a/src/commands/fun/dice.ts b/src/commands/fun/dice.ts
index 53fc9e2..b2bc7e4 100644
--- a/src/commands/fun/dice.ts
+++ b/src/commands/fun/dice.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
export default class DiceCommand extends BushCommand {
public constructor() {
@@ -14,7 +14,7 @@ export default class DiceCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const responses = ['1', '2', '3', '4', '5', '6'];
const answer = responses[Math.floor(Math.random() * responses.length)];
return await message.util.reply(`You rolled a **${answer}**.`);
diff --git a/src/commands/fun/eightBall.ts b/src/commands/fun/eightBall.ts
index ff06fe5..66fcc45 100644
--- a/src/commands/fun/eightBall.ts
+++ b/src/commands/fun/eightBall.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class EightBallCommand extends BushCommand {
@@ -26,7 +26,7 @@ export default class EightBallCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const responses = [
'It is certain',
'Without a doubt',
diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts
index 72551e9..d25cb5d 100644
--- a/src/commands/fun/minesweeper.ts
+++ b/src/commands/fun/minesweeper.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, OptArgType, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { Minesweeper } from '@notenoughupdates/discord.js-minesweeper';
import assert from 'assert';
import { ApplicationCommandOptionType } from 'discord.js';
@@ -53,10 +53,10 @@ export default class MinesweeperCommand extends BushCommand {
optional: true
},
{
- id: 'do_not_reveal_first_cell',
+ id: 'no_reveal',
description: 'Whether to not reveal the first cell automatically.',
match: 'flag',
- flag: ['--doNotRevealFirstCell', 'do_not_reveal_first_cell'],
+ flag: ['--noReveal', '--no_reveal', '--doNotRevealFirstCell', 'do_not_reveal_first_cell'],
prompt: 'Would you like to not automatically reveal the first cell?',
slashType: ApplicationCommandOptionType.Boolean,
optional: true
@@ -69,20 +69,24 @@ export default class MinesweeperCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- rows: ArgType<'integer'>;
- columns: ArgType<'integer'>;
- mines: ArgType<'integer'>;
- spaces: boolean;
- do_not_reveal_first_cell: boolean;
+ rows: OptArgType<'integer'>;
+ columns: OptArgType<'integer'>;
+ mines: OptArgType<'integer'>;
+ spaces: ArgType<'flag'>;
+ no_reveal: ArgType<'flag'>;
}
) {
+ args.rows ??= 9;
+ args.columns ??= 9;
+ args.mines ??= 10;
+
const minesweeper = new Minesweeper({
rows: args.rows,
columns: args.columns,
mines: args.mines,
- revealFirstCell: args.do_not_reveal_first_cell ? false : true,
+ revealFirstCell: args.no_reveal ? false : true,
spaces: args.spaces ?? false,
zeroFirstCell: false
});
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index 870908d..544c30a 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, PermissionFlagsBits } from 'discord.js';
export default class AvatarCommand extends BushCommand {
@@ -27,11 +27,12 @@ export default class AvatarCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'member'> | ArgType<'globalUser'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { user: OptArgType<'member' | 'globalUser'> }) {
const params: { size: 2048; extension: 'png'; dynamic: true } = { size: 2048, extension: 'png', dynamic: true };
const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${Math.ceil(Math.random() * 6) - 1}.png`;
- const member = (args.user ?? message.member) instanceof GuildMember ? args.user ?? message.member : undefined;
+ const member =
+ (args.user ?? message.member) instanceof GuildMember ? args.user ?? (message.member as GuildMember | null) : null;
const user = args.user instanceof GuildMember ? args.user.user : args.user ?? message.author;
const guildAvatar = member?.avatarURL(params);
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts
index e67ae5a..4a8a36a 100644
--- a/src/commands/info/botInfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { EmbedBuilder, PermissionFlagsBits, version as discordJSVersion } from 'discord.js';
import * as os from 'os';
@@ -20,7 +20,7 @@ export default class BotInfoCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
enum Platform {
aix = 'AIX',
android = 'Android',
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index a74c3f3..f60e28a 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -1,25 +1,9 @@
-import {
- AllowedMentions,
- BushCommand,
- type ArgType,
- type BushArgumentTypeCaster,
- type BushGuildMember,
- type BushMessage,
- type BushRole,
- type BushSlashMessage
-} from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits, Role } from 'discord.js';
+import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, PermissionFlagsBits, Role } from 'discord.js';
import tinycolor from 'tinycolor2';
-
assert(tinycolor);
-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;
-};
-
export default class ColorCommand extends BushCommand {
public constructor() {
super('color', {
@@ -32,7 +16,7 @@ export default class ColorCommand extends BushCommand {
{
id: 'color',
description: 'The color string, role, or member to find the color of.',
- type: util.arg.union(isValidTinyColor as any, 'role', 'member'),
+ type: util.arg.union('tinyColor', 'role', 'member'),
readableType: 'color|role|member',
match: 'restContent',
prompt: 'What color code, role, or user would you like to find the color of?',
@@ -50,15 +34,12 @@ export default class ColorCommand extends BushCommand {
return color.substring(4, color.length - 5);
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { color: string | ArgType<'role'> | ArgType<'member'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { color: ArgType<'tinyColor' | 'role' | 'member'> }) {
const _color = message.util.isSlashMessage(message)
- ? ((await util.arg.cast(util.arg.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as
+ ? ((await util.arg.cast(util.arg.union('tinyColor', 'role', 'member'), message, args.color as string)) as
| string
- | BushRole
- | BushGuildMember)
+ | Role
+ | GuildMember)
: args.color;
const color =
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 4872497..572cf06 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -1,10 +1,12 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
-import { GuildDefaultMessageNotifications, GuildExplicitContentFilter } from 'discord-api-types/v10';
import {
ApplicationCommandOptionType,
+ ChannelType,
EmbedBuilder,
Guild,
+ GuildDefaultMessageNotifications,
+ GuildExplicitContentFilter,
GuildMFALevel,
GuildPremiumTier,
GuildVerificationLevel,
@@ -41,17 +43,14 @@ export default class GuildInfoCommand extends BushCommand {
});
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { guild: OptArgType<'guild'> | OptArgType<'snowflake'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { guild: OptArgType<'guild' | 'snowflake'> }) {
if (!args.guild && !message.inGuild()) {
return await message.util.reply(
`${util.emojis.error} You must either provide an server to provide info about or run this command in a server.`
);
}
- let guild: ArgType<'guild'> | ArgType<'snowflake'> | GuildPreview = args.guild ?? message.guild!;
+ let guild: ArgType<'guild' | 'snowflake'> | GuildPreview = args.guild ?? message.guild!;
if (typeof guild === 'string') {
const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => undefined);
if (preview) guild = preview;
@@ -163,10 +162,19 @@ export default class GuildInfoCommand extends BushCommand {
const guildStats: string[] = [];
- const channelTypes = (['Text', 'Voice', 'News', 'Stage', 'Category', 'Thread'] as const).map(
+ const channelTypes = (
+ [
+ ['Text', [ChannelType.GuildText]],
+ ['Voice', [ChannelType.GuildVoice]],
+ ['News', [ChannelType.GuildNews]],
+ ['Stage', [ChannelType.GuildStageVoice]],
+ ['Category', [ChannelType.GuildCategory]],
+ ['Thread', [ChannelType.GuildNewsThread, ChannelType.GuildPrivateThread, ChannelType.GuildPublicThread]]
+ ] as const
+ ).map(
(type) =>
- `${client.consts.mappings.otherEmojis[`Channel${type}`]} ${guild.channels.cache
- .filter((channel) => channel[`is${type}`]())
+ `${client.consts.mappings.otherEmojis[`Channel${type[0]}`]} ${guild.channels.cache
+ .filter((channel) => type[1].some((type) => channel.type === type))
.size.toLocaleString()}`
);
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index ea1e965..af44980 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,10 +1,10 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { ButtonBuilder } from '@discordjs/builders';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import {
ActionRowBuilder,
ApplicationCommandOptionType,
AutocompleteInteraction,
+ ButtonBuilder,
ButtonStyle,
EmbedBuilder,
PermissionFlagsBits
@@ -53,7 +53,7 @@ export default class HelpCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: HelpArgs) {
+ public override async exec(message: CommandMessage | SlashMessage, args: HelpArgs) {
const row = this.addLinks(message);
const command = args.command
? typeof args.command === 'string'
@@ -70,7 +70,7 @@ export default class HelpCommand extends BushCommand {
}
}
- private helpAll(message: BushMessage | BushSlashMessage, args: HelpArgs, row: ActionRowBuilder<ButtonBuilder>) {
+ private helpAll(message: CommandMessage | SlashMessage, args: HelpArgs, row: ActionRowBuilder<ButtonBuilder>) {
const prefix = util.prefix(message);
const embed = new EmbedBuilder()
.setColor(util.colors.default)
@@ -99,7 +99,7 @@ export default class HelpCommand extends BushCommand {
return message.util.reply({ embeds: [embed], components: row.components.length ? [row] : undefined });
}
- private helpIndividual(message: BushMessage | BushSlashMessage, row: ActionRowBuilder<ButtonBuilder>, command: BushCommand) {
+ private helpIndividual(message: CommandMessage | SlashMessage, row: ActionRowBuilder<ButtonBuilder>, command: BushCommand) {
const embed = new EmbedBuilder().setColor(util.colors.default).setTitle(`${command.id} Command`);
let description = `${command.description ?? '*This command does not have a description.*'}`;
@@ -207,7 +207,7 @@ export default class HelpCommand extends BushCommand {
}
}
- private addLinks(message: BushMessage | BushSlashMessage) {
+ private addLinks(message: CommandMessage | SlashMessage) {
const row = new ActionRowBuilder<ButtonBuilder>();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
@@ -246,4 +246,4 @@ export default class HelpCommand extends BushCommand {
}
}
-type HelpArgs = { command: ArgType<'commandAlias'> | string; showHidden?: boolean };
+type HelpArgs = { command: OptArgType<'commandAlias'> | string; showHidden: ArgType<'flag'> };
diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts
index db390a5..9c9556b 100644
--- a/src/commands/info/icon.ts
+++ b/src/commands/info/icon.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -17,7 +17,7 @@ export default class IconCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
assert(message.inGuild());
const embed = new EmbedBuilder()
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index 91b62ca..0d5bd15 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
@@ -19,7 +19,7 @@ export default class LinksCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const buttonRow = new ActionRowBuilder<ButtonBuilder>();
if (!client.config.isDevelopment || message.author.isOwner()) {
buttonRow.addComponents([new ButtonBuilder({ style: ButtonStyle.Link, label: 'Invite Me', url: util.invite })]);
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index af0fa98..ad7fdcc 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -1,5 +1,5 @@
-import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
+import { BushCommand, type CommandMessage, type SlashMessage } from '#lib';
+import { EmbedBuilder, PermissionFlagsBits, type Message } from 'discord.js';
export default class PingCommand extends BushCommand {
public constructor() {
@@ -15,21 +15,21 @@ export default class PingCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage) {
+ public override async exec(message: CommandMessage) {
const timestamp1 = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp;
const msg = await message.util.reply('Pong!');
const timestamp2 = msg.editedTimestamp ? msg.editedTimestamp : msg.createdTimestamp;
void this.command(message, timestamp2 - timestamp1);
}
- public override async execSlash(message: BushSlashMessage) {
+ public override async execSlash(message: SlashMessage) {
const timestamp1 = message.createdTimestamp;
- const msg = (await message.util.reply({ content: 'Pong!', fetchReply: true })) as BushMessage;
+ const msg = (await message.util.reply({ content: 'Pong!', fetchReply: true })) as Message;
const timestamp2 = msg.editedTimestamp ? msg.editedTimestamp : msg.createdTimestamp;
void this.command(message, timestamp2 - timestamp1);
}
- private command(message: BushMessage | BushSlashMessage, msgLatency: number) {
+ private command(message: CommandMessage | SlashMessage, msgLatency: number) {
const botLatency = util.format.codeBlock(`${Math.round(msgLatency)}ms`);
const apiLatency = util.format.codeBlock(`${Math.round(message.client.ws.ping)}ms`);
const embed = new EmbedBuilder()
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index b45f9b3..f916687 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class PronounsCommand extends BushCommand {
@@ -26,7 +26,7 @@ export default class PronounsCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user?: ArgType<'globalUser'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { user: OptArgType<'globalUser'> }) {
const user = args.user ?? message.author;
const author = user.id === message.author.id;
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index 07544c9..e74756f 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { stripIndent } from '#tags';
import {
ApplicationCommandOptionType,
@@ -37,7 +37,7 @@ export default class SnowflakeCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { snowflake: ArgType<'snowflake'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { snowflake: ArgType<'snowflake'> }) {
const snowflake = `${args.snowflake}` as Snowflake;
const snowflakeEmbed = new EmbedBuilder().setTitle('Unknown :snowflake:').setColor(util.colors.default);
@@ -45,7 +45,7 @@ export default class SnowflakeCommand extends BushCommand {
if (client.channels.cache.has(snowflake)) {
const channel = client.channels.resolve(snowflake)!;
const channelInfo = [`**Type:** ${BushChannelType[channel.type] ?? ChannelType[channel.type]}`];
- if (channel.isDM()) {
+ if (channel.type === ChannelType.DM) {
channelInfo.push(
`**Recipient:** ${util.discord.escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} (${
channel.recipient?.id ?? '¯\\_(ツ)_/¯'
@@ -55,11 +55,11 @@ export default class SnowflakeCommand extends BushCommand {
`:snowflake: DM with ${util.discord.escapeMarkdown(channel.recipient?.tag ?? '¯\\_(ツ)_/¯')} \`[Channel]\``
);
} else if (
- channel.isCategory() ||
- channel.isNews() ||
- channel.isText() ||
- channel.isVoice() ||
- channel.isStage() ||
+ channel.type === ChannelType.GuildCategory ||
+ channel.type === ChannelType.GuildNews ||
+ channel.type === ChannelType.GuildText ||
+ channel.type === ChannelType.GuildVoice ||
+ channel.type === ChannelType.GuildStageVoice ||
channel.isThread()
) {
channelInfo.push(
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index cb2fc5f..d617756 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -1,22 +1,17 @@
-import {
- BushCommand,
- Time,
- type ArgType,
- type BushGuild,
- type BushGuildMember,
- type BushMessage,
- type BushSlashMessage,
- type BushUser
-} from '#lib';
-import { TeamMemberMembershipState, type APIApplication } from 'discord-api-types/v10';
+import { BushCommand, Time, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import {
ActivityType,
ApplicationCommandOptionType,
ApplicationFlagsBitField,
- ApplicationFlagsString,
EmbedBuilder,
PermissionFlagsBits,
- UserFlags
+ TeamMemberMembershipState,
+ UserFlags,
+ type APIApplication,
+ type ApplicationFlagsString,
+ type Guild,
+ type GuildMember,
+ type User
} from 'discord.js';
export default class UserInfoCommand extends BushCommand {
@@ -45,7 +40,7 @@ export default class UserInfoCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'user'> | ArgType<'snowflake'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { user: OptArgType<'user' | 'snowflake'> }) {
const user =
args.user === null
? message.author
@@ -61,7 +56,7 @@ export default class UserInfoCommand extends BushCommand {
return await message.util.reply({ embeds: [userEmbed] });
}
- public static async makeUserInfoEmbed(user: BushUser, member?: BushGuildMember, guild?: BushGuild | null) {
+ public static async makeUserInfoEmbed(user: User, member?: GuildMember, guild?: Guild | null) {
const emojis = [];
const superUsers = util.getShared('superUsers');
@@ -121,7 +116,7 @@ export default class UserInfoCommand extends BushCommand {
return userEmbed;
}
- public static async generateGeneralInfoField(embed: EmbedBuilder, user: BushUser, title = '» General Information') {
+ public static async generateGeneralInfoField(embed: EmbedBuilder, user: User, title = '» General Information') {
// General Info
const generalInfo = [
`**Mention:** <@${user.id}>`,
@@ -138,11 +133,7 @@ export default class UserInfoCommand extends BushCommand {
embed.addFields([{ name: title, value: generalInfo.join('\n') }]);
}
- public static generateServerInfoField(
- embed: EmbedBuilder,
- member?: BushGuildMember | undefined,
- title = '» Server Information'
- ) {
+ public static generateServerInfoField(embed: EmbedBuilder, member?: GuildMember | undefined, title = '» Server Information') {
if (!member) return;
// Server User Info
@@ -167,7 +158,7 @@ export default class UserInfoCommand extends BushCommand {
if (serverUserInfo.length) embed.addFields([{ name: title, value: serverUserInfo.join('\n') }]);
}
- public static generatePresenceField(embed: EmbedBuilder, member?: BushGuildMember | undefined, title = '» Presence') {
+ public static generatePresenceField(embed: EmbedBuilder, member?: GuildMember | undefined, title = '» Presence') {
if (!member || !member.presence) return;
if (!member.presence.status && !member.presence.clientStatus && !member.presence.activities) return;
@@ -207,7 +198,7 @@ export default class UserInfoCommand extends BushCommand {
});
}
- public static generateRolesField(embed: EmbedBuilder, member?: BushGuildMember | undefined) {
+ public static generateRolesField(embed: EmbedBuilder, member?: GuildMember | undefined) {
if (!member || member.roles.cache.size <= 1) return;
// roles
@@ -227,7 +218,7 @@ export default class UserInfoCommand extends BushCommand {
public static generatePermissionsField(
embed: EmbedBuilder,
- member: BushGuildMember | undefined,
+ member: GuildMember | undefined,
title = '» Important Permissions'
) {
if (!member) return;
@@ -247,7 +238,7 @@ export default class UserInfoCommand extends BushCommand {
if (perms.length) embed.addFields([{ name: title, value: perms.join(' ') }]);
}
- public static async generateBotField(embed: EmbedBuilder, user: BushUser, title = '» Bot Information') {
+ public static async generateBotField(embed: EmbedBuilder, user: User, title = '» Bot Information') {
if (!user.bot) return;
const applicationInfo = (await client.rest.get(`/applications/${user.id}/rpc`).catch(() => null)) as APIApplication | null;
diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts
index f476ac1..040ed4a 100644
--- a/src/commands/leveling/leaderboard.ts
+++ b/src/commands/leveling/leaderboard.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ButtonPaginator, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, Level, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -28,7 +28,7 @@ export default class LeaderboardCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { page: ArgType<'integer'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { page: OptArgType<'integer'> }) {
assert(message.inGuild());
if (!(await message.guild.hasFeature('leveling')))
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts
index 3a9a916..34a839a 100644
--- a/src/commands/leveling/level.ts
+++ b/src/commands/leveling/level.ts
@@ -3,16 +3,14 @@ import {
BushCommand,
CanvasProgressBar,
Level,
- type BushGuild,
- type BushMessage,
- type BushSlashMessage,
- type BushUser,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import { SimplifyNumber } from '@notenoughupdates/simplify-number';
import assert from 'assert';
import canvas from 'canvas';
-import { ApplicationCommandOptionType, Attachment, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, AttachmentBuilder, Guild, PermissionFlagsBits, User } from 'discord.js';
import got from 'got';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
@@ -46,7 +44,7 @@ export default class LevelCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user: OptArgType<'user'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { user: OptArgType<'user'> }) {
assert(message.inGuild());
if (!(await message.guild.hasFeature('leveling')))
@@ -60,7 +58,7 @@ export default class LevelCommand extends BushCommand {
const user = args.user ?? message.author;
try {
return await message.util.reply({
- files: [new Attachment(await this.getImage(user, message.guild), 'level.png')]
+ files: [new AttachmentBuilder(await this.getImage(user, message.guild), { name: 'level.png' })]
});
} catch (e) {
if (e instanceof Error && e.message === 'User does not have a level') {
@@ -72,7 +70,7 @@ export default class LevelCommand extends BushCommand {
}
}
- private async getImage(user: BushUser, guild: BushGuild): Promise<Buffer> {
+ private async getImage(user: User, guild: Guild): Promise<Buffer> {
const guildRows = await Level.findAll({ where: { guild: guild.id } });
const rank = guildRows.sort((a, b) => b.xp - a.xp);
const userLevelRow = guildRows.find((a) => a.user === user.id);
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts
index 9fe7dd0..afa4ab6 100644
--- a/src/commands/leveling/levelRoles.ts
+++ b/src/commands/leveling/levelRoles.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -39,7 +39,7 @@ export default class LevelRolesCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { level: ArgType<'integer'>; role: OptArgType<'role'> }
) {
assert(message.inGuild());
diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts
index ac7df57..8abdb57 100644
--- a/src/commands/leveling/setLevel.ts
+++ b/src/commands/leveling/setLevel.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -36,7 +36,7 @@ export default class SetLevelCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{ user, level }: { user: ArgType<'user'>; level: ArgType<'integer'> }
) {
assert(message.inGuild());
diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts
index 1f7c981..60e0b94 100644
--- a/src/commands/leveling/setXp.ts
+++ b/src/commands/leveling/setXp.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -37,7 +37,7 @@ export default class SetXpCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{ user, xp }: { user: ArgType<'user'>; xp: ArgType<'abbreviatedNumber'> }
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts
index e751493..92b4242 100644
--- a/src/commands/moderation/_activePunishments.ts
+++ b/src/commands/moderation/_activePunishments.ts
@@ -1,79 +1,78 @@
-/* import { BushCommand, ModLog, ModLogModel, type BushGuildMember, type BushMessage, type BushSlashMessage } from '#lib';
-import { FindOptions, Op } from 'sequelize';
-import { Permissions } from 'discord.js';
+// import { BushCommand, ModLog, ModLogModel, OptArgType, type CommandMessage, type SlashMessage } from '#lib';
+// import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
+// import { FindOptions, Op } from 'sequelize';
-const punishmentTypes = ['ban', 'kick', 'mute', 'warn', 'role'] as const;
+// const punishmentTypes = ['ban', 'kick', 'mute', 'warn', 'role'] as const;
-export default class ActivePunishmentsCommand extends BushCommand {
- public constructor() {
- super('activePunishments', {
- aliases: ['active-punishments', 'ap'],
- category: 'moderation',
- description: 'Gets a list of all the active punishment in the server.',
- usage: [`active-punishments [--moderator <user>] [--type <${punishmentTypes.map((v) => `'${v}'`).join('|')}>]`],
- examples: ['active-punishments'],
- args: [
- {
- id: 'moderator',
- description: 'Only show active punishments by this moderator.',
- type: 'user',
- match: 'option',
- prompt: 'Only show active punishments from what user?',
- optional: true,
- slashType: ApplicationCommandOptionType.User,
- slashResolve: 'Member'
- },
- {
- id: 'type',
- description: 'Only show active punishments of this type.',
- customType: [...punishmentTypes],
- readableType: punishmentTypes.map((v) => `'${v}'`).join('|'),
- match: 'option',
- optional: true,
- slashType: ApplicationCommandOptionType.String,
- choices: punishmentTypes.map((v) => ({ name: v, value: v }))
- }
- ],
- slash: true,
- channel: 'guild',
- hidden: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
- });
- }
+// export default class ActivePunishmentsCommand extends BushCommand {
+// public constructor() {
+// super('activePunishments', {
+// aliases: ['active-punishments', 'ap'],
+// category: 'moderation',
+// description: 'Gets a list of all the active punishment in the server.',
+// usage: [`active-punishments [--moderator <user>] [--type <${punishmentTypes.map((v) => `'${v}'`).join('|')}>]`],
+// examples: ['active-punishments'],
+// args: [
+// {
+// id: 'moderator',
+// description: 'Only show active punishments by this moderator.',
+// type: 'user',
+// match: 'option',
+// prompt: 'Only show active punishments from what user?',
+// optional: true,
+// slashType: ApplicationCommandOptionType.User,
+// slashResolve: 'Member'
+// },
+// {
+// id: 'type',
+// description: 'Only show active punishments of this type.',
+// customType: [...punishmentTypes],
+// readableType: punishmentTypes.map((v) => `'${v}'`).join('|'),
+// match: 'option',
+// optional: true,
+// slashType: ApplicationCommandOptionType.String,
+// choices: punishmentTypes.map((v) => ({ name: v, value: v }))
+// }
+// ],
+// slash: true,
+// channel: 'guild',
+// hidden: true,
+// clientPermissions: (m) => util.clientSendAndPermCheck(m),
+// userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
+// });
+// }
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { moderator?: BushGuildMember; type: typeof punishmentTypes[number] }
- ) {
- const where: FindOptions<ModLogModel>['where'] = { guild: message.guild!.id };
- if (args.moderator?.id) where.user = args.moderator.id;
- if (args.type) {
- switch (args.type) {
- case 'ban':
- where.type = { [Op.or]: ['PERM_BAN', 'TEMP_BAN', 'UNBAN'] };
- break;
- case 'kick':
- where.type = { [Op.or]: ['KICK'] };
- break;
- case 'mute':
- where.type = { [Op.or]: ['PERM_MUTE', 'TEMP_MUTE', 'UNMUTE'] };
- break;
- case 'warn':
- where.type = { [Op.or]: ['WARN'] };
- break;
- case 'role':
- where.type = { [Op.or]: ['PERM_PUNISHMENT_ROLE', 'TEMP_PUNISHMENT_ROLE', 'REMOVE_PUNISHMENT_ROLE'] };
- break;
- default:
- return message.util.reply(`${util.emojis.error} You supplied an invalid case type to filter by.`);
- }
- }
+// public override async exec(
+// message: CommandMessage | SlashMessage,
+// args: { moderator: OptArgType<'user' | 'member'>; type: typeof punishmentTypes[number] }
+// ) {
+// const where: FindOptions<ModLogModel>['where'] = { guild: message.guild!.id };
+// if (args.moderator?.id) where.user = args.moderator.id;
+// if (args.type) {
+// switch (args.type) {
+// case 'ban':
+// where.type = { [Op.or]: ['PERM_BAN', 'TEMP_BAN', 'UNBAN'] };
+// break;
+// case 'kick':
+// where.type = { [Op.or]: ['KICK'] };
+// break;
+// case 'mute':
+// where.type = { [Op.or]: ['PERM_MUTE', 'TEMP_MUTE', 'UNMUTE'] };
+// break;
+// case 'warn':
+// where.type = { [Op.or]: ['WARN'] };
+// break;
+// case 'role':
+// where.type = { [Op.or]: ['PERM_PUNISHMENT_ROLE', 'TEMP_PUNISHMENT_ROLE', 'REMOVE_PUNISHMENT_ROLE'] };
+// break;
+// default:
+// return message.util.reply(`${util.emojis.error} You supplied an invalid case type to filter by.`);
+// }
+// }
- const logs = await ModLog.findAll({
- where,
- order: [['createdAt', 'ASC']]
- });
- }
-}
- */
+// const logs = await ModLog.findAll({
+// where,
+// order: [['createdAt', 'ASC']]
+// });
+// }
+// }
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 77951c3..f4bd52b 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -4,9 +4,9 @@ import {
BushCommand,
Moderation,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -71,12 +71,12 @@ export default class BanCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- user: ArgType<'user'> | ArgType<'snowflake'>;
+ user: ArgType<'user' | 'snowflake'>;
reason_and_duration: OptArgType<'contentWithDuration'> | string;
days: OptArgType<'integer'>;
- force: boolean;
+ force: ArgType<'flag'>;
}
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts
index 722f08b..16beb6f 100644
--- a/src/commands/moderation/block.ts
+++ b/src/commands/moderation/block.ts
@@ -4,9 +4,9 @@ import {
BushCommand,
Moderation,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -58,15 +58,16 @@ export default class BlockCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
user: ArgType<'user'>;
reason_and_duration: OptArgType<'contentWithDuration'> | string;
- force?: ArgType<'boolean'>;
+ force: ArgType<'flag'>;
}
) {
assert(message.inGuild());
assert(message.member);
+ assert(message.channel);
if (!message.channel.isTextBased())
return message.util.send(`${util.emojis.error} This command can only be used in text based channels.`);
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index 9b63189..f1fac0d 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -1,8 +1,7 @@
-import { BushCommand, ModLog, OptArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ModLog, OptArgType, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ArgumentGeneratorReturn } from 'discord-akairo';
-import { Argument, ArgumentTypeCasterReturn } from 'discord-akairo/dist/src/struct/commands/arguments/Argument.js';
-import { ApplicationCommandOptionType, PermissionFlagsBits, User } from 'discord.js';
+import { Argument, ArgumentGeneratorReturn } from 'discord-akairo';
+import { ApplicationCommandOptionType, PermissionFlagsBits, type Message } from 'discord.js';
export default class EvidenceCommand extends BushCommand {
public constructor() {
@@ -48,8 +47,8 @@ export default class EvidenceCommand extends BushCommand {
});
}
- public override *args(message: BushMessage): ArgumentGeneratorReturn {
- const target: ArgumentTypeCasterReturn<'string'> | ArgumentTypeCasterReturn<'snowflake'> = yield {
+ public override *args(message: CommandMessage): ArgumentGeneratorReturn {
+ const target: ArgType<'string' | 'snowflake'> = yield {
id: 'target',
type: Argument.union('snowflake', 'string'),
prompt: {
@@ -59,7 +58,7 @@ export default class EvidenceCommand extends BushCommand {
}
};
- const evidence: ArgumentTypeCasterReturn<'string'> = yield {
+ const evidence: OptArgType<'string'> = yield {
id: 'evidence',
type: 'string',
match: 'restContent',
@@ -74,13 +73,18 @@ export default class EvidenceCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{
case_id: caseID,
user,
target: messageCommandTarget,
evidence
- }: { case_id?: string; user?: User; target: string | User; evidence: OptArgType<'string'> }
+ }: {
+ case_id: OptArgType<'string'>;
+ user: OptArgType<'user'>;
+ target: ArgType<'string' | 'snowflake'>;
+ evidence: OptArgType<'string'>;
+ }
) {
assert(message.inGuild());
@@ -88,22 +92,13 @@ export default class EvidenceCommand extends BushCommand {
return message.util.send(`${util.emojis.error} You must provide either a user or a case ID.`);
const entry = messageCommandTarget
- ? typeof messageCommandTarget == 'string'
- ? await ModLog.findByPk(messageCommandTarget)
- : await ModLog.findOne({
- where: {
- user: messageCommandTarget.id
- },
- order: [['createdAt', 'DESC']]
- })
+ ? util.consts.regex.snowflake.test(messageCommandTarget)
+ ? await ModLog.findOne({ where: { user: messageCommandTarget }, order: [['createdAt', 'DESC']] })
+ : await ModLog.findByPk(messageCommandTarget)
: caseID
? await ModLog.findByPk(caseID)
- : await ModLog.findOne({
- where: {
- user: user!.id
- },
- order: [['createdAt', 'DESC']]
- });
+ : await ModLog.findOne({ where: { user: user!.id }, order: [['createdAt', 'DESC']] });
+
if (!entry || entry.pseudo) return message.util.send(`${util.emojis.error} Invalid modlog entry.`);
if (entry.guild !== message.guild.id) return message.util.reply(`${util.emojis.error} This modlog is from another server.`);
@@ -122,8 +117,8 @@ export default class EvidenceCommand extends BushCommand {
);
}
- public static getEvidence(message: BushMessage | BushSlashMessage, evidenceArg: OptArgType<'string'>): null | string {
- if (evidenceArg && (message as BushMessage).attachments?.size) {
+ public static getEvidence(message: CommandMessage | SlashMessage, evidenceArg: OptArgType<'string'>): null | string {
+ if (evidenceArg && (message as Message).attachments?.size) {
void message.util.reply(`${util.emojis.error} Please either attach an image or a reason not both.`);
return null;
}
@@ -131,7 +126,7 @@ export default class EvidenceCommand extends BushCommand {
const _evidence = evidenceArg
? evidenceArg
: !message.util.isSlash
- ? (message as BushMessage).attachments.first()?.url
+ ? (message as Message).attachments.first()?.url
: undefined;
if (!_evidence) {
void message.util.reply(`${util.emojis.error} You must provide evidence for this modlog.`);
diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts
index 8cec66e..fc5baf4 100644
--- a/src/commands/moderation/hideCase.ts
+++ b/src/commands/moderation/hideCase.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ModLog, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -27,7 +27,7 @@ export default class HideCaseCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, { case_id: caseID }: { case_id: string }) {
+ public override async exec(message: CommandMessage | SlashMessage, { case_id: caseID }: { case_id: string }) {
assert(message.inGuild());
const entry = await ModLog.findByPk(caseID);
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index 26098b5..a9a0336 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -4,8 +4,9 @@ import {
kickResponse,
Moderation,
type ArgType,
- type BushMessage,
- type BushSlashMessage
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -55,8 +56,8 @@ export default class KickCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { user, reason, force }: { user: ArgType<'user'>; reason: ArgType<'string'>; force: boolean }
+ message: CommandMessage | SlashMessage,
+ { user, reason, force }: { user: ArgType<'user'>; reason: OptArgType<'string'>; force: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts
index d10a5d4..7d8211c 100644
--- a/src/commands/moderation/lockdown.ts
+++ b/src/commands/moderation/lockdown.ts
@@ -3,9 +3,9 @@ import {
BushCommand,
ConfirmationPrompt,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import {
@@ -72,22 +72,22 @@ export default class LockdownCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'>;
+ channel: OptArgType<'textChannel' | 'newsChannel' | 'threadChannel' | 'voiceChannel'>;
reason: OptArgType<'string'>;
- all: ArgType<'boolean'>;
+ all: ArgType<'flag'>;
}
) {
return await LockdownCommand.lockdownOrUnlockdown(message, args, 'lockdown');
}
public static async lockdownOrUnlockdown(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'> | OptArgType<'voiceChannel'>;
+ channel: OptArgType<'textChannel' | 'newsChannel' | 'threadChannel' | 'voiceChannel'>;
reason: OptArgType<'string'>;
- all: ArgType<'boolean'>;
+ all: ArgType<'flag'>;
},
action: 'lockdown' | 'unlockdown'
) {
diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts
index f1d85ed..a25c64f 100644
--- a/src/commands/moderation/massBan.ts
+++ b/src/commands/moderation/massBan.ts
@@ -3,9 +3,9 @@ import {
banResponse,
BushCommand,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, Collection, PermissionFlagsBits } from 'discord.js';
@@ -61,7 +61,7 @@ export default class MassBanCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { users: ArgType<'string'>; reason: OptArgType<'string'>; days: OptArgType<'integer'> }
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/massEvidence.ts b/src/commands/moderation/massEvidence.ts
index 67f5a25..468d43c 100644
--- a/src/commands/moderation/massEvidence.ts
+++ b/src/commands/moderation/massEvidence.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ModLog, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { BushCommand, ModLog, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
import { EvidenceCommand } from '../index.js';
@@ -44,7 +44,7 @@ export default class MassEvidenceCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { users: ArgType<'string'>; evidence: OptArgType<'string'> }
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 66368f9..71ed975 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ButtonPaginator, ModLog, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, ModLog, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits, User } from 'discord.js';
@@ -40,8 +40,8 @@ export default class ModlogCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { search, hidden }: { search: ArgType<'user'> | string; hidden: boolean }
+ message: CommandMessage | SlashMessage,
+ { search, hidden }: { search: ArgType<'user'> | string; hidden: ArgType<'flag'> }
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index d846817..a665670 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -4,9 +4,9 @@ import {
Moderation,
muteResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -57,11 +57,11 @@ export default class MuteCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
user: ArgType<'user'>;
reason_and_duration: OptArgType<'contentWithDuration'> | string;
- force?: ArgType<'boolean'>;
+ force: ArgType<'flag'>;
}
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
index 799cf36..1652f6f 100644
--- a/src/commands/moderation/purge.ts
+++ b/src/commands/moderation/purge.ts
@@ -1,6 +1,6 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, OptArgType, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, Collection, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, Collection, PermissionFlagsBits, type Message } from 'discord.js';
export default class PurgeCommand extends BushCommand {
public constructor() {
@@ -50,14 +50,14 @@ export default class PurgeCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { amount: number; bot: boolean; user: ArgType<'user'> }
+ message: CommandMessage | SlashMessage,
+ args: { amount: ArgType<'integer'>; bot: ArgType<'flag'>; user: OptArgType<'user'> }
) {
assert(message.inGuild());
if (args.amount > 100 || args.amount < 1) return message.util.reply(`${util.emojis.error} `);
- const messageFilter = (filterMessage: BushMessage): boolean => {
+ const messageFilter = (filterMessage: Message): boolean => {
const shouldFilter: boolean[] = [];
if (args.bot) shouldFilter.push(filterMessage.author.bot);
if (args.user) shouldFilter.push(filterMessage.author.id === args.user.id);
@@ -65,16 +65,16 @@ export default class PurgeCommand extends BushCommand {
return shouldFilter.filter((bool) => bool === false).length === 0 && filterMessage.id !== message.id;
};
const messages = new Collection(
- (await message.channel.messages.fetch({ limit: 100, before: message.id }))
+ (await message.channel!.messages.fetch({ limit: 100, before: message.id }))
.filter((message) => messageFilter(message))
.first(args.amount)
.map((m) => [m.id, m] as const)
);
- const purged = await message.channel.bulkDelete(messages, true).catch(() => null);
+ const purged = await message.channel!.bulkDelete(messages, true).catch(() => null);
if (!purged) return message.util.reply(`${util.emojis.error} Failed to purge messages.`).catch(() => null);
else {
- client.emit('bushPurge', message.author, message.guild, message.channel, messages);
+ client.emit('bushPurge', message.author, message.guild, message.channel!, messages);
await message.util.send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`);
/* .then(async (purgeMessage) => {
if (!message.util.isSlashMessage(message)) {
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index bc24db0..4359c5b 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, Message, PermissionFlagsBits } from 'discord.js';
@@ -40,8 +40,8 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { message: ArgType<'guildMessage'> | string; emoji: ArgType<'emoji'> | ArgType<'snowflake'> }
+ message: CommandMessage | SlashMessage,
+ args: { message: ArgType<'guildMessage'> | string; emoji: ArgType<'emoji' | 'snowflake'> }
) {
assert(message.channel);
const resolvedMessage = args.message instanceof Message ? args.message : await message.channel.messages.fetch(args.message);
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index a87b2bf..b9e1490 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -4,10 +4,11 @@ import {
BushCommand,
removeRoleResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
+import assert from 'assert';
import { type ArgumentGeneratorReturn } from 'discord-akairo';
import { ApplicationCommandOptionType, PermissionFlagsBits, type Snowflake } from 'discord.js';
@@ -59,6 +60,7 @@ export default class RoleCommand extends BushCommand {
],
slash: true,
channel: 'guild',
+ flags: ['--force'],
typing: true,
clientPermissions: (m) =>
util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles, PermissionFlagsBits.EmbedLinks], true),
@@ -66,7 +68,7 @@ export default class RoleCommand extends BushCommand {
});
}
- public override *args(message: BushMessage): ArgumentGeneratorReturn {
+ public override *args(message: CommandMessage): ArgumentGeneratorReturn {
const action = (['rr'] as const).includes(message.util.parsed?.alias ?? '')
? 'remove'
: (['ar', 'ra'] as const).includes(message.util.parsed?.alias ?? '')
@@ -118,15 +120,16 @@ export default class RoleCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
action: 'add' | 'remove';
member: ArgType<'member'>;
role: ArgType<'role'>;
- duration?: OptArgType<'duration'>;
- force?: boolean;
+ duration: OptArgType<'duration'>;
+ force?: ArgType<'flag'>;
}
) {
+ assert(message.inGuild());
if (!args.role) return await message.util.reply(`${util.emojis.error} You must specify a role.`);
args.duration ??= 0;
if (
diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts
index 6d93ede..e657b76 100644
--- a/src/commands/moderation/slowmode.ts
+++ b/src/commands/moderation/slowmode.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { Argument } from 'discord-akairo';
import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js';
@@ -42,17 +42,22 @@ export default class SlowmodeCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- length: ArgType<'duration'> | ArgType<'durationSeconds'> | 'off' | 'none' | 'disable' | null;
- channel: ArgType<'channel'>;
+ length: OptArgType<'duration' | 'durationSeconds'> | 'off' | 'none' | 'disable';
+ channel: OptArgType<'channel'>;
}
) {
assert(message.inGuild());
- args.channel ??= message.channel;
+ args.channel ??= message.channel!;
- if (!args.channel.isTextBased() || args.channel.isNews())
+ if (
+ args.channel.type !== ChannelType.GuildText &&
+ args.channel.type !== ChannelType.GuildNews &&
+ args.channel.type !== ChannelType.GuildVoice &&
+ !args.channel.isThread()
+ )
return await message.util.reply(`${util.emojis.error} <#${args.channel.id}> is not a text or thread channel.`);
args.length =
diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts
index b8fb78f..ed3562d 100644
--- a/src/commands/moderation/timeout.ts
+++ b/src/commands/moderation/timeout.ts
@@ -4,8 +4,8 @@ import {
Moderation,
timeoutResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage
+ type CommandMessage,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -55,8 +55,8 @@ export default class TimeoutCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { user: ArgType<'user'>; reason_and_duration: ArgType<'contentWithDuration'> | string; force?: ArgType<'boolean'> }
+ message: CommandMessage | SlashMessage,
+ args: { user: ArgType<'user'>; reason_and_duration: ArgType<'contentWithDuration'> | string; force?: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index e6ac6d0..d7549ab 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -3,9 +3,9 @@ import {
BushCommand,
unbanResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -46,8 +46,8 @@ export default class UnbanCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { user, reason }: { user: ArgType<'user'>; reason: OptArgType<'string'> }
+ message: CommandMessage | SlashMessage,
+ { user, reason }: { user: ArgType<'user' | 'globalUser'>; reason: OptArgType<'string'> }
) {
assert(message.inGuild());
diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts
index 22c9949..886d546 100644
--- a/src/commands/moderation/unblock.ts
+++ b/src/commands/moderation/unblock.ts
@@ -4,9 +4,9 @@ import {
Moderation,
unblockResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -57,11 +57,12 @@ export default class UnblockCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'boolean'> }
+ message: CommandMessage | SlashMessage,
+ args: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
+ assert(message.channel);
if (!message.channel.isTextBased())
return message.util.send(`${util.emojis.error} This command can only be used in text based channels.`);
diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts
index 253ce37..dbcd429 100644
--- a/src/commands/moderation/unlockdown.ts
+++ b/src/commands/moderation/unlockdown.ts
@@ -1,5 +1,5 @@
import { LockdownCommand } from '#commands';
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js';
export default class UnlockdownCommand extends BushCommand {
@@ -14,7 +14,7 @@ export default class UnlockdownCommand extends BushCommand {
{
id: 'channel',
description: 'Specify a different channel to unlockdown instead of the one you trigger the command in.',
- type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'),
+ type: util.arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'),
prompt: 'What channel would you like to unlockdown?',
slashType: ApplicationCommandOptionType.Channel,
channelTypes: [
@@ -22,7 +22,8 @@ export default class UnlockdownCommand extends BushCommand {
ChannelType.GuildNews,
ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread,
- ChannelType.GuildPrivateThread
+ ChannelType.GuildPrivateThread,
+ ChannelType.GuildVoice
],
optional: true
},
@@ -53,11 +54,11 @@ export default class UnlockdownCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'>;
+ channel: OptArgType<'textChannel' | 'newsChannel' | 'threadChannel' | 'voiceChannel'>;
reason: OptArgType<'string'>;
- all: ArgType<'boolean'>;
+ all: ArgType<'flag'>;
}
) {
return await LockdownCommand.lockdownOrUnlockdown(message, args, 'unlockdown');
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 094cadd..202e341 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -4,10 +4,9 @@ import {
Moderation,
unmuteResponse,
type ArgType,
- type BushGuildMember,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -58,14 +57,14 @@ export default class UnmuteCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { user, reason, force = false }: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: boolean }
+ message: CommandMessage | SlashMessage,
+ { user, reason, force = false }: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
const error = util.emojis.error;
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
+ const member = message.guild.members.cache.get(user.id)!;
const useForce = force && message.author.isOwner();
const canModerateResponse = await Moderation.permissionCheck(message.member, member, 'unmute', true, useForce);
diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts
index cbaf7d1..7622f29 100644
--- a/src/commands/moderation/untimeout.ts
+++ b/src/commands/moderation/untimeout.ts
@@ -4,9 +4,9 @@ import {
Moderation,
removeTimeoutResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -57,8 +57,8 @@ export default class UntimeoutCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'boolean'> }
+ message: CommandMessage | SlashMessage,
+ args: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 87baf4a..b3bf965 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -4,9 +4,9 @@ import {
Moderation,
warnResponse,
type ArgType,
- type BushMessage,
- type BushSlashMessage,
- type OptArgType
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -56,8 +56,8 @@ export default class WarnCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { user, reason, force = false }: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: boolean }
+ message: CommandMessage | SlashMessage,
+ { user, reason, force = false }: { user: ArgType<'user'>; reason: OptArgType<'string'>; force?: ArgType<'flag'> }
) {
assert(message.inGuild());
assert(message.member);
diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts
index dd210e2..5f15d9e 100644
--- a/src/commands/moulberry-bush/capePermissions.ts
+++ b/src/commands/moulberry-bush/capePermissions.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import got from 'got';
@@ -27,7 +27,7 @@ export default class CapePermissionsCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { ign: ArgType<'string'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { ign: ArgType<'string'> }) {
let capePerms: CapePerms | null, uuid: string;
try {
uuid = await util.mcUUID(args.ign);
diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts
index 3f273c1..6bf7854 100644
--- a/src/commands/moulberry-bush/capes.ts
+++ b/src/commands/moulberry-bush/capes.ts
@@ -1,7 +1,14 @@
-import { AllowedMentions, BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptArgType } from '#lib';
+import {
+ AllowedMentions,
+ BushCommand,
+ ButtonPaginator,
+ DeleteButton,
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
-import { APIEmbed } from 'discord-api-types/v10';
-import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, PermissionFlagsBits, type APIEmbed, type AutocompleteInteraction } from 'discord.js';
import Fuse from 'fuse.js';
import got from 'got';
@@ -34,7 +41,7 @@ export default class CapesCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage, args: { cape: OptArgType<'string'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { cape: OptArgType<'string'> }) {
const { tree: neuFileTree }: GithubTreeApi = await got
.get('https://api.github.com/repos/Moulberry/NotEnoughUpdates/git/trees/master?recursive=1')
.json();
diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts
index dd305c6..23a6a20 100644
--- a/src/commands/moulberry-bush/giveawayPing.ts
+++ b/src/commands/moulberry-bush/giveawayPing.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage } from '#lib';
+import { AllowedMentions, BushCommand, type CommandMessage } from '#lib';
import { PermissionFlagsBits } from 'discord.js';
export default class GiveawayPingCommand extends BushCommand {
@@ -28,7 +28,7 @@ export default class GiveawayPingCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage) {
+ public override async exec(message: CommandMessage) {
if (!message.member!.permissions.has(PermissionFlagsBits.ManageGuild) && !message.member!.user.isOwner())
await message.util.reply(`${util.emojis.error} You are missing the **ManageGuild** permission.`);
diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts
index a5d2c27..f07511a 100644
--- a/src/commands/moulberry-bush/moulHammer.ts
+++ b/src/commands/moulberry-bush/moulHammer.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -29,10 +29,10 @@ export default class MoulHammerCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, { user }: { user: ArgType<'user'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, { user }: { user: ArgType<'user'> }) {
assert(message.inGuild());
- if (message.channel.permissionsFor(message.guild.members.me!).has('ManageMessages')) await message.delete().catch(() => {});
+ if (message.channel?.permissionsFor(message.guild.members.me!).has('ManageMessages')) await message.delete().catch(() => {});
const embed = new EmbedBuilder()
.setTitle('L')
diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts
index 0561e13..29eee76 100644
--- a/src/commands/moulberry-bush/report.ts
+++ b/src/commands/moulberry-bush/report.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage } from '#lib';
import { stripIndent } from '#tags';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
@@ -38,7 +38,7 @@ export default class ReportCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage, { member, evidence }: { member: ArgType<'member'>; evidence: string }) {
+ public override async exec(message: CommandMessage, { member, evidence }: { member: ArgType<'member'>; evidence: string }) {
assert(message.inGuild());
if (!(await message.guild.hasFeature('reporting')))
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index cd9994f..17f1bd8 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, BushSlashMessage, type BushMessage, type OptArgType } from '#lib';
+import { AllowedMentions, BushCommand, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import { stripIndent } from '../../lib/common/tags.js';
@@ -99,7 +99,7 @@ export default class RuleCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
{ rule, user }: { rule: OptArgType<'integer'>; user: OptArgType<'user'> }
) {
const rulesEmbed = new EmbedBuilder()
diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts
index c0df828..ad3903a 100644
--- a/src/commands/moulberry-bush/serverStatus.ts
+++ b/src/commands/moulberry-bush/serverStatus.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage } from '#lib';
+import { BushCommand, type CommandMessage } from '#lib';
import assert from 'assert';
import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import got from 'got';
@@ -19,7 +19,7 @@ export default class ServerStatusCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage) {
+ public override async exec(message: CommandMessage) {
const msgEmbed = new EmbedBuilder()
.setTitle('Server status')
.setDescription(`Checking server:\n${util.emojis.loading}`)
diff --git a/src/commands/utilities/_poll.ts b/src/commands/utilities/_poll.ts
index 81bb5fc..a843561 100644
--- a/src/commands/utilities/_poll.ts
+++ b/src/commands/utilities/_poll.ts
@@ -1,81 +1,80 @@
-/* import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { ApplicationCommandOptionType, ComponentType } from 'discord.js';
+// import { BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+// import { ApplicationCommandOptionType, ComponentType } from 'discord.js';
-export default class PollCommand extends BushCommand {
- public constructor() {
- super('poll', {
- aliases: ['poll', 'quick-poll'],
- category: 'utilities',
- description: 'Allows you to create a poll that other users can vote on. Separate options with "," or "|".',
- usage: ['poll options'],
- examples: ['poll 1 2'],
- args: [
- {
- id: 'question',
- description: 'The question to be answered by a poll.',
- type: 'string',
- prompt: 'What question would you like to ask?',
- retry: '{error} Choose a question.',
- slashType: ApplicationCommandOptionType.String,
- only: 'slash'
- },
- {
- id: 'options',
- description: 'The options to include in the poll. Separate options with "," or "|".',
- type: 'string',
- prompt: 'What options you want to include in the poll? Separate options with "," or "|".',
- retry: '{error} Choose options for the poll. Separate options with "," or "|".',
- slashType: ApplicationCommandOptionType.String
- }
- ],
- slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: []
- });
- }
+// export default class PollCommand extends BushCommand {
+// public constructor() {
+// super('poll', {
+// aliases: ['poll', 'quick-poll'],
+// category: 'utilities',
+// description: 'Allows you to create a poll that other users can vote on. Separate options with "," or "|".',
+// usage: ['poll options'],
+// examples: ['poll 1 2'],
+// args: [
+// {
+// id: 'question',
+// description: 'The question to be answered by a poll.',
+// type: 'string',
+// prompt: 'What question would you like to ask?',
+// retry: '{error} Choose a question.',
+// slashType: ApplicationCommandOptionType.String,
+// only: 'slash'
+// },
+// {
+// id: 'options',
+// description: 'The options to include in the poll. Separate options with "," or "|".',
+// type: 'string',
+// prompt: 'What options you want to include in the poll? Separate options with "," or "|".',
+// retry: '{error} Choose options for the poll. Separate options with "," or "|".',
+// slashType: ApplicationCommandOptionType.String
+// }
+// ],
+// slash: true,
+// clientPermissions: (m) => util.clientSendAndPermCheck(m),
+// userPermissions: []
+// });
+// }
- public override async exec(message: BushMessage | BushSlashMessage, args: { question?: string; options: ArgType<'string'> }) {
- const { question, options } = this.parseArgs(message, args);
- if (!question || !options.length) return;
+// public override async exec(message: CommandMessage | SlashMessage, args: { question?: string; options: ArgType<'string'> }) {
+// const { question, options } = this.parseArgs(message, args);
+// if (!question || !options.length) return;
- if (question.length > 256) return await message.util.reply(`${util.emojis.error} Question must be 256 characters or less.`);
- if (options.length > 10) return await message.util.reply(`${util.emojis.error} You can only have upto 10 options.`);
+// if (question.length > 256) return await message.util.reply(`${util.emojis.error} Question must be 256 characters or less.`);
+// if (options.length > 10) return await message.util.reply(`${util.emojis.error} You can only have upto 10 options.`);
- return message.util.send({
- embeds: [
- {
- author: { name: `asked by: ${message.author.tag}`, icon_url: message.author.displayAvatarURL() || undefined },
- title: question
- }
- ],
- components: [
- {
- type: ComponentType.ActionRow,
- components: []
- }
- ]
- });
- }
+// return message.util.send({
+// embeds: [
+// {
+// author: { name: `asked by: ${message.author.tag}`, icon_url: message.author.displayAvatarURL() || undefined },
+// title: question
+// }
+// ],
+// components: [
+// {
+// type: ComponentType.ActionRow,
+// components: []
+// }
+// ]
+// });
+// }
- private parseArgs(
- message: BushMessage | BushSlashMessage,
- args: { question?: string; options: ArgType<'string'> }
- ): { question: string; options: string[] } {
- const split = args.options.split(/[,|]/).filter((s) => s.trim().length > 0);
- if (message.util.isSlash) {
- if (split.length < 2) {
- void message.util.reply(`${util.emojis.error} You must provide at least two options.`);
- return { question: '', options: [] };
- }
- return { question: args.question!, options: split };
- } else {
- if (split.length < 3) {
- void message.util.reply(`${util.emojis.error} You must provide a question and at least two options.`);
- return { question: '', options: [] };
- }
+// private parseArgs(
+// message: CommandMessage | SlashMessage,
+// args: { question?: string; options: ArgType<'string'> }
+// ): { question: string; options: string[] } {
+// const split = args.options.split(/[,|]/).filter((s) => s.trim().length > 0);
+// if (message.util.isSlash) {
+// if (split.length < 2) {
+// void message.util.reply(`${util.emojis.error} You must provide at least two options.`);
+// return { question: '', options: [] };
+// }
+// return { question: args.question!, options: split };
+// } else {
+// if (split.length < 3) {
+// void message.util.reply(`${util.emojis.error} You must provide a question and at least two options.`);
+// return { question: '', options: [] };
+// }
- return { question: split[0], options: split.slice(1) };
- }
- }
-}
- */
+// return { question: split[0], options: split.slice(1) };
+// }
+// }
+// }
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 230cc81..14cc5a0 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushArgumentTypeCaster, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, type ArgType, type BushArgumentTypeCaster, type CommandMessage, type SlashMessage } from '#lib';
import { type ArgumentGeneratorReturn, type ArgumentTypeCaster } from 'discord-akairo';
import { ApplicationCommandOptionType, ChannelType, type DiscordAPIError, type Snowflake } from 'discord.js';
@@ -66,7 +66,7 @@ function map(phase: string): Activity | null {
return null;
}
-const activityTypeCaster: BushArgumentTypeCaster<Snowflake | null> = (message: BushMessage, phrase: string) => {
+const activityTypeCaster: BushArgumentTypeCaster<Snowflake | null> = (message: CommandMessage, phrase: string) => {
const parsedPhrase = phrase ?? message.util.parsed?.alias !== 'activity' ? message.util.parsed?.alias : undefined;
if (!parsedPhrase) return null;
const mappedPhrase = map(parsedPhrase)?.id;
@@ -120,7 +120,7 @@ export default class ActivityCommand extends BushCommand {
});
}
- public override *args(message: BushMessage): ArgumentGeneratorReturn {
+ public override *args(message: CommandMessage): ArgumentGeneratorReturn {
const channel: ArgType<'voiceChannel'> = yield {
id: 'channel',
description: 'The channel to create the activity in.',
@@ -151,11 +151,12 @@ export default class ActivityCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: { channel: ArgType<'voiceChannel'>; activity: string }
) {
const channel = typeof args.channel === 'string' ? message.guild?.channels.cache.get(args.channel) : args.channel;
- if (!channel || !channel.isVoice()) return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`);
+ if (channel?.type !== ChannelType.GuildVoice)
+ return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`);
const target_application_id = message.util.isSlashMessage(message)
? args.activity
diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts
index e17ef76..a318a79 100644
--- a/src/commands/utilities/calculator.ts
+++ b/src/commands/utilities/calculator.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js';
import { evaluate } from 'mathjs';
@@ -30,7 +30,7 @@ export default class CalculatorCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { expression: string }) {
const decodedEmbed = new EmbedBuilder().addFields([
{
name: '📥 Input',
diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts
index 7cb0e83..8c82fcc 100644
--- a/src/commands/utilities/decode.ts
+++ b/src/commands/utilities/decode.ts
@@ -1,5 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage } from '#lib';
-import { type AkairoMessage } from 'discord-akairo';
+import { AllowedMentions, BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js';
const encodingTypesArray = ['ascii', 'utf8', 'utf-8', 'utf16le', 'ucs2', 'ucs-2', 'base64', 'latin1', 'binary', 'hex'];
@@ -49,7 +48,7 @@ export default class DecodeCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | AkairoMessage,
+ message: CommandMessage | SlashMessage,
{ from, to, data }: { from: BufferEncoding; to: BufferEncoding; data: string }
) {
const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias ?? 'decoded');
diff --git a/src/commands/utilities/hash.ts b/src/commands/utilities/hash.ts
index 7cc59f3..f47c388 100644
--- a/src/commands/utilities/hash.ts
+++ b/src/commands/utilities/hash.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage } from '#lib';
+import { BushCommand, type CommandMessage } from '#lib';
import assert from 'assert';
import crypto from 'crypto';
import { ApplicationCommandOptionType } from 'discord.js';
@@ -30,7 +30,7 @@ export default class HashCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage, { url }: { url: string }) {
+ public override async exec(message: CommandMessage, { url }: { url: string }) {
try {
const req = await got.get(url);
const rawHash = crypto.createHash('md5');
diff --git a/src/commands/utilities/highlight-!.ts b/src/commands/utilities/highlight-!.ts
index 9aeb9ec..6dca545 100644
--- a/src/commands/utilities/highlight-!.ts
+++ b/src/commands/utilities/highlight-!.ts
@@ -1,7 +1,11 @@
-import { BushCommand, Highlight, HighlightWord, type BushSlashMessage } from '#lib';
+import { BushCommand, Highlight, HighlightWord, type SlashMessage } from '#lib';
import { Flag, type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo';
-import { ApplicationCommandOptionType } from 'discord-api-types/v10';
-import { ApplicationCommandSubCommandData, AutocompleteInteraction, CacheType } from 'discord.js';
+import {
+ ApplicationCommandOptionType,
+ ApplicationCommandSubCommandData,
+ type AutocompleteInteraction,
+ type CacheType
+} from 'discord.js';
type Unpacked<T> = T extends (infer U)[] ? U : T;
@@ -139,7 +143,7 @@ export default class HighlightCommand extends BushCommand {
return Flag.continue(`highlight-${subcommand}`);
}
- public override async execSlash(message: BushSlashMessage, args: { subcommand: keyof typeof highlightSubcommands }) {
+ public override async execSlash(message: SlashMessage, args: { subcommand: keyof typeof highlightSubcommands }) {
// manual `Flag.continue`
const subcommand = this.handler.modules.get(`highlight-${args.subcommand}`)!;
return subcommand.exec(message, args);
diff --git a/src/commands/utilities/highlight-add.ts b/src/commands/utilities/highlight-add.ts
index 73c61d2..726b887 100644
--- a/src/commands/utilities/highlight-add.ts
+++ b/src/commands/utilities/highlight-add.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { highlightCommandArgs, highlightSubcommands } from './highlight-!.js';
@@ -37,10 +37,7 @@ export default class HighlightAddCommand extends BushCommand {
});
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { word: ArgType<'string'>; regex: ArgType<'boolean'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { word: ArgType<'string'>; regex: ArgType<'flag'> }) {
assert(message.inGuild());
args.regex = false;
diff --git a/src/commands/utilities/highlight-block.ts b/src/commands/utilities/highlight-block.ts
index 4ad1a86..61e1254 100644
--- a/src/commands/utilities/highlight-block.ts
+++ b/src/commands/utilities/highlight-block.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Highlight, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Highlight, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { Argument, ArgumentGeneratorReturn } from 'discord-akairo';
import { Channel, GuildMember } from 'discord.js';
@@ -18,7 +18,7 @@ export default class HighlightBlockCommand extends BushCommand {
}
public override *args(): ArgumentGeneratorReturn {
- const target: ArgType<'member'> | ArgType<'channel'> = yield {
+ const target: ArgType<'member' | 'channel'> = yield {
type: Argument.union('member', 'channel'),
match: 'rest',
prompt: {
@@ -31,10 +31,7 @@ export default class HighlightBlockCommand extends BushCommand {
return { target };
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { target: string | ArgType<'member'> | ArgType<'channel'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { target: string | ArgType<'member' | 'channel'> }) {
assert(message.inGuild());
args.target =
diff --git a/src/commands/utilities/highlight-clear.ts b/src/commands/utilities/highlight-clear.ts
index 274c6fb..b905f3b 100644
--- a/src/commands/utilities/highlight-clear.ts
+++ b/src/commands/utilities/highlight-clear.ts
@@ -1,4 +1,4 @@
-import { BushCommand, ConfirmationPrompt, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ConfirmationPrompt, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { highlightSubcommands } from './highlight-!.js';
@@ -15,7 +15,7 @@ export default class HighlightClearCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
assert(message.inGuild());
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
diff --git a/src/commands/utilities/highlight-matches.ts b/src/commands/utilities/highlight-matches.ts
index 0e98c8d..40020cd 100644
--- a/src/commands/utilities/highlight-matches.ts
+++ b/src/commands/utilities/highlight-matches.ts
@@ -1,7 +1,7 @@
-import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ArgumentGeneratorReturn } from 'discord-akairo';
-import { APIEmbed } from 'discord-api-types/v10';
+import { type ArgumentGeneratorReturn } from 'discord-akairo';
+import { type APIEmbed } from 'discord.js';
import { highlightCommandArgs, highlightSubcommands } from './highlight-!.js';
export default class HighlightMatchesCommand extends BushCommand {
@@ -31,7 +31,7 @@ export default class HighlightMatchesCommand extends BushCommand {
return { phrase };
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { phrase: ArgType<'string'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { phrase: ArgType<'string'> }) {
assert(message.inGuild());
const res = await client.highlightManager.checkPhrase(message.guild.id, message.author.id, args.phrase);
diff --git a/src/commands/utilities/highlight-remove.ts b/src/commands/utilities/highlight-remove.ts
index 7e8c416..a2f2367 100644
--- a/src/commands/utilities/highlight-remove.ts
+++ b/src/commands/utilities/highlight-remove.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { highlightCommandArgs, highlightSubcommands } from './highlight-!.js';
@@ -28,7 +28,7 @@ export default class HighlightRemoveCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { word: ArgType<'string'> }) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { word: ArgType<'string'> }) {
assert(message.inGuild());
const res = await client.highlightManager.removeHighlight(message.guild.id, message.author.id, args.word);
diff --git a/src/commands/utilities/highlight-show.ts b/src/commands/utilities/highlight-show.ts
index d0a91e6..80ba4ca 100644
--- a/src/commands/utilities/highlight-show.ts
+++ b/src/commands/utilities/highlight-show.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Highlight, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Highlight, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { EmbedBuilder } from 'discord.js';
import { highlightSubcommands } from './highlight-!.js';
@@ -16,7 +16,7 @@ export default class HighlightShowCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
assert(message.inGuild());
const [highlight] = await Highlight.findOrCreate({
diff --git a/src/commands/utilities/highlight-unblock.ts b/src/commands/utilities/highlight-unblock.ts
index c437e6f..b738ee9 100644
--- a/src/commands/utilities/highlight-unblock.ts
+++ b/src/commands/utilities/highlight-unblock.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, Highlight, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, Highlight, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { Argument, ArgumentGeneratorReturn } from 'discord-akairo';
import { Channel, GuildMember } from 'discord.js';
@@ -18,7 +18,7 @@ export default class HighlightUnblockCommand extends BushCommand {
}
public override *args(): ArgumentGeneratorReturn {
- const target: ArgType<'member'> | ArgType<'channel'> = yield {
+ const target: ArgType<'member' | 'channel'> = yield {
type: Argument.union('member', 'channel'),
match: 'rest',
prompt: {
@@ -31,10 +31,7 @@ export default class HighlightUnblockCommand extends BushCommand {
return { target };
}
- public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { target: ArgType<'user'> | ArgType<'role'> | ArgType<'member'> }
- ) {
+ public override async exec(message: CommandMessage | SlashMessage, args: { target: ArgType<'user' | 'role' | 'member'> }) {
assert(message.inGuild());
if (!(args.target instanceof GuildMember || args.target instanceof Channel))
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index e4e4f50..a4f4c03 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type BushMessage } from '#lib';
+import { ArgType, BushCommand, type CommandMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, AutocompleteInteraction, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import Fuse from 'fuse.js';
@@ -45,7 +45,7 @@ export default class PriceCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage, { item, strict }: { item: string; strict: boolean }) {
+ public override async exec(message: CommandMessage, args: { item: ArgType<'string'>; strict: ArgType<'flag'> }) {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
const errors: string[] = [];
@@ -57,7 +57,7 @@ export default class PriceCommand extends BushCommand {
got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => { errors.push('auction average') })
])) as [Bazaar | undefined, LowestBIN | undefined, LowestBIN | undefined, AuctionAverages | undefined];
- let parsedItem = item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, '');
+ let parsedItem = args.item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, '');
const priceEmbed = new EmbedBuilder().setColor(errors?.length ? util.colors.warn : util.colors.success).setTimestamp();
if (bazaar?.success === false) errors.push('bazaar');
@@ -75,7 +75,7 @@ export default class PriceCommand extends BushCommand {
]);
// fuzzy search
- if (!strict) {
+ if (!args.strict) {
parsedItem = new Fuse([...itemNames], {
isCaseSensitive: false,
findAllMatches: true,
diff --git a/src/commands/utilities/remind.ts b/src/commands/utilities/remind.ts
index 044d4fc..8727879 100644
--- a/src/commands/utilities/remind.ts
+++ b/src/commands/utilities/remind.ts
@@ -1,4 +1,4 @@
-import { BushCommand, Reminder, Time, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, Reminder, Time, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class RemindCommand extends BushCommand {
@@ -28,8 +28,8 @@ export default class RemindCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- args: { reminder: ArgType<'contentWithDuration'> | string }
+ message: CommandMessage | SlashMessage,
+ args: { reminder: OptArgType<'contentWithDuration'> | string }
) {
const { duration, content } = await util.castDurationContent(args.reminder, message);
diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts
index 653274a..79284ac 100644
--- a/src/commands/utilities/reminders.ts
+++ b/src/commands/utilities/reminders.ts
@@ -1,7 +1,6 @@
-import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, Reminder, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { APIEmbed } from 'discord-api-types/v10';
-import { PermissionFlagsBits } from 'discord.js';
+import { PermissionFlagsBits, type APIEmbed } from 'discord.js';
import { Op } from 'sequelize';
assert(Op);
@@ -20,7 +19,7 @@ export default class RemindersCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
const reminders = await Reminder.findAll({ where: { user: message.author.id, expires: { [Op.gt]: new Date() } } });
if (!reminders.length) return message.util.send(`${util.emojis.error} You don't have any reminders set.`);
diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts
index e4f08f1..69d3054 100644
--- a/src/commands/utilities/steal.ts
+++ b/src/commands/utilities/steal.ts
@@ -1,7 +1,7 @@
-import { BushCommand, OptArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, OptArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
import { type ArgumentGeneratorReturn, type ArgumentType, type ArgumentTypeCaster } from 'discord-akairo';
-import { ApplicationCommandOptionType, PermissionFlagsBits, type Attachment } from 'discord.js';
+import { ApplicationCommandOptionType, Attachment, PermissionFlagsBits } from 'discord.js';
import _ from 'lodash';
import { Stream } from 'stream';
import { URL } from 'url';
@@ -41,7 +41,7 @@ export default class StealCommand extends BushCommand {
});
}
- public override *args(message: BushMessage): ArgumentGeneratorReturn {
+ public override *args(message: CommandMessage): ArgumentGeneratorReturn {
const hasImage = message.attachments.size && message.attachments.first()?.contentType?.includes('image/');
const emoji = hasImage
@@ -60,8 +60,8 @@ export default class StealCommand extends BushCommand {
}
public override async exec(
- message: BushMessage,
- args: { emoji: OptArgType<'discordEmoji'> | OptArgType<'snowflake'> | OptArgType<'url'> | string; name: string }
+ message: CommandMessage,
+ args: { emoji: OptArgType<'discordEmoji' | 'snowflake' | 'url'>; name: OptArgType<'string'> }
) {
assert(message.inGuild());
@@ -88,7 +88,9 @@ export default class StealCommand extends BushCommand {
: 'stolen_emoji';
const creationSuccess = await message.guild.emojis
- .create(image, emojiName, {
+ .create({
+ attachment: image,
+ name: emojiName,
reason: `Stolen by ${message.author.tag} (${message.author.id})`
})
.catch((e: Error) => e);
@@ -102,7 +104,7 @@ export default class StealCommand extends BushCommand {
}
}
- public override async execSlash(message: BushSlashMessage, args: { emoji: Attachment; name?: string }) {
+ public override async execSlash(message: SlashMessage, args: { emoji: Attachment; name: string | null }) {
assert(message.inGuild());
const name = args.name ?? args.emoji.name ?? 'stolen_emoji';
@@ -119,7 +121,9 @@ export default class StealCommand extends BushCommand {
: args.emoji.attachment;
const creationSuccess = await message.guild.emojis
- .create(data, name, {
+ .create({
+ attachment: data,
+ name: name,
reason: `Stolen by ${message.author.tag} (${message.author.id})`
})
.catch((e: Error) => e);
diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts
index e4609f2..c4151e8 100644
--- a/src/commands/utilities/suicide.ts
+++ b/src/commands/utilities/suicide.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { stripIndent } from '#tags';
import { EmbedBuilder } from 'discord.js';
@@ -17,7 +17,7 @@ export default class SuicideCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage) {
+ public override async exec(message: CommandMessage | SlashMessage) {
// stolen from https://github.com/dexbiobot/Zeppelin
const suicideEmbed = new EmbedBuilder()
.setTitle('Mental Health Resources')
diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts
index 448baf3..1e70e91 100644
--- a/src/commands/utilities/uuid.ts
+++ b/src/commands/utilities/uuid.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, ArgType, BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class UuidCommand extends BushCommand {
@@ -14,7 +14,7 @@ export default class UuidCommand extends BushCommand {
id: 'ign',
description: 'The ign to find the ign of.',
customType: /\w{1,16}/im,
- readableType: 'ign',
+ readableType: 'string[1,16]',
prompt: 'What ign would you like to find the uuid of?',
retry: '{error} Choose a valid ign.',
slashType: ApplicationCommandOptionType.String
@@ -23,7 +23,7 @@ export default class UuidCommand extends BushCommand {
id: 'dashed',
description: 'Include dashes in the uuid.',
match: 'flag',
- flag: '--dashed',
+ flag: ['--dashed', '-d'],
prompt: 'Would you like to include dashes in the uuid?',
slashType: ApplicationCommandOptionType.Boolean,
optional: true
@@ -36,15 +36,15 @@ export default class UuidCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
- { ign, dashed }: { ign: { match: RegExpMatchArray; matches?: any[] } | string; dashed: boolean }
+ message: CommandMessage | SlashMessage,
+ args: { ign: ArgType<'regex'> | string; dashed: ArgType<'flag'> }
) {
- if (typeof ign === 'string') ign = { match: /\w{1,16}/im.exec(ign)! };
+ if (typeof args.ign === 'string') args.ign = { match: /\w{1,16}/im.exec(args.ign)!, matches: [] };
- if (!ign || !ign.match) return await message.util.reply(`${util.emojis.error} Please enter a valid ign.`);
- const readableIGN = ign.match[0];
+ if (!args.ign.match) return await message.util.reply(`${util.emojis.error} Please enter a valid ign.`);
+ const readableIGN = args.ign.match[0];
try {
- const uuid = await util.mcUUID(readableIGN, dashed);
+ const uuid = await util.mcUUID(readableIGN, args.dashed);
return await message.util.reply({
content: `The uuid for ${util.format.input(readableIGN)} is ${util.format.input(uuid)}`,
allowedMentions: AllowedMentions.none()
diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts
index cb106dd..5c2c146 100644
--- a/src/commands/utilities/viewRaw.ts
+++ b/src/commands/utilities/viewRaw.ts
@@ -1,4 +1,4 @@
-import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptArgType } from '#lib';
+import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, ChannelType, EmbedBuilder, Message, PermissionFlagsBits } from 'discord.js';
@@ -23,7 +23,7 @@ export default class ViewRawCommand extends BushCommand {
{
id: 'channel',
description: 'The channel that the message is in.',
- type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'),
+ type: util.arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'),
prompt: 'What channel is the message in?',
retry: '{error} Choose a valid channel.',
optional: true,
@@ -34,7 +34,8 @@ export default class ViewRawCommand extends BushCommand {
ChannelType.GuildNews,
ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread,
- ChannelType.GuildPrivateThread
+ ChannelType.GuildPrivateThread,
+ ChannelType.GuildVoice
]
},
{
@@ -64,12 +65,12 @@ export default class ViewRawCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
- message: ArgType<'message'> | ArgType<'messageLink'>;
- channel: OptArgType<'textChannel'> | OptArgType<'newsChannel'> | OptArgType<'threadChannel'>;
- json: boolean;
- js: boolean;
+ message: ArgType<'message' | 'messageLink'>;
+ channel: OptArgType<'textChannel' | 'newsChannel' | 'threadChannel' | 'voiceChannel'>;
+ json: ArgType<'flag'>;
+ js: ArgType<'flag'>;
}
) {
assert(message.inGuild());
@@ -88,7 +89,7 @@ export default class ViewRawCommand extends BushCommand {
return await message.util.reply({ embeds: [Embed] });
}
- public static async getRawData(message: BushMessage, options: { json?: boolean; js: boolean }): Promise<EmbedBuilder> {
+ public static async getRawData(message: Message, options: { json?: boolean; js: boolean }): Promise<EmbedBuilder> {
const content =
options.json || options.js
? options.json
diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts
index 5f13c02..ae96a65 100644
--- a/src/commands/utilities/whoHasRole.ts
+++ b/src/commands/utilities/whoHasRole.ts
@@ -1,6 +1,6 @@
-import { BushCommand, BushRole, ButtonPaginator, OptArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, ButtonPaginator, OptArgType, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, Util, type CommandInteraction } from 'discord.js';
+import { ApplicationCommandOptionType, Util, type CommandInteraction, type Role } from 'discord.js';
export default class WhoHasRoleCommand extends BushCommand {
public constructor() {
@@ -31,7 +31,7 @@ export default class WhoHasRoleCommand extends BushCommand {
}
public override async exec(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
args: {
[K in `role${NumberRange}`]: OptArgType<'role'>;
}
@@ -39,7 +39,7 @@ export default class WhoHasRoleCommand extends BushCommand {
assert(message.inGuild());
if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply();
- const rawRoles = Object.values(args).filter((v) => v !== null) as BushRole[];
+ const rawRoles = Object.values(args).filter((v) => v !== null) as Role[];
const roles = rawRoles.map((v) => v.id);
const members = message.guild.members.cache.filter((m) => roles.every((r) => m.roles.cache.has(r)));
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index 0e1cb14..98cac69 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -1,4 +1,4 @@
-import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { initializeClass as WolframAlphaAPI } from '@notenoughupdates/wolfram-alpha-api';
import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, type MessageOptions } from 'discord.js';
@@ -39,7 +39,10 @@ export default class WolframAlphaCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string; image: boolean }) {
+ public override async exec(
+ message: CommandMessage | SlashMessage,
+ args: { expression: ArgType<'string'>; image: ArgType<'flag'> }
+ ) {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
args.image && void message.util.reply({ content: `${util.emojis.loading} Loading...`, embeds: [] });