From 07e1025902642fd0a71830e2a37277eba84b775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aura=20Rom=C3=A1n?= Date: Thu, 9 Nov 2023 13:38:25 +0100 Subject: [PATCH] refactor: cleanup and permissions fixes --- package.json | 3 +- src/arguments/command.ts | 2 +- src/arguments/commandMatch.ts | 2 +- src/arguments/commandName.ts | 2 +- src/commands/Admin/conf.ts | 2 +- src/commands/Admin/roleset.ts | 3 +- src/commands/General/invite.ts | 2 +- .../manage-command-auto-delete.ts | 3 +- .../Configuration/manage-command-channel.ts | 3 +- .../Configuration/manage-reaction-roles.ts | 3 +- .../Configuration/setIgnoreChannels.ts | 5 +- .../Management/Configuration/setPrefix.ts | 3 +- src/commands/Management/Helpers/guild-info.ts | 4 +- src/commands/Management/Helpers/role-info.ts | 16 ++-- .../Management/Members/stickyRoles.ts | 3 +- .../Management/Message Filters/filter.ts | 3 +- src/commands/Management/create-mute.ts | 3 +- src/commands/Management/permissionNodes.ts | 3 +- src/commands/Misc/remindme.ts | 2 +- src/commands/Misc/snipe.ts | 3 +- src/commands/Moderation/Management/history.ts | 6 +- .../Moderation/Management/moderations.ts | 3 +- src/commands/Moderation/Management/mutes.ts | 3 +- .../Moderation/Management/warnings.ts | 3 +- src/commands/Moderation/Utilities/case.ts | 5 +- .../Moderation/Utilities/permissions.ts | 14 ++- src/commands/Moderation/Utilities/reason.ts | 3 +- src/commands/Moderation/Utilities/slowmode.ts | 3 +- src/commands/Moderation/Utilities/time.ts | 3 +- src/commands/Moderation/addrole.ts | 3 +- src/commands/Moderation/dehoist.ts | 3 +- src/commands/Moderation/lockdown.ts | 3 +- src/commands/Moderation/prune.ts | 3 +- src/commands/Moderation/removerole.ts | 5 +- src/commands/System/Admin/eval.ts | 2 +- src/commands/System/Admin/reboot.ts | 2 +- src/commands/Tools/whois.ts | 50 +++++----- src/commands/Twitch/twitchsubscription.ts | 4 +- src/languages/en-US/colors.json | 12 --- src/languages/en-US/guilds.json | 12 +-- src/languages/en-US/humanLevels.json | 12 +-- src/languages/en-US/permissions.json | 92 +++++++++---------- src/lib/database/entities/ModerationEntity.ts | 2 +- src/lib/database/entities/ScheduleEntity.ts | 2 +- src/lib/games/base/BaseReactionController.ts | 2 +- src/lib/games/base/BaseReactionGame.ts | 2 +- .../structures/ModerationCommand.ts | 3 +- .../structures/ModerationMessageListener.ts | 3 +- .../structures/SelfModerationCommand.ts | 3 +- src/lib/structures/SettingsMenu.ts | 6 +- .../commands/ChannelConfigurationCommand.ts | 3 +- .../structures/commands/SkyraSubcommand.ts | 3 +- .../preconditions/PermissionsPrecondition.ts | 3 +- src/lib/types/Augments.d.ts | 8 +- src/lib/types/index.ts | 1 + src/lib/util/bits.ts | 6 +- src/lib/util/common/index.ts | 1 + src/lib/util/common/objects.ts | 5 + src/listeners/analytics/analyticsSync.ts | 3 +- .../analytics/commandUsageAnalytics.ts | 3 +- .../analytics/guilds/guildCreateAnalytics.ts | 3 +- .../analytics/guilds/guildDeleteAnalytics.ts | 3 +- .../analytics/messages/messageAnalytics.ts | 2 +- .../analytics/resourceAnalyticsSync.ts | 3 +- .../analytics/twitchStreamHookedAnalytics.ts | 3 +- src/listeners/commands/messageCommandError.ts | 2 +- src/listeners/errors/taskError.ts | 3 +- src/listeners/errors/taskErrorSentry.ts | 5 +- .../guilds/members/guildMemberAdd.ts | 2 +- .../guildMemberUpdateNicknameNotify.ts | 2 +- .../members/guildMemberUpdateRolesNotify.ts | 2 +- .../members/notMutedMemberAddInitialRole.ts | 2 +- .../guilds/members/notMutedMemberAddNotify.ts | 2 +- .../guilds/members/rawGuildMemberRemove.ts | 2 +- .../guilds/members/rawMemberRemoveNotify.ts | 2 +- .../messages/guildUserMessageImageNotify.ts | 3 +- src/listeners/mentionSpamExceeded.ts | 3 +- .../messages/guildMessageDeleteNotify.ts | 3 +- .../messages/guildMessageDeleteRichDisplay.ts | 3 +- .../messages/guildMessageDeleteSnipe.ts | 3 +- .../messages/guildUserMessageMediaOnly.ts | 3 +- src/listeners/messages/messageCreate.ts | 2 +- src/listeners/messages/messageDelete.ts | 2 +- .../messageDeleteBulkRemoveResponses.ts | 3 +- .../messages/messageDeleteRemoveResponses.ts | 3 +- src/listeners/messages/messageUpdateNotify.ts | 2 +- src/listeners/messages/rawMessageDelete.ts | 2 +- .../messages/rawMessageDeleteBulk.ts | 2 +- .../messages/userMessageGuildHandler.ts | 2 +- .../guildUserMessageMentionsHandler.ts | 3 +- .../reactions/rawMessageReactionAdd.ts | 2 +- .../reactions/rawMessageReactionRemove.ts | 2 +- .../reactions/rawReactionAddBlockList.ts | 2 +- .../reactions/rawReactionAddNotify.ts | 2 +- src/listeners/reactions/rawReactionAddRole.ts | 2 +- .../reactions/rawReactionRemoveRole.ts | 2 +- src/listeners/ready.ts | 2 +- src/listeners/twitch/twitchStreamOffline.ts | 3 +- src/listeners/twitch/twitchStreamOnline.ts | 4 +- src/listeners/userUpdate.ts | 3 +- src/routes/twitch/twitchEventSubVerify.ts | 4 +- src/serializers/permissionnode.ts | 2 +- src/tasks/poststats.ts | 2 +- src/tasks/syncResourceAnalytics.ts | 2 +- tests/lib/bits.test.ts | 57 +----------- yarn.lock | 12 --- 106 files changed, 221 insertions(+), 334 deletions(-) delete mode 100644 src/languages/en-US/colors.json create mode 100644 src/lib/util/common/objects.ts diff --git a/package.json b/package.json index e086b36570c..db6311b0a38 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "start:profiler:0x": "0x --collect-only dist/Skyra.js", "test": "NODE_OPTIONS=\"--loader tsx/esm\" vitest", "lint": "eslint --fix --ext ts src tests", - "format": "prettier --write --loglevel=warn \"{src,tests}/**/*.{js,ts,json}\"", + "format": "prettier --write --log-level=warn \"{src,tests}/**/*.{js,ts,json}\"", "scripts:tlds": "node scripts/tlds.mjs", "scripts:migration": "node scripts/migrations.mjs", "dockerps": "pwsh -NoLogo ./.docker/control.ps1", @@ -67,7 +67,6 @@ "@sapphire/stopwatch": "^1.5.0", "@sapphire/time-utilities": "^1.7.10", "@sapphire/utilities": "^3.13.0", - "@sentry/hub": "^7.79.0", "@sentry/integrations": "^7.79.0", "@sentry/node": "^7.79.0", "@skyra/ai": "^1.2.0", diff --git a/src/arguments/command.ts b/src/arguments/command.ts index c5b11851a5e..ab0f5d4d8ab 100644 --- a/src/arguments/command.ts +++ b/src/arguments/command.ts @@ -1,6 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { SkyraCommand } from '#lib/structures'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import { OWNERS } from '#root/config'; import { Argument } from '@sapphire/framework'; diff --git a/src/arguments/commandMatch.ts b/src/arguments/commandMatch.ts index b10b30ff982..267a3c507da 100644 --- a/src/arguments/commandMatch.ts +++ b/src/arguments/commandMatch.ts @@ -1,7 +1,7 @@ import { CommandMatcher } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { SkyraCommand } from '#lib/structures'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import { OWNERS } from '#root/config'; import { Argument } from '@sapphire/framework'; diff --git a/src/arguments/commandName.ts b/src/arguments/commandName.ts index db4c1e55fb8..ae274e41741 100644 --- a/src/arguments/commandName.ts +++ b/src/arguments/commandName.ts @@ -1,6 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { SkyraCommand } from '#lib/structures'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import { OWNERS } from '#root/config'; import { FuzzySearch } from '#utils/Parsers/FuzzySearch'; import { Argument, Command } from '@sapphire/framework'; diff --git a/src/commands/Admin/conf.ts b/src/commands/Admin/conf.ts index 9882e4b4628..abdcf75aba9 100644 --- a/src/commands/Admin/conf.ts +++ b/src/commands/Admin/conf.ts @@ -2,7 +2,7 @@ import { configurableGroups, isSchemaGroup, isSchemaKey, readSettings, remove, r import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SettingsMenu, SkyraSubcommand } from '#lib/structures'; import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import { isValidCustomEmoji, isValidSerializedTwemoji, isValidTwemoji } from '#lib/util/functions/emojis'; import { filter, map } from '#utils/common'; import { inlineCode } from '@discordjs/builders'; diff --git a/src/commands/Admin/roleset.ts b/src/commands/Admin/roleset.ts index 16301aff4ca..9e282b53e43 100644 --- a/src/commands/Admin/roleset.ts +++ b/src/commands/Admin/roleset.ts @@ -1,8 +1,7 @@ import { GuildEntity, GuildSettings, readSettings, writeSettings, type UniqueRoleSet } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/commands/General/invite.ts b/src/commands/General/invite.ts index 6fb4dda31cc..62018c38732 100644 --- a/src/commands/General/invite.ts +++ b/src/commands/General/invite.ts @@ -62,7 +62,7 @@ export class UserCommand extends SkyraCommand { PermissionFlagsBits.EmbedLinks | PermissionFlagsBits.KickMembers | PermissionFlagsBits.ManageChannels | - PermissionFlagsBits.ManageEmojisAndStickers | + PermissionFlagsBits.ManageGuildExpressions | PermissionFlagsBits.ManageGuild | PermissionFlagsBits.ManageMessages | PermissionFlagsBits.ManageNicknames | diff --git a/src/commands/Management/Configuration/manage-command-auto-delete.ts b/src/commands/Management/Configuration/manage-command-auto-delete.ts index d17f87907be..9977c1925bb 100644 --- a/src/commands/Management/Configuration/manage-command-auto-delete.ts +++ b/src/commands/Management/Configuration/manage-command-auto-delete.ts @@ -1,8 +1,7 @@ import { GuildSettings, readSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { minutes, seconds } from '#utils/common'; import { ApplyOptions } from '@sapphire/decorators'; import type { GuildTextBasedChannelTypes } from '@sapphire/discord.js-utilities'; diff --git a/src/commands/Management/Configuration/manage-command-channel.ts b/src/commands/Management/Configuration/manage-command-channel.ts index d3308b3af2e..0b6787092eb 100644 --- a/src/commands/Management/Configuration/manage-command-channel.ts +++ b/src/commands/Management/Configuration/manage-command-channel.ts @@ -1,8 +1,7 @@ import { GuildSettings, readSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/commands/Management/Configuration/manage-reaction-roles.ts b/src/commands/Management/Configuration/manage-reaction-roles.ts index 5b7aeb06b57..d3d2ca0fefc 100644 --- a/src/commands/Management/Configuration/manage-reaction-roles.ts +++ b/src/commands/Management/Configuration/manage-reaction-roles.ts @@ -1,8 +1,7 @@ import { GuildSettings, readSettings, writeSettings, type ReactionRole } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { getEmojiString, getEmojiTextFormat } from '#utils/functions'; import { LongLivingReactionCollector } from '#utils/LongLivingReactionCollector'; import { getColor, sendLoadingMessage } from '#utils/util'; diff --git a/src/commands/Management/Configuration/setIgnoreChannels.ts b/src/commands/Management/Configuration/setIgnoreChannels.ts index 24cea141c1e..df5e55b4f91 100644 --- a/src/commands/Management/Configuration/setIgnoreChannels.ts +++ b/src/commands/Management/Configuration/setIgnoreChannels.ts @@ -1,11 +1,10 @@ import { GuildSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import type { GuildTextBasedChannelTypes } from '@sapphire/discord.js-utilities'; -import { Args, CommandOptionsRunTypeEnum, container, Argument } from '@sapphire/framework'; +import { Args, Argument, CommandOptionsRunTypeEnum, container } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; @ApplyOptions({ diff --git a/src/commands/Management/Configuration/setPrefix.ts b/src/commands/Management/Configuration/setPrefix.ts index 85f7b4d8b58..f0fe0e535e5 100644 --- a/src/commands/Management/Configuration/setPrefix.ts +++ b/src/commands/Management/Configuration/setPrefix.ts @@ -1,8 +1,7 @@ import { GuildSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/commands/Management/Helpers/guild-info.ts b/src/commands/Management/Helpers/guild-info.ts index 82ebb73bada..d870e0be7d1 100644 --- a/src/commands/Management/Helpers/guild-info.ts +++ b/src/commands/Management/Helpers/guild-info.ts @@ -10,7 +10,7 @@ import { isCategoryChannel, isNewsChannel, isStageChannel, isTextChannel, isVoic import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; import { chunk } from '@sapphire/utilities'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; +import { GuildVerificationLevel, PermissionFlagsBits } from 'discord-api-types/v10'; import { EmbedBuilder, PermissionsBitField, Role } from 'discord.js'; const SORT = (x: Role, y: Role) => Number(y.position > x.position) || Number(x.position === y.position) - 1; @@ -179,7 +179,7 @@ export class UserCommand extends SkyraCommand { return args.t(LanguageKeys.Commands.Management.GuildInfoOther, { size: guild.roles.cache.size, createdAt: time(seconds.fromMilliseconds(guild.createdTimestamp), TimestampStyles.ShortDateTime), - verificationLevel: guild.verificationLevel + verificationLevel: GuildVerificationLevel[guild.verificationLevel] }); } } diff --git a/src/commands/Management/Helpers/role-info.ts b/src/commands/Management/Helpers/role-info.ts index a52928a4729..879cf96f3cc 100644 --- a/src/commands/Management/Helpers/role-info.ts +++ b/src/commands/Management/Helpers/role-info.ts @@ -1,7 +1,7 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; +import { PermissionsBits } from '#utils/bits'; import { BrandingColors } from '#utils/constants'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; @@ -21,12 +21,12 @@ export class UserCommand extends SkyraCommand { const role = args.finished ? message.member.roles.highest : await args.pick('roleName'); const roleInfoTitles = args.t(LanguageKeys.Commands.Management.RoleInfoTitles); - const permissions = role.permissions.has(PermissionFlagsBits.Administrator) + const permissions = role.permissions.bitfield; + const permissionsString = PermissionsBits.has(permissions, PermissionFlagsBits.Administrator) ? args.t(LanguageKeys.Commands.Management.RoleInfoAll) - : role.permissions.toArray().length > 0 - ? role.permissions - .toArray() - .map((key) => `+ **${args.t(`permissions:${key}`, key)}**`) + : permissions > 0n + ? PermissionsBits.toArray(permissions) + .map((name) => `+ ${args.t(`permissions:${name}`)}`) .join('\n') : args.t(LanguageKeys.Commands.Management.RoleInfoNoPermissions); @@ -40,7 +40,7 @@ export class UserCommand extends SkyraCommand { .setColor(role.color || BrandingColors.Secondary) .setTitle(`${role.name} [${role.id}]`) .setDescription(description) - .addFields({ name: roleInfoTitles.PERMISSIONS, value: permissions }); + .addFields({ name: roleInfoTitles.PERMISSIONS, value: permissionsString }); return send(message, { embeds: [embed] }); } } diff --git a/src/commands/Management/Members/stickyRoles.ts b/src/commands/Management/Members/stickyRoles.ts index 89754bfa376..f8225d005e1 100644 --- a/src/commands/Management/Members/stickyRoles.ts +++ b/src/commands/Management/Members/stickyRoles.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { getStickyRoles } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Management/Message Filters/filter.ts b/src/commands/Management/Message Filters/filter.ts index ae800d831a4..8753fbd0b1f 100644 --- a/src/commands/Management/Message Filters/filter.ts +++ b/src/commands/Management/Message Filters/filter.ts @@ -2,8 +2,7 @@ import { GuildEntity, GuildSettings, readSettings, writeSettings } from '#lib/da import { LanguageKeys } from '#lib/i18n/languageKeys'; import { IncomingType, OutgoingType } from '#lib/moderation/workers'; import { SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/commands/Management/create-mute.ts b/src/commands/Management/create-mute.ts index 8102f27cfc0..6d71e923cbd 100644 --- a/src/commands/Management/create-mute.ts +++ b/src/commands/Management/create-mute.ts @@ -1,8 +1,7 @@ import { GuildSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { minutes } from '#utils/common'; import { Emojis } from '#utils/constants'; import { getEmojiReactionFormat, getSecurity, promptConfirmation, promptForMessage, type SerializedEmoji } from '#utils/functions'; diff --git a/src/commands/Management/permissionNodes.ts b/src/commands/Management/permissionNodes.ts index d5365432176..5a96bbaaa30 100644 --- a/src/commands/Management/permissionNodes.ts +++ b/src/commands/Management/permissionNodes.ts @@ -1,8 +1,7 @@ import { GuildSettings, PermissionNodeAction, readSettings, writeSettings, type PermissionsNode } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { resolveOnErrorCodes } from '#utils/common'; import { ApplyOptions } from '@sapphire/decorators'; import { Args, CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Misc/remindme.ts b/src/commands/Misc/remindme.ts index 773cf58f80c..32ea3fee6d2 100644 --- a/src/commands/Misc/remindme.ts +++ b/src/commands/Misc/remindme.ts @@ -1,7 +1,7 @@ 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 { Schedules } from '#lib/types'; import { ButtonInviteTeryl, ButtonSkyraV7, makeRow } from '#utils/deprecate'; import { getColor, getFullEmbedAuthor, sendLoadingMessage } from '#utils/util'; import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators'; diff --git a/src/commands/Misc/snipe.ts b/src/commands/Misc/snipe.ts index 750b7bdafb4..660491d841d 100644 --- a/src/commands/Misc/snipe.ts +++ b/src/commands/Misc/snipe.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { getSnipedMessage } from '#utils/functions'; import { getColor, getContent, getFullEmbedAuthor, getImage } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/commands/Moderation/Management/history.ts b/src/commands/Moderation/Management/history.ts index df7a342fac8..1d5595672a8 100644 --- a/src/commands/Moderation/Management/history.ts +++ b/src/commands/Moderation/Management/history.ts @@ -1,8 +1,7 @@ import type { ModerationEntity } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { seconds } from '#utils/common'; import { getModeration } from '#utils/functions'; import { TypeVariation } from '#utils/moderationConstants'; @@ -56,6 +55,9 @@ export class UserCommand extends SkyraSubcommand { break; case TypeVariation.Warning: ++warnings; + break; + default: + break; } } diff --git a/src/commands/Moderation/Management/moderations.ts b/src/commands/Moderation/Management/moderations.ts index 390e79cac15..29008a17bb2 100644 --- a/src/commands/Moderation/Management/moderations.ts +++ b/src/commands/Moderation/Management/moderations.ts @@ -1,8 +1,7 @@ import type { ModerationEntity } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand, SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { seconds } from '#utils/common'; import { getModeration } from '#utils/functions'; import { TypeCodes } from '#utils/moderationConstants'; diff --git a/src/commands/Moderation/Management/mutes.ts b/src/commands/Moderation/Management/mutes.ts index 9950396c195..e021fb73349 100644 --- a/src/commands/Moderation/Management/mutes.ts +++ b/src/commands/Moderation/Management/mutes.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import type { UserPaginatedMessageCommand as Moderations } from '#root/commands/Moderation/Management/moderations'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Moderation/Management/warnings.ts b/src/commands/Moderation/Management/warnings.ts index 713fdca3c49..500a2e37de5 100644 --- a/src/commands/Moderation/Management/warnings.ts +++ b/src/commands/Moderation/Management/warnings.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import type { UserPaginatedMessageCommand as Moderations } from '#root/commands/Moderation/Management/moderations'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Moderation/Utilities/case.ts b/src/commands/Moderation/Utilities/case.ts index 2703f788a89..c05216ae3bd 100644 --- a/src/commands/Moderation/Utilities/case.ts +++ b/src/commands/Moderation/Utilities/case.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { getModeration } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; @@ -36,7 +35,7 @@ export class UserCommand extends SkyraSubcommand { const entry = await moderation.fetch(caseId); if (!entry) this.error(LanguageKeys.Commands.Moderation.ReasonNotExists); - entry.remove(); + await entry.remove(); moderation.delete(entry.caseId); const content = args.t(LanguageKeys.Commands.Moderation.CaseDeleted, { case: entry.caseId }); diff --git a/src/commands/Moderation/Utilities/permissions.ts b/src/commands/Moderation/Utilities/permissions.ts index d91bb98f852..30bb0e0a66e 100644 --- a/src/commands/Moderation/Utilities/permissions.ts +++ b/src/commands/Moderation/Utilities/permissions.ts @@ -1,7 +1,7 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; +import { PermissionsBits, PermissionsBitsList } from '#utils/bits'; import { ZeroWidthSpace } from '#utils/constants'; import { getColor, getTag } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; @@ -10,8 +10,6 @@ import { send } from '@sapphire/plugin-editable-commands'; import { PermissionFlagsBits } from 'discord-api-types/v10'; import { EmbedBuilder } from 'discord.js'; -const PERMISSION_FLAGS = Object.keys(PermissionFlagsBits) as (keyof typeof PermissionFlagsBits)[]; - @ApplyOptions({ description: LanguageKeys.Commands.Moderation.PermissionsDescription, detailedDescription: LanguageKeys.Commands.Moderation.PermissionsExtended, @@ -26,14 +24,14 @@ export class UserCommand extends SkyraCommand { this.error(LanguageKeys.Misc.UserNotInGuild); }); - const { permissions } = member; + const permissions = member.permissions.bitfield; const list = [ZeroWidthSpace]; - if (permissions.has(PermissionFlagsBits.Administrator)) { + if (PermissionsBits.has(permissions, PermissionFlagsBits.Administrator)) { list.push(args.t(LanguageKeys.Commands.Moderation.PermissionsAll)); } else { - for (const flag of PERMISSION_FLAGS) { - list.push(`${permissions.has(flag) ? '🔹' : '🔸'} ${args.t(`permissions:${flag}`, flag)}`); + for (const [name, flag] of PermissionsBitsList) { + list.push(`${PermissionsBits.has(permissions, flag) ? '🔹' : '🔸'} ${args.t(`permissions:${name}`)}`); } } diff --git a/src/commands/Moderation/Utilities/reason.ts b/src/commands/Moderation/Utilities/reason.ts index 0cf1f7434ca..01cf482f7b9 100644 --- a/src/commands/Moderation/Utilities/reason.ts +++ b/src/commands/Moderation/Utilities/reason.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { Events, PermissionLevels } from '#lib/types/Enums'; +import { Events, PermissionLevels, type GuildMessage } from '#lib/types'; import { getModeration, sendTemporaryMessage } from '#utils/functions'; import { getImage } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/commands/Moderation/Utilities/slowmode.ts b/src/commands/Moderation/Utilities/slowmode.ts index d64dd070125..08c1c12fe53 100644 --- a/src/commands/Moderation/Utilities/slowmode.ts +++ b/src/commands/Moderation/Utilities/slowmode.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types/Discord'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { hours, seconds } from '#utils/common'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Moderation/Utilities/time.ts b/src/commands/Moderation/Utilities/time.ts index b61d0129cdd..d0a5b0b3c01 100644 --- a/src/commands/Moderation/Utilities/time.ts +++ b/src/commands/Moderation/Utilities/time.ts @@ -1,8 +1,7 @@ import type { ModerationEntity } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { seconds, years } from '#utils/common'; import { getModeration, getSecurity } from '#utils/functions'; import { SchemaKeys, TypeCodes } from '#utils/moderationConstants'; diff --git a/src/commands/Moderation/addrole.ts b/src/commands/Moderation/addrole.ts index 6564439fbcb..6df1b940ba2 100644 --- a/src/commands/Moderation/addrole.ts +++ b/src/commands/Moderation/addrole.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { ModerationCommand, type HandledCommandContext } from '#lib/moderation'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { years } from '#utils/common'; import { getSecurity } from '#utils/functions'; import { getImage } from '#utils/util'; diff --git a/src/commands/Moderation/dehoist.ts b/src/commands/Moderation/dehoist.ts index c8e90f05473..17dd73effe4 100644 --- a/src/commands/Moderation/dehoist.ts +++ b/src/commands/Moderation/dehoist.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { getColor, sendLoadingMessage } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; diff --git a/src/commands/Moderation/lockdown.ts b/src/commands/Moderation/lockdown.ts index 0f50d0ae1f9..f2c4be84a27 100644 --- a/src/commands/Moderation/lockdown.ts +++ b/src/commands/Moderation/lockdown.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { LockdownManager, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { floatPromise } from '#utils/common'; import { assertNonThread, getSecurity } from '#utils/functions'; import { clearAccurateTimeout, setAccurateTimeout } from '#utils/Timers'; diff --git a/src/commands/Moderation/prune.ts b/src/commands/Moderation/prune.ts index 674fd1aec53..44d8553264b 100644 --- a/src/commands/Moderation/prune.ts +++ b/src/commands/Moderation/prune.ts @@ -1,8 +1,7 @@ import { GuildSettings, readSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { days, floatPromise, seconds } from '#utils/common'; import { andMix, type BooleanFn } from '#utils/common/comparators'; import { formatMessage } from '#utils/formatters'; diff --git a/src/commands/Moderation/removerole.ts b/src/commands/Moderation/removerole.ts index e90d07e400e..a942f189d67 100644 --- a/src/commands/Moderation/removerole.ts +++ b/src/commands/Moderation/removerole.ts @@ -1,7 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { type HandledCommandContext, ModerationCommand } from '#lib/moderation'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { ModerationCommand, type HandledCommandContext } from '#lib/moderation'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { years } from '#utils/common'; import { getSecurity } from '#utils/functions'; import { getImage } from '#utils/util'; diff --git a/src/commands/System/Admin/eval.ts b/src/commands/System/Admin/eval.ts index 9da3a0e392b..4b324e28c3c 100644 --- a/src/commands/System/Admin/eval.ts +++ b/src/commands/System/Admin/eval.ts @@ -1,6 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import { createReferPromise, seconds } from '#utils/common'; import { ZeroWidthSpace } from '#utils/constants'; import { clean } from '#utils/Sanitizer/clean'; diff --git a/src/commands/System/Admin/reboot.ts b/src/commands/System/Admin/reboot.ts index 626bc8c3bea..7978177a422 100644 --- a/src/commands/System/Admin/reboot.ts +++ b/src/commands/System/Admin/reboot.ts @@ -1,6 +1,6 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; -import { Events, PermissionLevels } from '#lib/types/Enums'; +import { Events, PermissionLevels } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { send } from '@sapphire/plugin-editable-commands'; import { envParseBoolean } from '@skyra/env-utilities'; diff --git a/src/commands/Tools/whois.ts b/src/commands/Tools/whois.ts index 914a04e8b6c..81ea31db8f7 100644 --- a/src/commands/Tools/whois.ts +++ b/src/commands/Tools/whois.ts @@ -2,7 +2,8 @@ import { SkyraEmbed } from '#lib/discord'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures'; import type { GuildMessage } from '#lib/types'; -import { months, seconds } from '#utils/common'; +import { PermissionsBits } from '#utils/bits'; +import { map, months, seconds } from '#utils/common'; import { Colors, Emojis } from '#utils/constants'; import { getDisplayAvatar, getTag } from '#utils/util'; import { TimestampStyles, time } from '@discordjs/builders'; @@ -23,19 +24,18 @@ const sortRanks = (x: Role, y: Role) => Number(y.position > x.position) || Numbe runIn: [CommandOptionsRunTypeEnum.GuildAny] }) export class UserCommand extends SkyraCommand { - private readonly kAdministratorPermission = PermissionFlagsBits.Administrator; - private readonly kKeyPermissions: [keyof typeof PermissionFlagsBits, bigint][] = [ - ['BanMembers', PermissionFlagsBits.BanMembers], - ['KickMembers', PermissionFlagsBits.KickMembers], - ['ManageChannels', PermissionFlagsBits.ManageChannels], - ['ManageGuildExpressions', PermissionFlagsBits.ManageGuildExpressions], - ['ManageGuild', PermissionFlagsBits.ManageGuild], - ['ManageMessages', PermissionFlagsBits.ManageMessages], - ['ManageNicknames', PermissionFlagsBits.ManageNicknames], - ['ManageRoles', PermissionFlagsBits.ManageRoles], - ['ManageWebhooks', PermissionFlagsBits.ManageWebhooks], - ['MentionEveryone', PermissionFlagsBits.MentionEveryone] - ]; + private readonly KeyPermissions = PermissionsBits.resolve([ + PermissionFlagsBits.BanMembers, + PermissionFlagsBits.KickMembers, + PermissionFlagsBits.ManageChannels, + PermissionFlagsBits.ManageGuildExpressions, + PermissionFlagsBits.ManageGuild, + PermissionFlagsBits.ManageMessages, + PermissionFlagsBits.ManageNicknames, + PermissionFlagsBits.ManageRoles, + PermissionFlagsBits.ManageWebhooks, + PermissionFlagsBits.MentionEveryone + ]); public override async messageRun(message: GuildMessage, args: SkyraCommand.Args) { const user = args.finished ? message.author : await args.pick('userName'); @@ -106,7 +106,11 @@ export class UserCommand extends SkyraCommand { } private applyMemberKeyPermissions(t: TFunction, member: GuildMember, embed: SkyraEmbed) { - if (member.permissions.has(this.kAdministratorPermission)) { + const permissions = member.permissions.bitfield; + + // If the member has Administrator, add a field indicating the member + // has all permissions and return: + if (PermissionsBits.has(permissions, PermissionFlagsBits.Administrator)) { embed.addFields({ name: t(LanguageKeys.Commands.Tools.WhoisMemberPermissions), value: t(LanguageKeys.Commands.Tools.WhoisMemberPermissionsAll) @@ -114,14 +118,16 @@ export class UserCommand extends SkyraCommand { return; } - const permissions: string[] = []; - for (const [name, bit] of this.kKeyPermissions) { - if (member.permissions.has(bit)) permissions.push(t(`permissions:${name}`)); - } + // Create an intersection between the permissions the member has and the + // key permissions, if there are no permissions, return, else add a field + // with the permissions: + const intersection = PermissionsBits.intersection(permissions, this.KeyPermissions); + if (intersection === 0n) return; - if (permissions.length > 0) { - embed.addFields({ name: t(LanguageKeys.Commands.Tools.WhoisMemberPermissions), value: permissions.join(', ') }); - } + embed.addFields({ + name: t(LanguageKeys.Commands.Tools.WhoisMemberPermissions), + value: [...map(PermissionsBits.toKeys(intersection), (name) => t(`permissions:${name}`))].join(', ') + }); } private getBoostIcon(boostingSince: number | null): string { diff --git a/src/commands/Twitch/twitchsubscription.ts b/src/commands/Twitch/twitchsubscription.ts index 073b2440c75..d41945d0b47 100644 --- a/src/commands/Twitch/twitchsubscription.ts +++ b/src/commands/Twitch/twitchsubscription.ts @@ -1,9 +1,7 @@ import { GuildSubscriptionEntity, TwitchSubscriptionEntity } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand, SkyraPaginatedMessage, SkyraSubcommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { TwitchEventSubTypes, type TwitchHelixUsersSearchResult } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, TwitchEventSubTypes, type GuildMessage, type TwitchHelixUsersSearchResult } from '#lib/types'; import { getColor, getFullEmbedAuthor, sendLoadingMessage } from '#utils/util'; import { channelMention } from '@discordjs/builders'; import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators'; diff --git a/src/languages/en-US/colors.json b/src/languages/en-US/colors.json deleted file mode 100644 index 7e7f8d54b83..00000000000 --- a/src/languages/en-US/colors.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invalidBase10": "Color must be within the range 0 - 16777215 (0xFFFFFF), but received `{{value}}`.", - "invalidHexRed": "Invalid Red range. Must be between '00' and 'ff', but received `{{value}}`.", - "invalidHexGreen": "Invalid Green range. Must be between '00' and 'ff', but received `{{value}}`.", - "invalidHexBlue": "Invalid Blue range. Must be between '00' and 'ff', but received `{{value}}`.", - "invalidHslHue": "Invalid Hue range. Must be between 0 and 360, but received `{{value}}`.", - "invalidHslSaturation": "Invalid Saturation range. Must be between 0 and 100, but received `{{value}}`.", - "invalidHslLightness": "Invalid Lightness range. Must be between 0 and 100, but received `{{value}}`.", - "invalidRgbRed": "Invalid Red range. Must be between 0 and 255, but received `{{value}}`.", - "invalidRgbGreen": "Invalid Green range. Must be between 0 and 255, but received `{{value}}`.", - "invalidRgbBlue": "Invalid Blue range. Must be between 0 and 255, but received `{{value}}`." -} diff --git a/src/languages/en-US/guilds.json b/src/languages/en-US/guilds.json index 946880a0acc..dc0bc039ac0 100644 --- a/src/languages/en-US/guilds.json +++ b/src/languages/en-US/guilds.json @@ -4,10 +4,10 @@ "explicitContentFilterAllMembers": "All members", "messageNotificationsAll": "All Messages", "messageNotificationsMentions": "Only @mentions", - "SUPPRESS_JOIN_NOTIFICATIONS": "Member join notifications", - "SUPPRESS_JOIN_NOTIFICATION_REPLIES": "Member join sticker reply buttons", - "SUPPRESS_PREMIUM_SUBSCRIPTIONS": "Server boost notifications", - "SUPPRESS_GUILD_REMINDER_NOTIFICATIONS": "Server setup tips", - "SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS": "Suppress role subscription purchase notifications", - "SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES": "Suppress replies for role subscription purchase notifications" + "SuppressJoinNotifications": "Member join notifications", + "SuppressJoinNotificationReplies": "Member join sticker reply buttons", + "SuppressPremiumSubscriptions": "Server boost notifications", + "SuppressGuildReminderNotifications": "Server setup tips", + "SuppressRoleSubscriptionPurchaseNotifications": "Suppress role subscription purchase notifications", + "SuppressRoleSubscriptionPurchaseNotificationReplies": "Suppress replies for role subscription purchase notifications" } diff --git a/src/languages/en-US/humanLevels.json b/src/languages/en-US/humanLevels.json index bd785d3ded8..80314b99821 100644 --- a/src/languages/en-US/humanLevels.json +++ b/src/languages/en-US/humanLevels.json @@ -1,7 +1,7 @@ { - "NONE": "None", - "LOW": "Low", - "MEDIUM": "Medium", - "HIGH": "High", - "VERY_HIGH": "Highest" -} \ No newline at end of file + "None": "None", + "Low": "Low", + "Medium": "Medium", + "High": "High", + "VeryHigh": "Highest" +} diff --git a/src/languages/en-US/permissions.json b/src/languages/en-US/permissions.json index 92dd6dd61d7..71dcd91fbb6 100644 --- a/src/languages/en-US/permissions.json +++ b/src/languages/en-US/permissions.json @@ -1,48 +1,48 @@ { - "ADD_REACTIONS": "Add Reactions", - "ADMINISTRATOR": "Administrator", - "ATTACH_FILES": "Attach Files", - "BAN_MEMBERS": "Ban Members", - "CHANGE_NICKNAME": "Change Nickname", - "CONNECT": "Connect", - "CREATE_INSTANT_INVITE": "Create Invite", - "CREATE_PRIVATE_THREADS": "Create Private Threads", - "CREATE_PUBLIC_THREADS": "Create Public Threads", - "DEAFEN_MEMBERS": "Deafen Members", - "EMBED_LINKS": "Embed Links", - "KICK_MEMBERS": "Kick Members", - "MANAGE_CHANNELS": "Manage Channels", - "MANAGE_EMOJIS_AND_STICKERS": "Manage Emojis and Stickers", - "MANAGE_EVENTS": "Manage Events", - "MANAGE_GUILD": "Manage Server", - "MANAGE_MESSAGES": "Manage Messages", - "MANAGE_NICKNAMES": "Manage Nicknames", - "MANAGE_ROLES": "Manage Roles", - "MANAGE_THREADS": "Manage Threads", - "MANAGE_WEBHOOKS": "Manage Webhooks", - "MENTION_EVERYONE": "Mention everyone, here, and All Roles", - "MODERATE_MEMBERS": "Timeout Members", - "MOVE_MEMBERS": "Move Members", - "MUTE_MEMBERS": "Mute Members", - "PRIORITY_SPEAKER": "Priority Speaker", - "READ_MESSAGE_HISTORY": "Read Message History", - "REQUEST_TO_SPEAK": "Request to Speak", - "SEND_MESSAGES_IN_THREADS": "Send Messages in Threads", - "SEND_MESSAGES": "Send Messages", - "SEND_TTS_MESSAGES": "Send Text-to-Speech Messages", - "SEND_VOICE_MESSAGES": "Send Voice Messages", - "SPEAK": "Speak", - "START_EMBEDDED_ACTIVITIES": "Start Embedded Activities", - "STREAM": "Video", - "USE_APPLICATION_COMMANDS": "Use Application Commands", - "USE_EXTERNAL_EMOJIS": "Use External Emojis", - "USE_EXTERNAL_STICKERS": "Use External Stickers", - "USE_PRIVATE_THREADS": "Create Private Threads", - "USE_PUBLIC_THREADS": "Create Public Threads", - "USE_SOUNDBOARD": "Use Soundboard", - "USE_VAD": "Use Voice Activity", - "VIEW_AUDIT_LOG": "View Audit Log", - "VIEW_CHANNEL": "View Channels", - "VIEW_CREATOR_MONETIZATION_ANALYTICS": "View Creator Monetization Analytics", - "VIEW_GUILD_INSIGHTS": "View Server Insights" + "AddReactions": "Add Reactions", + "Administrator": "Administrator", + "AttachFiles": "Attach Files", + "BanMembers": "Ban Members", + "ChangeNickname": "Change Nickname", + "Connect": "Connect", + "CreateExpressions": "Create Expressions", + "CreateInstantInvite": "Create Invite", + "CreatePrivateThreads": "Create Private Threads", + "CreatePublicThreads": "Create Public Threads", + "DeafenMembers": "Deafen Members", + "EmbedLinks": "Embed Links", + "KickMembers": "Kick Members", + "ManageChannels": "Manage Channels", + "ManageEvents": "Manage Events", + "ManageGuild": "Manage Server", + "ManageGuildExpressions": "Manage Expressions", + "ManageMessages": "Manage Messages", + "ManageNicknames": "Manage Nicknames", + "ManageRoles": "Manage Roles", + "ManageThreads": "Manage Threads", + "ManageWebhooks": "Manage Webhooks", + "MentionEveryone": "Mention Everyone", + "ModerateMembers": "Time out members", + "MoveMembers": "Move Members", + "MuteMembers": "Mute Members", + "PrioritySpeaker": "Priority Speaker", + "ReadMessageHistory": "Read Message History", + "RequestToSpeak": "Request to Speak", + "SendMessages": "Send Messages", + "SendMessagesInThreads": "Send Messages in Threads", + "SendTTSMessages": "Send Text-to-speech Messages", + "SendVoiceMessages": "Send Voice Messages", + "Speak": "Speak", + "Stream": "Video", + "UseApplicationCommands": "Use Application Commands", + "UseEmbeddedActivities": "Use Activities", + "UseExternalEmojis": "Use External Emojis", + "UseExternalSounds": "Use External Sounds", + "UseExternalStickers": "Use External Stickers", + "UseSoundboard": "Use Soundboard", + "UseVAD": "Use Voice Activity", + "ViewAuditLog": "View Audit Log", + "ViewChannel": "View Channels", + "ViewCreatorMonetizationAnalytics": "View Creator Monetization Analytics", + "ViewGuildInsights": "View Server Insights" } diff --git a/src/lib/database/entities/ModerationEntity.ts b/src/lib/database/entities/ModerationEntity.ts index c03638748d1..8cdfca0ebb1 100644 --- a/src/lib/database/entities/ModerationEntity.ts +++ b/src/lib/database/entities/ModerationEntity.ts @@ -3,7 +3,7 @@ import { readSettings } from '#lib/database/settings'; import { kBigIntTransformer } from '#lib/database/utils/Transformers'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { ModerationManager, ModerationManagerUpdateData } from '#lib/moderation'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { minutes, years } from '#utils/common'; import { TypeBits, diff --git a/src/lib/database/entities/ScheduleEntity.ts b/src/lib/database/entities/ScheduleEntity.ts index 63b83885b26..e01320fb641 100644 --- a/src/lib/database/entities/ScheduleEntity.ts +++ b/src/lib/database/entities/ScheduleEntity.ts @@ -1,5 +1,5 @@ import type { ScheduleManager } from '#lib/structures/managers/ScheduleManager'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { container } from '@sapphire/framework'; import { Cron } from '@sapphire/time-utilities'; import { BaseEntity, Column, Entity, PrimaryGeneratedColumn, type ValueTransformer } from 'typeorm'; diff --git a/src/lib/games/base/BaseReactionController.ts b/src/lib/games/base/BaseReactionController.ts index 354971b4935..d6c2da60dc4 100644 --- a/src/lib/games/base/BaseReactionController.ts +++ b/src/lib/games/base/BaseReactionController.ts @@ -1,7 +1,7 @@ import { api } from '#lib/discord/Api'; import { BaseController } from '#lib/games/base/BaseController'; import type { BaseReactionGame } from '#lib/games/base/BaseReactionGame'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import type { LLRCData } from '#utils/LongLivingReactionCollector'; import { getEmojiString } from '#utils/functions'; import { cast } from '#utils/util'; diff --git a/src/lib/games/base/BaseReactionGame.ts b/src/lib/games/base/BaseReactionGame.ts index 2decb86d72f..f76b9bc941e 100644 --- a/src/lib/games/base/BaseReactionGame.ts +++ b/src/lib/games/base/BaseReactionGame.ts @@ -1,7 +1,7 @@ import type { BaseController } from '#lib/games/base/BaseController'; import { BaseGame } from '#lib/games/base/BaseGame'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { LongLivingReactionCollector } from '#utils/LongLivingReactionCollector'; import { sendLoadingMessage } from '#utils/util'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/lib/moderation/structures/ModerationCommand.ts b/src/lib/moderation/structures/ModerationCommand.ts index 17d6ce616e8..aae64674474 100644 --- a/src/lib/moderation/structures/ModerationCommand.ts +++ b/src/lib/moderation/structures/ModerationCommand.ts @@ -1,8 +1,7 @@ import { GuildSettings, ModerationEntity, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures/commands/SkyraCommand'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { floatPromise, seconds, years } from '#utils/common'; import { deleteMessage, isGuildOwner } from '#utils/functions'; import type { ModerationActionsSendOptions } from '#utils/Security/ModerationActions'; diff --git a/src/lib/moderation/structures/ModerationMessageListener.ts b/src/lib/moderation/structures/ModerationMessageListener.ts index 430f91ddb92..27b1ef153bc 100644 --- a/src/lib/moderation/structures/ModerationMessageListener.ts +++ b/src/lib/moderation/structures/ModerationMessageListener.ts @@ -1,8 +1,7 @@ import { GuildEntity, GuildSettings, readSettings, type AdderKey, type GuildSettingsOfType } from '#lib/database'; import type { AdderError } from '#lib/database/utils/Adder'; import { SelfModeratorBitField, SelfModeratorHardActionFlags } from '#lib/moderation/structures/SelfModeratorBitField'; -import type { CustomFunctionGet, CustomGet, GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type CustomFunctionGet, type CustomGet, type GuildMessage } from '#lib/types'; import { floatPromise, seconds } from '#utils/common'; import { getModeration, getSecurity, isModerator } from '#utils/functions'; import { canSendMessages, type GuildTextBasedChannelTypes } from '@sapphire/discord.js-utilities'; diff --git a/src/lib/moderation/structures/SelfModerationCommand.ts b/src/lib/moderation/structures/SelfModerationCommand.ts index 2e5d72314e8..073c61061e4 100644 --- a/src/lib/moderation/structures/SelfModerationCommand.ts +++ b/src/lib/moderation/structures/SelfModerationCommand.ts @@ -2,8 +2,7 @@ import { configurableKeys, readSettings, writeSettings, type AdderKey, type Guil import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SelfModeratorBitField, SelfModeratorHardActionFlags } from '#lib/moderation/structures/SelfModeratorBitField'; import { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { CommandOptionsRunTypeEnum } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; import { codeBlock } from '@sapphire/utilities'; diff --git a/src/lib/structures/SettingsMenu.ts b/src/lib/structures/SettingsMenu.ts index 3972cc12623..9824494427e 100644 --- a/src/lib/structures/SettingsMenu.ts +++ b/src/lib/structures/SettingsMenu.ts @@ -1,10 +1,8 @@ import { configurableGroups, isSchemaGroup, readSettings, remove, SchemaGroup, SchemaKey, set, writeSettings } from '#lib/database/settings'; import { api } from '#lib/discord/Api'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { SkyraArgs } from '#lib/structures/commands/SkyraArgs'; -import type { SkyraCommand } from '#lib/structures/commands/SkyraCommand'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { SkyraArgs, type SkyraCommand } from '#lib/structures'; +import { Events, type GuildMessage } from '#lib/types'; import { floatPromise, minutes } from '#utils/common'; import { ZeroWidthSpace } from '#utils/constants'; import { deleteMessage } from '#utils/functions'; diff --git a/src/lib/structures/commands/ChannelConfigurationCommand.ts b/src/lib/structures/commands/ChannelConfigurationCommand.ts index 2e2688ce48a..85cedc8e993 100644 --- a/src/lib/structures/commands/ChannelConfigurationCommand.ts +++ b/src/lib/structures/commands/ChannelConfigurationCommand.ts @@ -2,8 +2,7 @@ import type { GuildSettingsOfType } from '#lib/database'; import { writeSettings } from '#lib/database/settings'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { SkyraCommand } from '#lib/structures/commands/SkyraCommand'; -import type { CustomFunctionGet, GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type CustomFunctionGet, type GuildMessage } from '#lib/types'; import { assertNonThread } from '#utils/functions'; import { Args, Argument, CommandOptionsRunTypeEnum, container } from '@sapphire/framework'; import { send } from '@sapphire/plugin-editable-commands'; diff --git a/src/lib/structures/commands/SkyraSubcommand.ts b/src/lib/structures/commands/SkyraSubcommand.ts index 15747acc6e8..d3d4c2795e8 100644 --- a/src/lib/structures/commands/SkyraSubcommand.ts +++ b/src/lib/structures/commands/SkyraSubcommand.ts @@ -8,8 +8,7 @@ import { implementSkyraCommandPreParse, type ExtendOptions } from '#lib/structures/commands/base/BaseSkyraCommandUtilities'; -import type { CustomGet } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type CustomGet } from '#lib/types'; import { UserError, type MessageCommand, type PieceContext } from '@sapphire/framework'; import { Subcommand } from '@sapphire/plugin-subcommands'; import type { Message } from 'discord.js'; diff --git a/src/lib/structures/preconditions/PermissionsPrecondition.ts b/src/lib/structures/preconditions/PermissionsPrecondition.ts index bcd236cd25d..38f93ccf426 100644 --- a/src/lib/structures/preconditions/PermissionsPrecondition.ts +++ b/src/lib/structures/preconditions/PermissionsPrecondition.ts @@ -1,8 +1,7 @@ import { readSettings } from '#lib/database/settings'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { SkyraCommand } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels, type GuildMessage } from '#lib/types'; import { isAdmin, isGuildOwner } from '#utils/functions'; import { Identifiers, Precondition, type PieceContext, type PreconditionOptions } from '@sapphire/framework'; diff --git a/src/lib/types/Augments.d.ts b/src/lib/types/Augments.d.ts index 8b2d7cd6986..39cbc72839b 100644 --- a/src/lib/types/Augments.d.ts +++ b/src/lib/types/Augments.d.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -import type { DbSet, GuildEntity, GuildSettingsOfType, SettingsManager } from '#lib/database'; +import type { DbSet, GuildSettingsOfType, SettingsManager } from '#lib/database'; import type { GuildMemberFetchQueue } from '#lib/discord/GuildMemberFetchQueue'; import type { WorkerManager } from '#lib/moderation/workers/WorkerManager'; import type { AnalyticsData, InviteCodeValidEntry, InviteStore, ScheduleManager, SkyraCommand } from '#lib/structures'; +import type { Events } from '#lib/types'; import type { TwitchStreamStatus } from '#lib/types/AnalyticsSchema'; -import type { Events } from '#lib/types/Enums'; import type { TaskErrorPayload } from '#lib/types/Internals'; import type { TwitchEventSubEvent, TwitchEventSubOnlineEvent } from '#lib/types/Twitch'; import type { CustomFunctionGet, CustomGet } from '#lib/types/Utils'; @@ -12,9 +12,9 @@ import type { LLRCData, LongLivingReactionCollector } from '#utils/LongLivingRea import type { Twitch } from '#utils/Notifications/Twitch'; import type { EmojiObject } from '#utils/functions'; import type { Piece, Store } from '@sapphire/framework'; -import type { Nullish, PickByValue } from '@sapphire/utilities'; +import type { Nullish } from '@sapphire/utilities'; import type { ArrayString, BooleanString, IntegerString } from '@skyra/env-utilities'; -import type { EmbedBuilder, Guild, GuildChannel, Message, NewsChannel, Role, Snowflake, TextChannel, User } from 'discord.js'; +import type { EmbedBuilder, Guild, GuildChannel, NewsChannel, Role, Snowflake, TextChannel, User } from 'discord.js'; declare module 'discord.js' { interface Client { diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index ea82ce34efc..1edd9f1af79 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -1,3 +1,4 @@ +export * from '#lib/types/AnalyticsSchema'; export * from '#lib/types/Discord'; export * from '#lib/types/Enums'; export * from '#lib/types/Internals'; diff --git a/src/lib/util/bits.ts b/src/lib/util/bits.ts index 5a1cb470482..c83afd4904a 100644 --- a/src/lib/util/bits.ts +++ b/src/lib/util/bits.ts @@ -1,12 +1,16 @@ +import { omit } from '#utils/common'; import { BitField, enumToObject } from '@sapphire/bitfield'; +import { objectEntries } from '@sapphire/utilities'; import { GuildSystemChannelFlags, PermissionFlagsBits } from 'discord-api-types/v10'; -export const PermissionsBits = new BitField(PermissionFlagsBits); +export const PermissionsBits = new BitField(omit(PermissionFlagsBits, 'ManageEmojisAndStickers')); +export const PermissionsBitsList = objectEntries(PermissionsBits.flags); export function toPermissionsArray(bits: bigint) { return PermissionsBits.toArray(bits); } export const SystemChannelFlag = new BitField(enumToObject(GuildSystemChannelFlags)); +export const SystemChannelFlagList = objectEntries(SystemChannelFlag.flags); export function toChannelsArray(bits: number) { return SystemChannelFlag.toArray(bits); } diff --git a/src/lib/util/common/index.ts b/src/lib/util/common/index.ts index b6594290487..f6604f717eb 100644 --- a/src/lib/util/common/index.ts +++ b/src/lib/util/common/index.ts @@ -1,5 +1,6 @@ export * from '#utils/common/comparators'; export * from '#utils/common/guards'; export * from '#utils/common/iterators'; +export * from '#utils/common/objects'; export * from '#utils/common/promises'; export * from '#utils/common/times'; diff --git a/src/lib/util/common/objects.ts b/src/lib/util/common/objects.ts new file mode 100644 index 00000000000..7442366173c --- /dev/null +++ b/src/lib/util/common/objects.ts @@ -0,0 +1,5 @@ +export function omit(object: T, ...keys: readonly K[]): Omit { + const clone = { ...object }; + for (const key of keys) delete clone[key]; + return clone; +} diff --git a/src/listeners/analytics/analyticsSync.ts b/src/listeners/analytics/analyticsSync.ts index fd4ac2d0a5a..411e059f4f0 100644 --- a/src/listeners/analytics/analyticsSync.ts +++ b/src/listeners/analytics/analyticsSync.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, Points, Tags } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, Events, Points, Tags } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/analytics/commandUsageAnalytics.ts b/src/listeners/analytics/commandUsageAnalytics.ts index 3996ae06f4e..8a9d3b0314b 100644 --- a/src/listeners/analytics/commandUsageAnalytics.ts +++ b/src/listeners/analytics/commandUsageAnalytics.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, CommandCategoryTypes, Points, Tags } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, CommandCategoryTypes, Events, Points, Tags } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/analytics/guilds/guildCreateAnalytics.ts b/src/listeners/analytics/guilds/guildCreateAnalytics.ts index 50631e598c7..c80bb092ec2 100644 --- a/src/listeners/analytics/guilds/guildCreateAnalytics.ts +++ b/src/listeners/analytics/guilds/guildCreateAnalytics.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, Points, Tags } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, Events, Points, Tags } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; import type { Guild } from 'discord.js'; diff --git a/src/listeners/analytics/guilds/guildDeleteAnalytics.ts b/src/listeners/analytics/guilds/guildDeleteAnalytics.ts index b3fafd67520..13fc0235d6b 100644 --- a/src/listeners/analytics/guilds/guildDeleteAnalytics.ts +++ b/src/listeners/analytics/guilds/guildDeleteAnalytics.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, Points, Tags } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, Events, Points, Tags } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; import type { Guild } from 'discord.js'; diff --git a/src/listeners/analytics/messages/messageAnalytics.ts b/src/listeners/analytics/messages/messageAnalytics.ts index 978b20ef847..ddbc841bbb7 100644 --- a/src/listeners/analytics/messages/messageAnalytics.ts +++ b/src/listeners/analytics/messages/messageAnalytics.ts @@ -1,5 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; @ApplyOptions({ event: Events.MessageCreate }) diff --git a/src/listeners/analytics/resourceAnalyticsSync.ts b/src/listeners/analytics/resourceAnalyticsSync.ts index 339a3bddd11..89868ea01b8 100644 --- a/src/listeners/analytics/resourceAnalyticsSync.ts +++ b/src/listeners/analytics/resourceAnalyticsSync.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, Points, Tags } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, Events, Points, Tags } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; import { cpus } from 'node:os'; diff --git a/src/listeners/analytics/twitchStreamHookedAnalytics.ts b/src/listeners/analytics/twitchStreamHookedAnalytics.ts index 3461d2cb31b..2c56432e49e 100644 --- a/src/listeners/analytics/twitchStreamHookedAnalytics.ts +++ b/src/listeners/analytics/twitchStreamHookedAnalytics.ts @@ -1,6 +1,5 @@ import { AnalyticsListener } from '#lib/structures'; -import { Actions, Points, Tags, TwitchStreamStatus } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Actions, Events, Points, Tags, TwitchStreamStatus } from '#lib/types'; import { Point } from '@influxdata/influxdb-client'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/commands/messageCommandError.ts b/src/listeners/commands/messageCommandError.ts index d37f8c499a4..2d4d3cd58f2 100644 --- a/src/listeners/commands/messageCommandError.ts +++ b/src/listeners/commands/messageCommandError.ts @@ -6,7 +6,7 @@ import { Colors, ZeroWidthSpace, rootFolder } from '#utils/constants'; import { sendTemporaryMessage } from '#utils/functions'; import { Args, ArgumentError, Command, Events, Listener, UserError, type MessageCommandErrorPayload } from '@sapphire/framework'; import { codeBlock, cutText, type NonNullObject } from '@sapphire/utilities'; -import { captureException } from '@sentry/core'; +import { captureException } from '@sentry/node'; import { envIsDefined } from '@skyra/env-utilities'; import { RESTJSONErrorCodes, Routes } from 'discord-api-types/v10'; import { DiscordAPIError, EmbedBuilder, HTTPError, Message } from 'discord.js'; diff --git a/src/listeners/errors/taskError.ts b/src/listeners/errors/taskError.ts index e7043120ba2..d5b5a91b76d 100644 --- a/src/listeners/errors/taskError.ts +++ b/src/listeners/errors/taskError.ts @@ -1,5 +1,4 @@ -import type { TaskErrorPayload } from '#lib/types'; -import type { Events } from '#lib/types/Enums'; +import type { Events, TaskErrorPayload } from '#lib/types'; import { Listener } from '@sapphire/framework'; export class UserListener extends Listener { diff --git a/src/listeners/errors/taskErrorSentry.ts b/src/listeners/errors/taskErrorSentry.ts index adbf519518a..b7134ea077b 100644 --- a/src/listeners/errors/taskErrorSentry.ts +++ b/src/listeners/errors/taskErrorSentry.ts @@ -1,8 +1,7 @@ -import type { TaskErrorPayload } from '#lib/types'; -import type { Events } from '#lib/types/Enums'; +import type { Events, TaskErrorPayload } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; -import { captureException } from '@sentry/hub'; +import { captureException } from '@sentry/node'; import { envIsDefined } from '@skyra/env-utilities'; @ApplyOptions({ enabled: envIsDefined('SENTRY_URL') }) diff --git a/src/listeners/guilds/members/guildMemberAdd.ts b/src/listeners/guilds/members/guildMemberAdd.ts index df3076ec37d..801b83ccc09 100644 --- a/src/listeners/guilds/members/guildMemberAdd.ts +++ b/src/listeners/guilds/members/guildMemberAdd.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings, writeSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { floatPromise } from '#utils/common'; import { Colors } from '#utils/constants'; import { getStickyRoles } from '#utils/functions'; diff --git a/src/listeners/guilds/members/guildMemberUpdateNicknameNotify.ts b/src/listeners/guilds/members/guildMemberUpdateNicknameNotify.ts index 60af13670d3..458f323af6b 100644 --- a/src/listeners/guilds/members/guildMemberUpdateNicknameNotify.ts +++ b/src/listeners/guilds/members/guildMemberUpdateNicknameNotify.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Colors } from '#utils/constants'; import { getFullEmbedAuthor } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/guilds/members/guildMemberUpdateRolesNotify.ts b/src/listeners/guilds/members/guildMemberUpdateRolesNotify.ts index 8812d9ecfba..f4d78fc040f 100644 --- a/src/listeners/guilds/members/guildMemberUpdateRolesNotify.ts +++ b/src/listeners/guilds/members/guildMemberUpdateRolesNotify.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Colors } from '#utils/constants'; import { getFullEmbedAuthor } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts b/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts index bbef51c4515..ba368b7fc4d 100644 --- a/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts +++ b/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts @@ -1,5 +1,5 @@ import { GuildSettings, readSettings, writeSettings } from '#lib/database'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; import type { GuildMember } from 'discord.js'; diff --git a/src/listeners/guilds/members/notMutedMemberAddNotify.ts b/src/listeners/guilds/members/notMutedMemberAddNotify.ts index dc5cf1df93a..f07ec2f0cd1 100644 --- a/src/listeners/guilds/members/notMutedMemberAddNotify.ts +++ b/src/listeners/guilds/members/notMutedMemberAddNotify.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Colors } from '#utils/constants'; import { getFullEmbedAuthor } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/guilds/members/rawGuildMemberRemove.ts b/src/listeners/guilds/members/rawGuildMemberRemove.ts index 2a018d1ec18..dd3e0eee3d2 100644 --- a/src/listeners/guilds/members/rawGuildMemberRemove.ts +++ b/src/listeners/guilds/members/rawGuildMemberRemove.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; import { GatewayDispatchEvents, type GatewayGuildMemberRemoveDispatch } from 'discord-api-types/v10'; diff --git a/src/listeners/guilds/members/rawMemberRemoveNotify.ts b/src/listeners/guilds/members/rawMemberRemoveNotify.ts index 3fb8385917f..89c527fca87 100644 --- a/src/listeners/guilds/members/rawMemberRemoveNotify.ts +++ b/src/listeners/guilds/members/rawMemberRemoveNotify.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Colors } from '#utils/constants'; import { getModeration } from '#utils/functions'; import { TypeCodes } from '#utils/moderationConstants'; diff --git a/src/listeners/guilds/messages/guildUserMessageImageNotify.ts b/src/listeners/guilds/messages/guildUserMessageImageNotify.ts index 3c1e042dd5a..b4730ef7235 100644 --- a/src/listeners/guilds/messages/guildUserMessageImageNotify.ts +++ b/src/listeners/guilds/messages/guildUserMessageImageNotify.ts @@ -1,7 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { Colors } from '#utils/constants'; import { getFullEmbedAuthor } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/mentionSpamExceeded.ts b/src/listeners/mentionSpamExceeded.ts index 846d6f0d18d..32a658acd95 100644 --- a/src/listeners/mentionSpamExceeded.ts +++ b/src/listeners/mentionSpamExceeded.ts @@ -1,7 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { getModeration } from '#utils/functions'; import { TypeCodes } from '#utils/moderationConstants'; import { getTag } from '#utils/util'; diff --git a/src/listeners/messages/guildMessageDeleteNotify.ts b/src/listeners/messages/guildMessageDeleteNotify.ts index eb16bba88bb..3ffae1dae49 100644 --- a/src/listeners/messages/guildMessageDeleteNotify.ts +++ b/src/listeners/messages/guildMessageDeleteNotify.ts @@ -1,7 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { Colors } from '#utils/constants'; import { getContent, getFullEmbedAuthor, getImage } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/messages/guildMessageDeleteRichDisplay.ts b/src/listeners/messages/guildMessageDeleteRichDisplay.ts index 5c782323c80..56f5c6c0b74 100644 --- a/src/listeners/messages/guildMessageDeleteRichDisplay.ts +++ b/src/listeners/messages/guildMessageDeleteRichDisplay.ts @@ -1,6 +1,5 @@ import { SkyraLazyPaginatedMessage, SkyraPaginatedMessage } from '#lib/structures'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/messages/guildMessageDeleteSnipe.ts b/src/listeners/messages/guildMessageDeleteSnipe.ts index 75f9451b8a3..da60bbd5105 100644 --- a/src/listeners/messages/guildMessageDeleteSnipe.ts +++ b/src/listeners/messages/guildMessageDeleteSnipe.ts @@ -1,5 +1,4 @@ -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { setSnipedMessage } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/messages/guildUserMessageMediaOnly.ts b/src/listeners/messages/guildUserMessageMediaOnly.ts index 6ff134cfede..227589cbec2 100644 --- a/src/listeners/messages/guildUserMessageMediaOnly.ts +++ b/src/listeners/messages/guildUserMessageMediaOnly.ts @@ -1,6 +1,5 @@ import { GuildSettings, readSettings } from '#lib/database'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { deleteMessage, isModerator } from '#utils/functions'; import { MEDIA_EXTENSION } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/messages/messageCreate.ts b/src/listeners/messages/messageCreate.ts index e4c2cebca8a..382d8099d34 100644 --- a/src/listeners/messages/messageCreate.ts +++ b/src/listeners/messages/messageCreate.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Listener } from '@sapphire/framework'; import type { Message } from 'discord.js'; diff --git a/src/listeners/messages/messageDelete.ts b/src/listeners/messages/messageDelete.ts index 693add809f9..41d68aeb158 100644 --- a/src/listeners/messages/messageDelete.ts +++ b/src/listeners/messages/messageDelete.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { isGuildMessage } from '#utils/common'; import { Listener } from '@sapphire/framework'; import type { Message } from 'discord.js'; diff --git a/src/listeners/messages/messageDeleteBulkRemoveResponses.ts b/src/listeners/messages/messageDeleteBulkRemoveResponses.ts index 64ba2b6c701..fd65b1c5598 100644 --- a/src/listeners/messages/messageDeleteBulkRemoveResponses.ts +++ b/src/listeners/messages/messageDeleteBulkRemoveResponses.ts @@ -1,6 +1,5 @@ import { CommandMatcher, GuildSettings, readSettings } from '#lib/database'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { deleteMessage, getCommand } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/messages/messageDeleteRemoveResponses.ts b/src/listeners/messages/messageDeleteRemoveResponses.ts index 2d0d309ba6a..0e0ec84edb9 100644 --- a/src/listeners/messages/messageDeleteRemoveResponses.ts +++ b/src/listeners/messages/messageDeleteRemoveResponses.ts @@ -1,6 +1,5 @@ import { CommandMatcher, GuildSettings, readSettings } from '#lib/database'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { deleteMessage, getCommand } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/messages/messageUpdateNotify.ts b/src/listeners/messages/messageUpdateNotify.ts index 550f0994ddc..b4d86500ba2 100644 --- a/src/listeners/messages/messageUpdateNotify.ts +++ b/src/listeners/messages/messageUpdateNotify.ts @@ -1,7 +1,7 @@ import { GuildSettings, readSettings } from '#lib/database'; import { SkyraEmbed } from '#lib/discord'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { isGuildMessage } from '#utils/common'; import { Colors } from '#utils/constants'; import { escapeMarkdown } from '#utils/External/escapeMarkdown'; diff --git a/src/listeners/messages/rawMessageDelete.ts b/src/listeners/messages/rawMessageDelete.ts index 8c5524ce8c6..d6e77825b42 100644 --- a/src/listeners/messages/rawMessageDelete.ts +++ b/src/listeners/messages/rawMessageDelete.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; import { GatewayDispatchEvents, type GatewayMessageDeleteDispatch } from 'discord-api-types/v10'; diff --git a/src/listeners/messages/rawMessageDeleteBulk.ts b/src/listeners/messages/rawMessageDeleteBulk.ts index 4255df445e0..f8b47641664 100644 --- a/src/listeners/messages/rawMessageDeleteBulk.ts +++ b/src/listeners/messages/rawMessageDeleteBulk.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; import { GatewayDispatchEvents, type GatewayMessageDeleteBulkDispatch } from 'discord-api-types/v10'; diff --git a/src/listeners/messages/userMessageGuildHandler.ts b/src/listeners/messages/userMessageGuildHandler.ts index 4026f51f263..96058383a15 100644 --- a/src/listeners/messages/userMessageGuildHandler.ts +++ b/src/listeners/messages/userMessageGuildHandler.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; import type { Message } from 'discord.js'; diff --git a/src/listeners/moderation/messages/guildUserMessageMentionsHandler.ts b/src/listeners/moderation/messages/guildUserMessageMentionsHandler.ts index e4e1636c2db..f5421e0cbfc 100644 --- a/src/listeners/moderation/messages/guildUserMessageMentionsHandler.ts +++ b/src/listeners/moderation/messages/guildUserMessageMentionsHandler.ts @@ -1,6 +1,5 @@ import { GuildSettings, readSettings } from '#lib/database'; -import type { GuildMessage } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type GuildMessage } from '#lib/types'; import { isModerator } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/reactions/rawMessageReactionAdd.ts b/src/listeners/reactions/rawMessageReactionAdd.ts index 00a0509427e..0b044b2e519 100644 --- a/src/listeners/reactions/rawMessageReactionAdd.ts +++ b/src/listeners/reactions/rawMessageReactionAdd.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { getEmojiString } from '#utils/functions'; import type { LLRCData } from '#utils/LongLivingReactionCollector'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/reactions/rawMessageReactionRemove.ts b/src/listeners/reactions/rawMessageReactionRemove.ts index 97cbcefc707..681ff1b3a11 100644 --- a/src/listeners/reactions/rawMessageReactionRemove.ts +++ b/src/listeners/reactions/rawMessageReactionRemove.ts @@ -1,4 +1,4 @@ -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { canReadMessages, isGuildBasedChannel } from '@sapphire/discord.js-utilities'; import { Listener } from '@sapphire/framework'; diff --git a/src/listeners/reactions/rawReactionAddBlockList.ts b/src/listeners/reactions/rawReactionAddBlockList.ts index 5594c6370b3..16b05a213f9 100644 --- a/src/listeners/reactions/rawReactionAddBlockList.ts +++ b/src/listeners/reactions/rawReactionAddBlockList.ts @@ -2,7 +2,7 @@ import { GuildSettings, readSettings, type GuildSettingsOfType } from '#lib/data import { api } from '#lib/discord/Api'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import { ModerationListener, SelfModeratorBitField, type HardPunishment } from '#lib/moderation'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { floatPromise, seconds } from '#utils/common'; import { Colors } from '#utils/constants'; import { deleteMessage, getEmojiReactionFormat, getEncodedTwemoji, getTwemojiUrl, type SerializedEmoji } from '#utils/functions'; diff --git a/src/listeners/reactions/rawReactionAddNotify.ts b/src/listeners/reactions/rawReactionAddNotify.ts index 4672f946e38..bf8e06f28d9 100644 --- a/src/listeners/reactions/rawReactionAddNotify.ts +++ b/src/listeners/reactions/rawReactionAddNotify.ts @@ -1,7 +1,7 @@ import { GuildSettings, readSettings } from '#lib/database'; import { api } from '#lib/discord/Api'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { Colors } from '#utils/constants'; import { getEmojiId, getEmojiReactionFormat, getEncodedTwemoji, getTwemojiUrl, type SerializedEmoji } from '#utils/functions'; import type { LLRCData } from '#utils/LongLivingReactionCollector'; diff --git a/src/listeners/reactions/rawReactionAddRole.ts b/src/listeners/reactions/rawReactionAddRole.ts index e3ad1a0036b..0477b7bd81f 100644 --- a/src/listeners/reactions/rawReactionAddRole.ts +++ b/src/listeners/reactions/rawReactionAddRole.ts @@ -1,6 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { resolveEmojiId, sendTemporaryMessage, type SerializedEmoji } from '#utils/functions'; import type { LLRCData } from '#utils/LongLivingReactionCollector'; import { ApplyOptions } from '@sapphire/decorators'; diff --git a/src/listeners/reactions/rawReactionRemoveRole.ts b/src/listeners/reactions/rawReactionRemoveRole.ts index 7ee44aace92..5bdd15fa375 100644 --- a/src/listeners/reactions/rawReactionRemoveRole.ts +++ b/src/listeners/reactions/rawReactionRemoveRole.ts @@ -1,5 +1,5 @@ import { GuildSettings, readSettings } from '#lib/database'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { resolveEmojiId } from '#utils/functions'; import { ApplyOptions } from '@sapphire/decorators'; import { isGuildBasedChannel } from '@sapphire/discord.js-utilities'; diff --git a/src/listeners/ready.ts b/src/listeners/ready.ts index 8b4bcab3ca1..37d050e41e6 100644 --- a/src/listeners/ready.ts +++ b/src/listeners/ready.ts @@ -1,4 +1,4 @@ -import { Events, Schedules } from '#lib/types/Enums'; +import { Events, Schedules } from '#lib/types'; import { ApplyOptions } from '@sapphire/decorators'; import { Listener, Piece, Store } from '@sapphire/framework'; import type { TFunction } from '@sapphire/plugin-i18next'; diff --git a/src/listeners/twitch/twitchStreamOffline.ts b/src/listeners/twitch/twitchStreamOffline.ts index 625239d3685..7e7951578a1 100644 --- a/src/listeners/twitch/twitchStreamOffline.ts +++ b/src/listeners/twitch/twitchStreamOffline.ts @@ -1,6 +1,5 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; -import { TwitchEventSubTypes, type TwitchEventSubEvent } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, TwitchEventSubTypes, type TwitchEventSubEvent } from '#lib/types'; import { floatPromise } from '#utils/common'; import { extractDetailedMentions } from '#utils/util'; import { TimestampStyles, time } from '@discordjs/builders'; diff --git a/src/listeners/twitch/twitchStreamOnline.ts b/src/listeners/twitch/twitchStreamOnline.ts index 2df091e31f2..c0adda922c1 100644 --- a/src/listeners/twitch/twitchStreamOnline.ts +++ b/src/listeners/twitch/twitchStreamOnline.ts @@ -1,7 +1,5 @@ import { LanguageKeys } from '#lib/i18n/languageKeys'; -import type { TwitchEventSubOnlineEvent, TwitchHelixStreamsResult, TwitchOnlineEmbedData } from '#lib/types'; -import { TwitchEventSubTypes } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, TwitchEventSubTypes, type TwitchEventSubOnlineEvent, type TwitchHelixStreamsResult, type TwitchOnlineEmbedData } from '#lib/types'; import { escapeMarkdown } from '#utils/External/escapeMarkdown'; import { floatPromise } from '#utils/common'; import { extractDetailedMentions } from '#utils/util'; diff --git a/src/listeners/userUpdate.ts b/src/listeners/userUpdate.ts index d6d1eec1816..b58a8f8757b 100644 --- a/src/listeners/userUpdate.ts +++ b/src/listeners/userUpdate.ts @@ -1,7 +1,6 @@ import { GuildSettings, readSettings } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; -import type { CustomGet } from '#lib/types'; -import { Events } from '#lib/types/Enums'; +import { Events, type CustomGet } from '#lib/types'; import { filter, map } from '#utils/common'; import { Colors } from '#utils/constants'; import { getFullEmbedAuthor } from '#utils/util'; diff --git a/src/routes/twitch/twitchEventSubVerify.ts b/src/routes/twitch/twitchEventSubVerify.ts index da9de9c9472..a736cd76ad9 100644 --- a/src/routes/twitch/twitchEventSubVerify.ts +++ b/src/routes/twitch/twitchEventSubVerify.ts @@ -1,6 +1,4 @@ -import { TwitchEventSubTypes, type TwitchEventSubVerificationMessage } from '#lib/types'; -import { TwitchStreamStatus } from '#lib/types/AnalyticsSchema'; -import { Events } from '#lib/types/Enums'; +import { Events, TwitchEventSubTypes, TwitchStreamStatus, type TwitchEventSubVerificationMessage } from '#lib/types'; import { cast } from '#utils/util'; import { ApplyOptions } from '@sapphire/decorators'; import { Route, methods, type ApiRequest, type ApiResponse } from '@sapphire/plugin-api'; diff --git a/src/serializers/permissionnode.ts b/src/serializers/permissionnode.ts index 9761d58d356..6a3eb1ac7ab 100644 --- a/src/serializers/permissionnode.ts +++ b/src/serializers/permissionnode.ts @@ -1,7 +1,7 @@ import { CommandMatcher, Serializer, type PermissionsNode } from '#lib/database'; import { LanguageKeys } from '#lib/i18n/languageKeys'; import type { SkyraCommand } from '#lib/structures'; -import { PermissionLevels } from '#lib/types/Enums'; +import { PermissionLevels } from '#lib/types'; import type { CommandStore } from '@sapphire/framework'; import { isObject } from '@sapphire/utilities'; import type { GuildMember, Role } from 'discord.js'; diff --git a/src/tasks/poststats.ts b/src/tasks/poststats.ts index f55fb3e3e06..c72ecd2041e 100644 --- a/src/tasks/poststats.ts +++ b/src/tasks/poststats.ts @@ -1,5 +1,5 @@ import { ResponseType, Task, type PartialResponseValue } from '#lib/database'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; import { FetchResultTypes, QueryError, fetch } from '@sapphire/fetch'; import { MimeTypes } from '@sapphire/plugin-api'; import { blueBright, green, red } from 'colorette'; diff --git a/src/tasks/syncResourceAnalytics.ts b/src/tasks/syncResourceAnalytics.ts index 79db989e86b..15f726617b8 100644 --- a/src/tasks/syncResourceAnalytics.ts +++ b/src/tasks/syncResourceAnalytics.ts @@ -1,5 +1,5 @@ import { Task } from '#lib/database'; -import { Events } from '#lib/types/Enums'; +import { Events } from '#lib/types'; export class UserTask extends Task { public run() { diff --git a/tests/lib/bits.test.ts b/tests/lib/bits.test.ts index 55b0cae69a7..7bd032f459b 100644 --- a/tests/lib/bits.test.ts +++ b/tests/lib/bits.test.ts @@ -1,4 +1,5 @@ import { toChannelsArray, toPermissionsArray } from '#utils/bits'; +import { enumToObject } from '@sapphire/bitfield'; import { GuildSystemChannelFlags, PermissionFlagsBits } from 'discord-api-types/v10'; describe('Bits', () => { @@ -9,51 +10,7 @@ describe('Bits', () => { }); test('GIVEN all permissions THEN returns an array with all the names', () => { - const value = - PermissionFlagsBits.CreateInstantInvite | - PermissionFlagsBits.KickMembers | - PermissionFlagsBits.BanMembers | - PermissionFlagsBits.Administrator | - PermissionFlagsBits.ManageChannels | - PermissionFlagsBits.ManageGuild | - PermissionFlagsBits.AddReactions | - PermissionFlagsBits.ViewAuditLog | - PermissionFlagsBits.PrioritySpeaker | - PermissionFlagsBits.Stream | - PermissionFlagsBits.ViewChannel | - PermissionFlagsBits.SendMessages | - PermissionFlagsBits.SendTTSMessages | - PermissionFlagsBits.ManageMessages | - PermissionFlagsBits.EmbedLinks | - PermissionFlagsBits.AttachFiles | - PermissionFlagsBits.ReadMessageHistory | - PermissionFlagsBits.MentionEveryone | - PermissionFlagsBits.UseExternalEmojis | - PermissionFlagsBits.ViewGuildInsights | - PermissionFlagsBits.Connect | - PermissionFlagsBits.Speak | - PermissionFlagsBits.MuteMembers | - PermissionFlagsBits.DeafenMembers | - PermissionFlagsBits.MoveMembers | - PermissionFlagsBits.UseVAD | - PermissionFlagsBits.ChangeNickname | - PermissionFlagsBits.ManageNicknames | - PermissionFlagsBits.ManageRoles | - PermissionFlagsBits.ManageWebhooks | - PermissionFlagsBits.ManageGuildExpressions | - PermissionFlagsBits.UseApplicationCommands | - PermissionFlagsBits.RequestToSpeak | - PermissionFlagsBits.ManageEvents | - PermissionFlagsBits.ManageThreads | - PermissionFlagsBits.CreatePublicThreads | - PermissionFlagsBits.CreatePrivateThreads | - PermissionFlagsBits.UseExternalStickers | - PermissionFlagsBits.SendMessagesInThreads | - PermissionFlagsBits.UseEmbeddedActivities | - PermissionFlagsBits.ModerateMembers | - PermissionFlagsBits.ViewCreatorMonetizationAnalytics | - PermissionFlagsBits.UseSoundboard | - PermissionFlagsBits.SendVoiceMessages; + const value = Object.values(PermissionFlagsBits).reduce((a, b) => a | b); expect(toPermissionsArray(value)).toStrictEqual([ 'CreateInstantInvite', 'KickMembers', @@ -85,7 +42,6 @@ describe('Bits', () => { 'ManageNicknames', 'ManageRoles', 'ManageWebhooks', - 'ManageEmojisAndStickers', 'ManageGuildExpressions', 'UseApplicationCommands', 'RequestToSpeak', @@ -99,6 +55,7 @@ describe('Bits', () => { 'ModerateMembers', 'ViewCreatorMonetizationAnalytics', 'UseSoundboard', + 'UseExternalSounds', 'SendVoiceMessages' ]); }); @@ -111,13 +68,7 @@ describe('Bits', () => { }); test('GIVEN all flags THEN returns an array with all the flags', () => { - const value = - GuildSystemChannelFlags.SuppressJoinNotifications | - GuildSystemChannelFlags.SuppressJoinNotificationReplies | - GuildSystemChannelFlags.SuppressPremiumSubscriptions | - GuildSystemChannelFlags.SuppressGuildReminderNotifications | - GuildSystemChannelFlags.SuppressRoleSubscriptionPurchaseNotifications | - GuildSystemChannelFlags.SuppressRoleSubscriptionPurchaseNotificationReplies; + const value = Object.values(enumToObject(GuildSystemChannelFlags)).reduce((a, b) => a | b); expect(toChannelsArray(value)).toStrictEqual([ 'SuppressJoinNotifications', 'SuppressPremiumSubscriptions', diff --git a/yarn.lock b/yarn.lock index 2c66b24d0c7..7fe08d70b21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1315,17 +1315,6 @@ __metadata: languageName: node linkType: hard -"@sentry/hub@npm:^7.79.0": - version: 7.79.0 - resolution: "@sentry/hub@npm:7.79.0" - dependencies: - "@sentry/core": 7.79.0 - "@sentry/types": 7.79.0 - "@sentry/utils": 7.79.0 - checksum: 22b292e8802ef535a42d22b755535fbcd028b82baa6c13a57d6cbc98c7454e4b5fd04f1023f9fc41b74b561236b3abf040cbc1f93d1ebb779e3fa1b043f52aaa - languageName: node - linkType: hard - "@sentry/integrations@npm:^7.79.0": version: 7.79.0 resolution: "@sentry/integrations@npm:7.79.0" @@ -7700,7 +7689,6 @@ __metadata: "@sapphire/time-utilities": ^1.7.10 "@sapphire/ts-config": ^5.0.0 "@sapphire/utilities": ^3.13.0 - "@sentry/hub": ^7.79.0 "@sentry/integrations": ^7.79.0 "@sentry/node": ^7.79.0 "@skyra/ai": ^1.2.0