aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/utilities')
-rw-r--r--src/commands/utilities/activity.ts3
-rw-r--r--src/commands/utilities/remind.ts32
-rw-r--r--src/commands/utilities/viewRaw.ts28
3 files changed, 27 insertions, 36 deletions
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 882c15d..230cc81 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -155,8 +155,7 @@ export default class ActivityCommand extends BushCommand {
args: { channel: ArgType<'voiceChannel'>; activity: string }
) {
const channel = typeof args.channel === 'string' ? message.guild?.channels.cache.get(args.channel) : args.channel;
- if (!channel || channel.type !== ChannelType.GuildVoice)
- return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`);
+ if (!channel || !channel.isVoice()) 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/remind.ts b/src/commands/utilities/remind.ts
index 4b7ccb9..044d4fc 100644
--- a/src/commands/utilities/remind.ts
+++ b/src/commands/utilities/remind.ts
@@ -1,4 +1,4 @@
-import { BushCommand, Reminder, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { BushCommand, Reminder, Time, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';
export default class RemindCommand extends BushCommand {
@@ -7,11 +7,11 @@ export default class RemindCommand extends BushCommand {
aliases: ['remind', 'remindme', 'reminder'],
category: 'utilities',
description: 'Create reminders that will be DMed to you when the time expires.',
- usage: ['remind <duration> <reason>'],
+ usage: ['remind <duration> <reminder>'],
examples: ['template 1 2'],
args: [
{
- id: 'reason_and_duration',
+ id: 'reminder',
type: 'contentWithDuration',
match: 'rest',
description: 'The reason to be reminded and the duration to remind the user in.',
@@ -29,32 +29,30 @@ export default class RemindCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { reason_and_duration: ArgType<'contentWithDuration'> | string }
+ args: { reminder: ArgType<'contentWithDuration'> | string }
) {
- const { duration, contentWithoutTime: reason } =
- typeof args.reason_and_duration === 'string'
- ? await util.arg.cast('contentWithDuration', message, args.reason_and_duration)
- : args.reason_and_duration;
+ const { duration, content } = await util.castDurationContent(args.reminder, message);
- if (!reason?.trim()) return await message.util.reply(`${util.emojis.error} Please enter a reason to be reminded about.`);
- if (!duration) return await message.util.reply(`${util.emojis.error} Please enter a duration.`);
+ if (!content.trim()) return await message.util.reply(`${util.emojis.error} Please enter a reason to be reminded about.`);
+ if (!duration) return await message.util.reply(`${util.emojis.error} Please enter a time to remind you in.`);
- if (duration < 30_000)
- return await message.util.reply(`${util.emojis.error} You cannot pick a duration less than 30 seconds.`);
+ if (duration < Time.Second * 30)
+ return await message.util.reply(`${util.emojis.error} You cannot be reminded in less than 30 seconds.`);
- const created = new Date();
const expires = new Date(Date.now() + duration);
- const delta = util.format.bold(util.dateDelta(expires));
const success = await Reminder.create({
- content: reason.trim(),
+ content: content.trim(),
messageUrl: message.url!,
user: message.author.id,
- created,
- expires
+ created: new Date(),
+ expires: expires
}).catch(() => false);
if (!success) return await message.util.reply(`${util.emojis.error} Could not create a reminder.`);
+
+ // This isn't technically accurate, but it prevents it from being .99 seconds
+ const delta = util.format.bold(util.dateDelta(new Date(Date.now() + duration)));
return await message.util.reply(`${util.emojis.success} I will remind you in ${delta} (${util.timestamp(expires, 'T')}).`);
}
}
diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts
index ee57e2d..be79499 100644
--- a/src/commands/utilities/viewRaw.ts
+++ b/src/commands/utilities/viewRaw.ts
@@ -1,13 +1,6 @@
-import {
- BushCommand,
- type ArgType,
- type BushMessage,
- type BushNewsChannel,
- type BushSlashMessage,
- type BushTextChannel,
- type OptionalArgType
-} from '#lib';
-import { ApplicationCommandOptionType, ChannelType, Embed, Message, PermissionFlagsBits, type Snowflake } from 'discord.js';
+import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
+import assert from 'assert';
+import { ApplicationCommandOptionType, ChannelType, Embed, Message, PermissionFlagsBits } from 'discord.js';
export default class ViewRawCommand extends BushCommand {
public constructor() {
@@ -30,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'),
+ type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'),
prompt: 'What channel is the message in?',
retry: '{error} Choose a valid channel.',
optional: true,
@@ -74,22 +67,23 @@ export default class ViewRawCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: {
message: ArgType<'guildMessage'> | ArgType<'messageLink'>;
- channel: OptionalArgType<'textChannel'> | OptionalArgType<'newsChannel'>;
+ channel: OptionalArgType<'textChannel'> | OptionalArgType<'newsChannel'> | OptionalArgType<'threadChannel'>;
json: boolean;
js: boolean;
}
) {
- if (!args.channel) args.channel = (message.channel as BushTextChannel | BushNewsChannel)!;
+ assert(message.inGuild());
+
+ args.channel ??= message.channel;
+
const newMessage =
- args.message instanceof Message
- ? args.message
- : await args.channel.messages.fetch(`${args.message}` as Snowflake).catch(() => null);
+ args.message instanceof Message ? args.message : await args.channel!.messages.fetch(`${args.message}`).catch(() => null);
if (!newMessage)
return await message.util.reply(
`${util.emojis.error} There was an error fetching that message, make sure that is a valid id and if the message is not in this channel, please provide a channel.`
);
- const Embed = await ViewRawCommand.getRawData(newMessage as BushMessage, { json: args.json, js: args.js });
+ const Embed = await ViewRawCommand.getRawData(newMessage, { json: args.json, js: args.js });
return await message.util.reply({ embeds: [Embed] });
}