Skip to content

Commit

Permalink
refactor: better deprecations (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet authored Apr 9, 2023
1 parent 938c71e commit 8de2490
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/commands/Misc/remindme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { ScheduleEntity } from '#lib/database';
import { LanguageKeys } from '#lib/i18n/languageKeys';
import { SkyraCommand, SkyraPaginatedMessage } from '#lib/structures';
import { Schedules } from '#lib/types/Enums';
import { getColor, getTerylInviteComponentRow, sendLoadingMessage } from '#utils/util';
import { ButtonInviteTeryl, ButtonSkyraV7, makeRow } from '#utils/deprecate';
import { getColor, sendLoadingMessage } from '#utils/util';
import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';
import { Args } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
Expand All @@ -24,6 +25,8 @@ interface ReminderScheduledTask extends ScheduleEntity {
};
}

const row = makeRow(ButtonInviteTeryl, ButtonSkyraV7);

@ApplyOptions<SkyraCommand.Options>({
aliases: ['rmm', 'remind', 'reminder', 'reminders'],
description: LanguageKeys.Commands.Misc.RemindMeDescription,
Expand All @@ -37,7 +40,7 @@ export class UserCommand extends SkyraCommand {

public async create(message: Message, args: SkyraCommand.Args) {
const content = args.t(LanguageKeys.Commands.Misc.RemindMeDeprecated);
return send(message, { content, components: [getTerylInviteComponentRow()] });
return send(message, { content, components: [row] });
}

@RequiresClientPermissions(PermissionFlagsBits.EmbedLinks)
Expand Down
7 changes: 5 additions & 2 deletions src/commands/Tags/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import { SkyraCommand, SkyraPaginatedMessage } from '#lib/structures';
import type { GuildMessage } from '#lib/types';
import { PermissionLevels } from '#lib/types/Enums';
import { RequiresLevel } from '#utils/decorators';
import { getColor, getTerylInviteComponentRow, sendLoadingMessage } from '#utils/util';
import { ButtonInviteTeryl, ButtonSkyraV7, makeRow } from '#utils/deprecate';
import { getColor, sendLoadingMessage } from '#utils/util';
import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';
import { CommandOptionsRunTypeEnum } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { chunk, codeBlock } from '@sapphire/utilities';
import { PermissionFlagsBits } from 'discord-api-types/v9';
import { MessageEmbed, MessageOptions } from 'discord.js';

const row = makeRow(ButtonInviteTeryl, ButtonSkyraV7);

@ApplyOptions<SkyraCommand.Options>({
aliases: ['tags', 'custom-command', 'copy-pasta'],
description: LanguageKeys.Commands.Tags.TagDescription,
Expand Down Expand Up @@ -63,7 +66,7 @@ export class UserCommand extends SkyraCommand {
@RequiresLevel(PermissionLevels.Moderator, LanguageKeys.Commands.Tags.TagPermissionLevel)
public async deprecated(message: GuildMessage, args: SkyraCommand.Args) {
const content = args.t(LanguageKeys.Commands.Tags.Deprecated);
return send(message, { content, components: [getTerylInviteComponentRow()] });
return send(message, { content, components: [row] });
}

@RequiresClientPermissions(PermissionFlagsBits.EmbedLinks)
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en-US/commands/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"remindmeShowFooter": "ID: {{id}} | Ends at:",
"remindmeInvalidId": "I am sorry, but the ID provided does not seem to be valid.",
"remindmeNotfound": "I cannot find something here. The reminder either never existed or it ended.",
"remindmeDeprecated": "**Notice**: This command has been moved to Teryl and will be removed from Skyra around <t:1708772400:d>. Consider inviting him before then with the button below.",
"remindmeDeprecated": "The reminder functionality has been deprecated and will be removed around <t:1708772400:d>. Please use </reminders create:1078828281949859985> from Teryl instead. You may need to invite the bot with the button below if the command doesn't work.",
"shipDescription": "Ships 2 members",
"shipExtended": {
"usages": [
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en-US/commands/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"nameNotAllowed": "A tag name may not have a grave accent nor invisible characters.",
"nameTooLong": "A tag name must be 50 or less characters long.",
"notExists": "The tag `{{tag}}` does not exist.",
"deprecated": "**Notice**: This command has been moved to Teryl and will be removed from Skyra on <t:1685185200:d>. Consider inviting him before then with the button below."
"deprecated": "The tag functionality has been deprecated and will be removed around <t:1685185200:d>. Please use </manage-tag add:1078828281949859988> from Teryl instead. You may need to invite the bot with the button below if the command doesn't work."
}
12 changes: 2 additions & 10 deletions src/lib/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { LanguageKeys } from '#lib/i18n/languageKeys';
import type { GuildMessage } from '#lib/types';
import { ButtonBuilder } from '@discordjs/builders';
import { send } from '@sapphire/plugin-editable-commands';
import { isNullishOrEmpty, Nullish, tryParseURL } from '@sapphire/utilities';
import { loadImage, type Image } from 'canvas-constructor/napi-rs';
import { APIUser, ButtonStyle } from 'discord-api-types/v9';
import type { APIUser } from 'discord-api-types/v9';
import {
AllowedImageSize,
Guild,
GuildChannel,
ImageURLOptions,
Message,
MessageActionRow,
MessageEmbed,
MessageMentionTypes,
Permissions,
Expand All @@ -20,7 +18,7 @@ import {
UserResolvable
} from 'discord.js';
import type { TFunction } from 'i18next';
import { BrandingColors, Invites, ZeroWidthSpace } from './constants';
import { BrandingColors, ZeroWidthSpace } from './constants';

const ONE_TO_TEN = new Map<number, UtilOneToTenEntry>([
[0, { emoji: '😪', color: 0x5b1100 }],
Expand Down Expand Up @@ -309,12 +307,6 @@ export function getColor(message: Message) {
return message.member?.displayColor ?? BrandingColors.Primary;
}

export function getTerylInviteComponentRow() {
return new MessageActionRow().addComponents([
new ButtonBuilder().setLabel('Invite Teryl').setStyle(ButtonStyle.Link).setURL(Invites.Teryl).toJSON()
]);
}

export interface UtilOneToTenEntry {
emoji: string;
color: number;
Expand Down

0 comments on commit 8de2490

Please sign in to comment.