From 217c100e49d99994421d639f4af3bd883e7fee87 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 7 Jul 2022 23:44:48 -0300 Subject: [PATCH] Refactor monorepo (#36) * feat: GuildChannel.edit * fix: fmt Co-authored-by: socram03 --- handlers/Actions.ts | 39 +++-- structures/Integration.ts | 157 +++++++++--------- structures/Invite.ts | 30 ++-- structures/Webhook.ts | 2 +- structures/channels/GuildChannel.ts | 72 +++++++- .../interactions/AutoCompleteInteraction.ts | 3 +- structures/interactions/CommandInteraction.ts | 20 ++- .../CommandInteractionOptionResolver.ts | 36 ++-- .../interactions/ModalSubmitInteraction.ts | 8 +- structures/interactions/PingInteraction.ts | 3 +- util/permissions.ts | 9 + 11 files changed, 246 insertions(+), 133 deletions(-) create mode 100644 util/permissions.ts diff --git a/handlers/Actions.ts b/handlers/Actions.ts index e64c58d..ce32b9a 100644 --- a/handlers/Actions.ts +++ b/handlers/Actions.ts @@ -11,6 +11,8 @@ import type { DiscordGuildRoleCreate, DiscordGuildRoleDelete, DiscordGuildRoleUpdate, + DiscordIntegration, + DiscordIntegrationDelete, DiscordInteraction, DiscordMemberWithUser, DiscordMessage, @@ -26,9 +28,6 @@ import type { DiscordThreadListSync, DiscordUser, DiscordWebhookUpdate, - DiscordIntegration, - DiscordIntegrationDelete - } from "../vendor/external.ts"; import type { Snowflake } from "../util/Snowflake.ts"; import type { Session } from "../session/Session.ts"; @@ -41,8 +40,8 @@ import ThreadMember from "../structures/ThreadMember.ts"; import Member from "../structures/Member.ts"; import Message from "../structures/Message.ts"; import User from "../structures/User.ts"; -import Integration from "../structures/Integration.ts" -import Guild from "../structures/guilds/Guild.ts"; +import Integration from "../structures/Integration.ts"; +import Guild from "../structures/guilds/Guild.ts"; import InteractionFactory from "../structures/interactions/InteractionFactory.ts"; export type RawHandler = (...args: [Session, number, T]) => void; @@ -186,16 +185,28 @@ export const WEBHOOKS_UPDATE: RawHandler = (session, _shar session.emit("webhooksUpdate", { guildId: webhook.guild_id, channelId: webhook.channel_id }); }; -export const INTEGRATION_CREATE: RawHandler = (session, _shardId, payload) => { +export const INTEGRATION_CREATE: RawHandler = ( + session, + _shardId, + payload, +) => { session.emit("integrationCreate", new Integration(session, payload)); }; -export const INTEGRATION_UPDATE: RawHandler = (session, _shardId, payload) => { +export const INTEGRATION_UPDATE: RawHandler = ( + session, + _shardId, + payload, +) => { session.emit("integrationCreate", new Integration(session, payload)); }; export const INTEGRATION_DELETE: RawHandler = (session, _shardId, payload) => { - session.emit("integrationDelete", { id: payload.id, guildId: payload.guild_id, applicationId: payload.application_id }); + session.emit("integrationDelete", { + id: payload.id, + guildId: payload.guild_id, + applicationId: payload.application_id, + }); }; export const MESSAGE_REACTION_ADD: RawHandler = (session, _shardId, reaction) => { @@ -206,11 +217,19 @@ export const MESSAGE_REACTION_REMOVE: RawHandler = session.emit("messageReactionRemove", null); }; -export const MESSAGE_REACTION_REMOVE_ALL: RawHandler = (session, _shardId, reaction) => { +export const MESSAGE_REACTION_REMOVE_ALL: RawHandler = ( + session, + _shardId, + reaction, +) => { session.emit("messageReactionRemoveAll", null); }; -export const MESSAGE_REACTION_REMOVE_EMOJI: RawHandler = (session, _shardId, reaction) => { +export const MESSAGE_REACTION_REMOVE_EMOJI: RawHandler = ( + session, + _shardId, + reaction, +) => { session.emit("messageReactionRemoveEmoji", null); }; diff --git a/structures/Integration.ts b/structures/Integration.ts index 9a3a90c..673e48a 100644 --- a/structures/Integration.ts +++ b/structures/Integration.ts @@ -1,80 +1,77 @@ -import type { Model } from "./Base.ts"; -import type { Snowflake } from "../util/Snowflake.ts"; -import type { Session } from "../session/Session.ts"; -import type { - DiscordIntegration, - IntegrationExpireBehaviors -} from "../vendor/external.ts"; -import User from "./User.ts" - -export interface IntegrationAccount { - id: Snowflake; - name: string; -} - -export interface IntegrationApplication { - id: Snowflake; - name: string; - icon?: string; - description: string; - bot?: User; -} - -export class Integration implements Model { - constructor(session: Session, data: DiscordIntegration & { guild_id?: Snowflake }) { - this.id = data.id; - this.session = session; - - data.guild_id ? this.guildId = data.guild_id : null; - - this.name = data.name; - this.type = data.type; - this.enabled = !!data.enabled; - this.syncing = !!data.syncing; - this.roleId = data.role_id; - this.enableEmoticons = !!data.enable_emoticons; - this.expireBehavior = data.expire_behavior; - this.expireGracePeriod = data.expire_grace_period; - this.syncedAt = data.synced_at; - this.subscriberCount = data.subscriber_count; - this.revoked = !!data.revoked; - - this.user = data.user ? new User(session, data.user) : undefined; - this.account = { - id: data.account.id, - name: data.account.name - } - - if (data.application) { - this.application = { - id: data.application.id, - name: data.application.name, - icon: data.application.icon ? data.application.icon : undefined, - description: data.application.description, - bot: data.application.bot ? new User(session, data.application.bot) : undefined - }; - } - } - - id: Snowflake; - session: Session; - guildId?: Snowflake; - - name: string - type: "twitch" | "youtube" | "discord"; - enabled?: boolean; - syncing?: boolean; - roleId?: string; - enableEmoticons?: boolean; - expireBehavior?: IntegrationExpireBehaviors; - expireGracePeriod?: number; - syncedAt?: string; - subscriberCount?: number; - revoked?: boolean; - - user?: User; - account: IntegrationAccount; - application?: IntegrationApplication; -} - -export default Integration; +import type { Model } from "./Base.ts"; +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordIntegration, IntegrationExpireBehaviors } from "../vendor/external.ts"; +import User from "./User.ts"; + +export interface IntegrationAccount { + id: Snowflake; + name: string; +} + +export interface IntegrationApplication { + id: Snowflake; + name: string; + icon?: string; + description: string; + bot?: User; +} + +export class Integration implements Model { + constructor(session: Session, data: DiscordIntegration & { guild_id?: Snowflake }) { + this.id = data.id; + this.session = session; + + data.guild_id ? this.guildId = data.guild_id : null; + + this.name = data.name; + this.type = data.type; + this.enabled = !!data.enabled; + this.syncing = !!data.syncing; + this.roleId = data.role_id; + this.enableEmoticons = !!data.enable_emoticons; + this.expireBehavior = data.expire_behavior; + this.expireGracePeriod = data.expire_grace_period; + this.syncedAt = data.synced_at; + this.subscriberCount = data.subscriber_count; + this.revoked = !!data.revoked; + + this.user = data.user ? new User(session, data.user) : undefined; + this.account = { + id: data.account.id, + name: data.account.name, + }; + + if (data.application) { + this.application = { + id: data.application.id, + name: data.application.name, + icon: data.application.icon ? data.application.icon : undefined, + description: data.application.description, + bot: data.application.bot ? new User(session, data.application.bot) : undefined, + }; + } + } + + id: Snowflake; + session: Session; + guildId?: Snowflake; + + name: string; + type: "twitch" | "youtube" | "discord"; + enabled?: boolean; + syncing?: boolean; + roleId?: string; + enableEmoticons?: boolean; + expireBehavior?: IntegrationExpireBehaviors; + expireGracePeriod?: number; + syncedAt?: string; + subscriberCount?: number; + revoked?: boolean; + + user?: User; + account: IntegrationAccount; + application?: IntegrationApplication; +} + +export default Integration; diff --git a/structures/Invite.ts b/structures/Invite.ts index 5b4eaa6..5c511c2 100644 --- a/structures/Invite.ts +++ b/structures/Invite.ts @@ -2,12 +2,12 @@ import type { Session } from "../session/Session.ts"; import type { Snowflake } from "../util/Snowflake.ts"; import type { DiscordChannel, - DiscordMemberWithUser, DiscordInvite, + DiscordMemberWithUser, DiscordScheduledEventEntityMetadata, + ScheduledEventEntityType, ScheduledEventPrivacyLevel, ScheduledEventStatus, - ScheduledEventEntityType } from "../vendor/external.ts"; import { TargetTypes } from "../vendor/external.ts"; import InviteGuild from "./guilds/InviteGuild.ts"; @@ -67,7 +67,7 @@ export class Invite { if (data.channel) { const guildId = (data.guild && data.guild?.id) ? data.guild.id : ""; - this.channel = new GuildChannel(session, (data.channel as DiscordChannel), guildId); + this.channel = new GuildChannel(session, data.channel as DiscordChannel, guildId); } this.code = data.code; @@ -83,17 +83,25 @@ export class Invite { channelId: data.guild_scheduled_event.channel_id ? data.guild_scheduled_event.channel_id : undefined, creatorId: data.guild_scheduled_event.creator_id ? data.guild_scheduled_event.creator_id : undefined, name: data.guild_scheduled_event.name, - description: data.guild_scheduled_event.description ? data.guild_scheduled_event.description : undefined, + description: data.guild_scheduled_event.description + ? data.guild_scheduled_event.description + : undefined, scheduledStartTime: data.guild_scheduled_event.scheduled_start_time, - scheduledEndTime: data.guild_scheduled_event.scheduled_end_time ? data.guild_scheduled_event.scheduled_end_time : undefined, + scheduledEndTime: data.guild_scheduled_event.scheduled_end_time + ? data.guild_scheduled_event.scheduled_end_time + : undefined, privacyLevel: data.guild_scheduled_event.privacy_level, status: data.guild_scheduled_event.status, entityType: data.guild_scheduled_event.entity_type, entityId: data.guild ? data.guild.id : undefined, - entityMetadata: data.guild_scheduled_event.entity_metadata ? data.guild_scheduled_event.entity_metadata : undefined, - creator: data.guild_scheduled_event.creator ? new User(session, data.guild_scheduled_event.creator) : undefined, + entityMetadata: data.guild_scheduled_event.entity_metadata + ? data.guild_scheduled_event.entity_metadata + : undefined, + creator: data.guild_scheduled_event.creator + ? new User(session, data.guild_scheduled_event.creator) + : undefined, userCount: data.guild_scheduled_event.user_count ? data.guild_scheduled_event.user_count : undefined, - image: data.guild_scheduled_event.image ? data.guild_scheduled_event.image : undefined + image: data.guild_scheduled_event.image ? data.guild_scheduled_event.image : undefined, }; } @@ -108,10 +116,12 @@ export class Invite { if (data.stage_instance) { const guildId = (data.guild && data.guild?.id) ? data.guild.id : ""; this.stageInstance = { - members: data.stage_instance.members.map(m => new Member(session, (m as DiscordMemberWithUser), guildId)), + members: data.stage_instance.members.map((m) => + new Member(session, m as DiscordMemberWithUser, guildId) + ), participantCount: data.stage_instance.participant_count, speakerCount: data.stage_instance.speaker_count, - topic: data.stage_instance.topic + topic: data.stage_instance.topic, }; } diff --git a/structures/Webhook.ts b/structures/Webhook.ts index c17a7ff..629ac36 100644 --- a/structures/Webhook.ts +++ b/structures/Webhook.ts @@ -47,7 +47,7 @@ export class Webhook implements Model { guildId?: Snowflake; user?: User; - async execute(options?: WebhookOptions & CreateMessage & { avatarUrl?: string, username?: string }) { + async execute(options?: WebhookOptions & CreateMessage & { avatarUrl?: string; username?: string }) { if (!this.token) { return; } diff --git a/structures/channels/GuildChannel.ts b/structures/channels/GuildChannel.ts index 4a3600a..d2b93a5 100644 --- a/structures/channels/GuildChannel.ts +++ b/structures/channels/GuildChannel.ts @@ -1,17 +1,23 @@ import type { Model } from "../Base.ts"; import type { Snowflake } from "../../util/Snowflake.ts"; +import type { PermissionsOverwrites } from "../../util/permissions.ts"; import type { Session } from "../../session/Session.ts"; import type { ChannelTypes, DiscordChannel, DiscordInviteMetadata, DiscordListArchivedThreads, + VideoQualityModes, } from "../../vendor/external.ts"; import type { ListArchivedThreads } from "../../util/Routes.ts"; import BaseChannel from "./BaseChannel.ts"; +import VoiceChannel from "./VoiceChannel.ts"; +import NewsChannel from "./NewsChannel.ts"; +import StageChannel from "./StageChannel.ts"; import ThreadMember from "../ThreadMember.ts"; import Invite from "../Invite.ts"; import * as Routes from "../../util/Routes.ts"; +import { Channel, ChannelFactory } from "./ChannelFactory.ts"; /** * Represent the options object to create a thread channel @@ -26,6 +32,40 @@ export interface ThreadCreateOptions { reason?: string; } +/** + * Representations of the objects to edit a guild channel + * @link https://discord.com/developers/docs/resources/channel#modify-channel-json-params-guild-channel + */ +export interface EditGuildChannelOptions { + name?: string; + position?: number; + permissionOverwrites?: PermissionsOverwrites[]; +} + +export interface EditNewsChannelOptions extends EditGuildChannelOptions { + type?: ChannelTypes.GuildNews | ChannelTypes.GuildText; + topic?: string | null; + nfsw?: boolean | null; + parentId?: Snowflake | null; + defaultAutoArchiveDuration?: number | null; +} + +export interface EditGuildTextChannelOptions extends EditNewsChannelOptions { + rateLimitPerUser?: number | null; +} + +export interface EditStageChannelOptions extends EditGuildChannelOptions { + bitrate?: number | null; + rtcRegion?: Snowflake | null; +} + +export interface EditVoiceChannelOptions extends EditStageChannelOptions { + nsfw?: boolean | null; + userLimit?: number | null; + parentId?: Snowflake | null; + videoQualityMode?: VideoQualityModes | null; +} + /** * Represents the option object to create a thread channel from a message * @link https://discord.com/developers/docs/resources/channel#start-thread-from-message @@ -63,6 +103,37 @@ export class GuildChannel extends BaseChannel implements Model { return invites.map((invite) => new Invite(this.session, invite)); } + async edit(options: EditNewsChannelOptions): Promise; + async edit(options: EditStageChannelOptions): Promise; + async edit(options: EditVoiceChannelOptions): Promise; + async edit( + options: EditGuildTextChannelOptions | EditNewsChannelOptions | EditVoiceChannelOptions, + ): Promise { + const channel = await this.session.rest.runMethod( + this.session.rest, + "PATCH", + Routes.CHANNEL(this.id), + { + name: options.name, + type: "type" in options ? options.type : undefined, + position: options.position, + topic: "topic" in options ? options.topic : undefined, + nsfw: "nfsw" in options ? options.nfsw : undefined, + rate_limit_per_user: "rateLimitPerUser" in options ? options.rateLimitPerUser : undefined, + bitrate: "bitrate" in options ? options.bitrate : undefined, + user_limit: "userLimit" in options ? options.userLimit : undefined, + permissions_overwrites: options.permissionOverwrites, + parent_id: "parentId" in options ? options.parentId : undefined, + rtc_region: "rtcRegion" in options ? options.rtcRegion : undefined, + video_quality_mode: "videoQualityMode" in options ? options.videoQualityMode : undefined, + default_auto_archive_duration: "defaultAutoArchiveDuration" in options + ? options.defaultAutoArchiveDuration + : undefined, + }, + ); + return ChannelFactory.from(this.session, channel); + } + /* async getArchivedThreads(options: ListArchivedThreads & { type: "public" | "private" | "privateJoinedThreads" }) { let func: (channelId: Snowflake, options: ListArchivedThreads) => string; @@ -113,5 +184,4 @@ export class GuildChannel extends BaseChannel implements Model { }*/ } - export default GuildChannel; diff --git a/structures/interactions/AutoCompleteInteraction.ts b/structures/interactions/AutoCompleteInteraction.ts index 063b407..7fe886e 100644 --- a/structures/interactions/AutoCompleteInteraction.ts +++ b/structures/interactions/AutoCompleteInteraction.ts @@ -1,4 +1,3 @@ - import type { Model } from "../Base.ts"; import type { Snowflake } from "../../util/Snowflake.ts"; import type { Session } from "../../session/Session.ts"; @@ -32,7 +31,7 @@ export class AutoCompleteInteraction extends BaseInteraction implements Model { { data: { choices }, type: InteractionResponseTypes.ApplicationCommandAutocompleteResult, - } + }, ); } } diff --git a/structures/interactions/CommandInteraction.ts b/structures/interactions/CommandInteraction.ts index 0d25e91..40bce4e 100644 --- a/structures/interactions/CommandInteraction.ts +++ b/structures/interactions/CommandInteraction.ts @@ -1,7 +1,12 @@ import type { Model } from "../Base.ts"; import type { Snowflake } from "../../util/Snowflake.ts"; import type { Session } from "../../session/Session.ts"; -import type { ApplicationCommandTypes, DiscordMemberWithUser, DiscordInteraction, InteractionTypes } from "../../vendor/external.ts"; +import type { + ApplicationCommandTypes, + DiscordInteraction, + DiscordMemberWithUser, + InteractionTypes, +} from "../../vendor/external.ts"; import type { CreateMessage } from "../Message.ts"; import type { MessageFlags } from "../../util/shared/flags.ts"; import { InteractionResponseTypes } from "../../vendor/external.ts"; @@ -17,7 +22,7 @@ import * as Routes from "../../util/Routes.ts"; /** * @link https://discord.com/developers/docs/interactions/slash-commands#interaction-response - * */ + */ export interface InteractionResponse { type: InteractionResponseTypes; data?: InteractionApplicationCommandCallbackData; @@ -25,8 +30,9 @@ export interface InteractionResponse { /** * @link https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata - * */ -export interface InteractionApplicationCommandCallbackData extends Pick { + */ +export interface InteractionApplicationCommandCallbackData + extends Pick { customId?: string; title?: string; // components?: MessageComponents; @@ -36,10 +42,10 @@ export interface InteractionApplicationCommandCallbackData extends Pick { +export interface CommandInteractionOption extends Omit { Attachment?: string; Boolean?: boolean; User?: bigint; @@ -97,7 +97,7 @@ export class CommandInteractionOptionResolver { } if (required === true && properties.every((prop) => typeof option[prop] === "undefined")) { - throw new TypeError(`Properties ${properties.join(', ')} are missing in option ${name}`); + throw new TypeError(`Properties ${properties.join(", ")} are missing in option ${name}`); } return option; @@ -107,12 +107,12 @@ export class CommandInteractionOptionResolver { get(name: string | number, required: boolean): CommandInteractionOption | undefined; get(name: string | number, required?: boolean) { const option = this.hoistedOptions.find((o) => - typeof name === 'number' ? o.name === name.toString() : o.name === name + typeof name === "number" ? o.name === name.toString() : o.name === name ); if (!option) { if (required && name in this.hoistedOptions.map((o) => o.name)) { - throw new TypeError('Option marked as required was undefined'); + throw new TypeError("Option marked as required was undefined"); } return; @@ -125,7 +125,7 @@ export class CommandInteractionOptionResolver { getString(name: string | number, required: true): string; getString(name: string | number, required?: boolean): string | undefined; getString(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.String, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.String, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -134,7 +134,7 @@ export class CommandInteractionOptionResolver { getNumber(name: string | number, required: true): number; getNumber(name: string | number, required?: boolean): number | undefined; getNumber(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Number, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Number, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -143,7 +143,7 @@ export class CommandInteractionOptionResolver { getInteger(name: string | number, required: true): number; getInteger(name: string | number, required?: boolean): number | undefined; getInteger(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Integer, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Integer, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -152,7 +152,7 @@ export class CommandInteractionOptionResolver { getBoolean(name: string | number, required: true): boolean; getBoolean(name: string | number, required?: boolean): boolean | undefined; getBoolean(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Boolean, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Boolean, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -161,7 +161,7 @@ export class CommandInteractionOptionResolver { getUser(name: string | number, required: true): bigint; getUser(name: string | number, required?: boolean): bigint | undefined; getUser(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.User, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.User, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -170,7 +170,7 @@ export class CommandInteractionOptionResolver { getChannel(name: string | number, required: true): bigint; getChannel(name: string | number, required?: boolean): bigint | undefined; getChannel(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Channel, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Channel, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -179,7 +179,7 @@ export class CommandInteractionOptionResolver { getMentionable(name: string | number, required: true): string; getMentionable(name: string | number, required?: boolean): string | undefined; getMentionable(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Mentionable, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Mentionable, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -188,7 +188,7 @@ export class CommandInteractionOptionResolver { getRole(name: string | number, required: true): bigint; getRole(name: string | number, required?: boolean): bigint | undefined; getRole(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Role, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Role, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -197,7 +197,7 @@ export class CommandInteractionOptionResolver { getAttachment(name: string | number, required: true): string; getAttachment(name: string | number, required?: boolean): string | undefined; getAttachment(name: string | number, required = false) { - const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Attachment, ['Otherwise'], required); + const option = this.getTypedOption(name, ApplicationCommandOptionTypes.Attachment, ["Otherwise"], required); return option?.Otherwise ?? undefined; } @@ -207,7 +207,7 @@ export class CommandInteractionOptionResolver { const focusedOption = this.hoistedOptions.find((option) => option.focused); if (!focusedOption) { - throw new TypeError('No option found'); + throw new TypeError("No option found"); } return full ? focusedOption : focusedOption.Otherwise; @@ -215,7 +215,7 @@ export class CommandInteractionOptionResolver { getSubCommand(required = true) { if (required && !this.#subcommand) { - throw new TypeError('Option marked as required was undefined'); + throw new TypeError("Option marked as required was undefined"); } return [this.#subcommand, this.hoistedOptions]; @@ -223,7 +223,7 @@ export class CommandInteractionOptionResolver { getSubCommandGroup(required = false) { if (required && !this.#group) { - throw new TypeError('Option marked as required was undefined'); + throw new TypeError("Option marked as required was undefined"); } return [this.#group, this.hoistedOptions]; diff --git a/structures/interactions/ModalSubmitInteraction.ts b/structures/interactions/ModalSubmitInteraction.ts index ff14a18..4d5f6df 100644 --- a/structures/interactions/ModalSubmitInteraction.ts +++ b/structures/interactions/ModalSubmitInteraction.ts @@ -1,8 +1,12 @@ - import type { Model } from "../Base.ts"; import type { Snowflake } from "../../util/Snowflake.ts"; import type { Session } from "../../session/Session.ts"; -import type { DiscordInteraction, InteractionTypes, MessageComponentTypes, DiscordMessageComponents } from "../../vendor/external.ts"; +import type { + DiscordInteraction, + DiscordMessageComponents, + InteractionTypes, + MessageComponentTypes, +} from "../../vendor/external.ts"; import BaseInteraction from "./BaseInteraction.ts"; import Message from "../Message.ts"; diff --git a/structures/interactions/PingInteraction.ts b/structures/interactions/PingInteraction.ts index 438ac01..a335f7c 100644 --- a/structures/interactions/PingInteraction.ts +++ b/structures/interactions/PingInteraction.ts @@ -1,4 +1,3 @@ - import type { Model } from "../Base.ts"; import type { Snowflake } from "../../util/Snowflake.ts"; import type { Session } from "../../session/Session.ts"; @@ -30,7 +29,7 @@ export class PingInteraction extends BaseInteraction implements Model { Routes.INTERACTION_ID_TOKEN(this.id, this.token), { type: InteractionResponseTypes.Pong, - } + }, ); } } diff --git a/util/permissions.ts b/util/permissions.ts new file mode 100644 index 0000000..e19f5ea --- /dev/null +++ b/util/permissions.ts @@ -0,0 +1,9 @@ +import { Snowflake } from "./Snowflake.ts"; +import { Permissions } from "../structures/Permissions.ts"; + +export interface PermissionsOverwrites { + id: Snowflake; + type: 0 | 1; + allow: Permissions; + deny: Permissions; +}