Skip to content

Commit

Permalink
refactor: removed Skyra*PaginatedMessage (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Jul 27, 2024
1 parent d5b38a3 commit 2761725
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { readSettings, writeSettings, writeSettingsTransaction, type ReactionRole } from '#lib/database';
import { LanguageKeys } from '#lib/i18n/languageKeys';
import { SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures';
import { SkyraSubcommand } from '#lib/structures';
import { PermissionLevels, type GuildMessage } from '#lib/types';
import { minutes } from '#utils/common';
import { getEmojiString, getEmojiTextFormat } from '#utils/functions';
import { LongLivingReactionCollector } from '#utils/LongLivingReactionCollector';
import { getColor, sendLoadingMessage } from '#utils/util';
import { channelMention, hideLinkEmbed, hyperlink, roleMention } from '@discordjs/builders';
import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { CommandOptionsRunTypeEnum } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { chunk } from '@sapphire/utilities';
Expand Down Expand Up @@ -113,10 +115,11 @@ export class UserCommand extends SkyraSubcommand {

const response = await sendLoadingMessage(message, args.t);

const display = new SkyraPaginatedMessage({
const display = new PaginatedMessage({
template: new EmbedBuilder().setColor(getColor(message))
});

display.setIdle(minutes(5));
for (const bulk of chunk(reactionRoles, 15)) {
const serialized = bulk.map((value) => this.format(value, message.guild)).join('\n');
display.addPageEmbed((embed) => embed.setDescription(serialized));
Expand Down
13 changes: 7 additions & 6 deletions src/commands/Management/Helpers/guild-info.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { LanguageKeys } from '#lib/i18n/languageKeys';
import { SkyraCommand, SkyraPaginatedMessage } from '#lib/structures';
import { SkyraCommand } from '#lib/structures';
import type { GuildMessage } from '#lib/types';
import { seconds } from '#utils/common';
import { minutes, seconds } from '#utils/common';
import { ZeroWidthSpace } from '#utils/constants';
import { getColor, getTag } from '#utils/util';
import { TimestampStyles, time } from '@discordjs/builders';
import { time, TimestampStyles } from '@discordjs/builders';
import { ApplyOptions } from '@sapphire/decorators';
import { isCategoryChannel, isNewsChannel, isStageChannel, isTextChannel, isVoiceChannel } from '@sapphire/discord.js-utilities';
import { isCategoryChannel, isNewsChannel, isStageChannel, isTextChannel, isVoiceChannel, PaginatedMessage } from '@sapphire/discord.js-utilities';
import { CommandOptionsRunTypeEnum } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { chunk } from '@sapphire/utilities';
Expand Down Expand Up @@ -39,15 +39,16 @@ export class UserCommand extends SkyraCommand {
return send(message, { embeds: [embed] });
}

private async buildDisplay(args: SkyraCommand.Args, roles: Role[], color: number): Promise<SkyraPaginatedMessage> {
private async buildDisplay(args: SkyraCommand.Args, roles: Role[], color: number): Promise<PaginatedMessage> {
const guild = args.message.guild!;
const display = new SkyraPaginatedMessage({
const display = new PaginatedMessage({
template: new EmbedBuilder() //
.setColor(color)
.setThumbnail(guild.iconURL({ size: 256, extension: 'png' })!)
.setTitle(`${guild.name} [${guild.id}]`)
});

display.setIdle(minutes(5));
display.addPageEmbed(await this.getSummary(args, roles, color));
if (guild.icon) display.addPageEmbed(this.getIcon(args, color));
if (guild.banner) display.addPageEmbed(this.getBanner(args, color));
Expand Down
7 changes: 5 additions & 2 deletions src/commands/Management/roles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { readSettings, writeSettings } from '#lib/database';
import { LanguageKeys } from '#lib/i18n/languageKeys';
import { SkyraCommand, SkyraPaginatedMessage } from '#lib/structures';
import { SkyraCommand } from '#lib/structures';
import type { GuildMessage } from '#lib/types';
import { minutes } from '#utils/common';
import { getColor, sendLoadingMessage } from '#utils/util';
import { ApplyOptions } from '@sapphire/decorators';
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { CommandOptionsRunTypeEnum } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import type { TFunction } from '@sapphire/plugin-i18next';
Expand Down Expand Up @@ -124,12 +126,13 @@ export class UserPaginatedMessageCommand extends SkyraCommand {
// would filter and remove them all, causing this to be empty.
if (!roles.length) this.error(LanguageKeys.Commands.Management.RolesListEmpty);

const display = new SkyraPaginatedMessage({
const display = new PaginatedMessage({
template: new EmbedBuilder() //
.setColor(getColor(message))
.setTitle(t(LanguageKeys.Commands.Management.RolesListTitle))
});

display.setIdle(minutes(5));
for (const page of chunk(roles, 10)) {
display.addPageEmbed((embed) => embed.setDescription(page.join('\n')));
}
Expand Down
7 changes: 5 additions & 2 deletions src/commands/Twitch/twitchsubscription.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { GuildSubscriptionEntity, TwitchSubscriptionEntity } from '#lib/database';
import { LanguageKeys } from '#lib/i18n/languageKeys';
import { SkyraCommand, SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures';
import { SkyraCommand, SkyraSubcommand } from '#lib/structures';
import { PermissionLevels, type GuildMessage } from '#lib/types';
import { minutes } from '#utils/common';
import { getColor, getFullEmbedAuthor, sendLoadingMessage } from '#utils/util';
import { channelMention } from '@discordjs/builders';
import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { Args, CommandOptionsRunTypeEnum } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import type { TFunction } from '@sapphire/plugin-i18next';
Expand Down Expand Up @@ -198,12 +200,13 @@ export class UserCommand extends SkyraSubcommand {

// Create the pages and the URD to display them.
const pages = chunk(lines, 10);
const display = new SkyraPaginatedMessage({
const display = new PaginatedMessage({
template: new EmbedBuilder() //
.setAuthor(getFullEmbedAuthor(message.author))
.setColor(getColor(message))
});

display.setIdle(minutes(5));
for (const page of pages) display.addPageEmbed((embed) => embed.setDescription(page.join('\n')));

// Start the display and return the message.
Expand Down
9 changes: 0 additions & 9 deletions src/lib/structures/SkyraLazyPaginatedMessage.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/lib/structures/SkyraPaginatedMessage.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/lib/structures/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export * from '#lib/structures/AnalyticsData';
export * from '#lib/structures/InviteStore';
export * from '#lib/structures/SettingsMenu';
export * from '#lib/structures/SkyraLazyPaginatedMessage';
export * from '#lib/structures/SkyraPaginatedMessage';
export * from '#lib/structures/commands/index';
export * from '#lib/structures/listeners/index';
export * from '#lib/structures/managers';
Expand Down
12 changes: 0 additions & 12 deletions src/listeners/messages/guildMessageDeleteRichDisplay.ts

This file was deleted.

0 comments on commit 2761725

Please sign in to comment.