diff --git a/structures/AnonymousGuild.ts b/structures/AnonymousGuild.ts index 649809b..cf3898e 100644 --- a/structures/AnonymousGuild.ts +++ b/structures/AnonymousGuild.ts @@ -29,3 +29,5 @@ export abstract class AnonymousGuild extends BaseGuild implements Model { // TODO: bannerUrl and splashUrl } + +export default AnonymousGuild; diff --git a/structures/Attachment.ts b/structures/Attachment.ts index 6f4e578..35a6a9b 100644 --- a/structures/Attachment.ts +++ b/structures/Attachment.ts @@ -34,3 +34,5 @@ export class Attachment implements Model { width?: number; ephemeral: boolean; } + +export default Attachment; diff --git a/structures/BaseGuild.ts b/structures/BaseGuild.ts index 6b47a9e..d233e9c 100644 --- a/structures/BaseGuild.ts +++ b/structures/BaseGuild.ts @@ -37,3 +37,5 @@ export abstract class BaseGuild implements Model { return this.name; } } + +export default BaseGuild; diff --git a/structures/Channel.ts b/structures/Channel.ts index f2fae2e..ccb45dc 100644 --- a/structures/Channel.ts +++ b/structures/Channel.ts @@ -1,5 +1,7 @@ import type { Model } from "./Base.ts"; -import { ChannelTypes, DiscordChannel, Session, Snowflake } from "../mod.ts"; +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import { ChannelTypes, DiscordChannel } from "../mod.ts"; export abstract class Channel implements Model { constructor(session: Session, data: DiscordChannel) { @@ -17,3 +19,5 @@ export abstract class Channel implements Model { return `<#${this.id}>`; } } + +export default Channel; diff --git a/structures/DMChannel.ts b/structures/DMChannel.ts index d2f0719..4e6568b 100644 --- a/structures/DMChannel.ts +++ b/structures/DMChannel.ts @@ -1,6 +1,7 @@ +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordChannel } from "../vendor/external.ts"; import { Channel } from "./Channel.ts"; -//import { User } from "./User.ts"; -import { DiscordChannel, Routes, Session, Snowflake } from "../mod.ts"; export class DMChannel extends Channel { constructor(session: Session, data: DiscordChannel) { @@ -17,6 +18,9 @@ export class DMChannel extends Channel { "DELETE", Routes.CHANNEL(this.id), ); + return new DMChannel(this.session, channel); } } + +export default DMChannel; diff --git a/structures/Emoji.ts b/structures/Emoji.ts index 9473b67..35ab4a7 100644 --- a/structures/Emoji.ts +++ b/structures/Emoji.ts @@ -16,3 +16,5 @@ export class Emoji { available: boolean; requireColons: boolean; } + +export default Emoji; diff --git a/structures/Guild.ts b/structures/Guild.ts index 37dfe5b..70bf41f 100644 --- a/structures/Guild.ts +++ b/structures/Guild.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"; import type { DiscordGuild, DiscordRole } from "../vendor/external.ts"; @@ -26,7 +25,7 @@ export interface CreateRole { * Represents a guild * @link https://discord.com/developers/docs/resources/guild#guild-object */ -export class Guild extends BaseGuild implements Model { +export class Guild extends BaseGuild { constructor(session: Session, data: DiscordGuild) { super(session, data); @@ -39,7 +38,7 @@ export class Guild extends BaseGuild implements Model { this.defaultMessageNotificationLevel = data.default_message_notifications; this.explicitContentFilterLevel = data.explicit_content_filter; this.members = data.members?.map((member) => new Member(session, { ...member, user: member.user! })) ?? []; - this.roles = data.roles.map((role) => new Role(session, data.id, role)); + this.roles = data.roles.map((role) => new Role(session, role, data.id)); } splashHash?: bigint; @@ -78,10 +77,12 @@ export class Guild extends BaseGuild implements Model { }, ); - return new Role(this.session, this.id, role); + return new Role(this.session, role, this.id); } async deleteRole(roleId: Snowflake): Promise { await this.session.rest.runMethod(this.session.rest, "DELETE", Routes.GUILD_ROLE(this.id, roleId)); } } + +export default Guild; diff --git a/structures/GuildChannel.ts b/structures/GuildChannel.ts index 8ca5873..fe07aef 100644 --- a/structures/GuildChannel.ts +++ b/structures/GuildChannel.ts @@ -1,6 +1,9 @@ +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordChannel } from "../vendor/external.ts"; import { Channel } from "./Channel.ts"; import { Guild } from "./Guild.ts"; -import { DiscordChannel, Routes, Session, Snowflake } from "../mod.ts"; +import { Routes } from "../util/mod.ts"; export abstract class GuildChannel extends Channel { constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) { @@ -27,3 +30,5 @@ export abstract class GuildChannel extends Channel { ); } } + +export default GuildChannel; diff --git a/structures/GuildEmoji.ts b/structures/GuildEmoji.ts index 8b022e9..af511c4 100644 --- a/structures/GuildEmoji.ts +++ b/structures/GuildEmoji.ts @@ -1,4 +1,8 @@ -import { DiscordEmoji, Emoji, Session, Snowflake, User } from "../mod.ts"; +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordEmoji } from "../vendor/external.ts"; +import { Emoji } from "./Emoji.ts"; +import { User } from "./User.ts"; export class GuildEmoji extends Emoji { constructor(session: Session, data: DiscordEmoji, guildId: Snowflake) { @@ -13,3 +17,5 @@ export class GuildEmoji extends Emoji { user?: User; managed?: boolean; } + +export default GuildEmoji; diff --git a/structures/Member.ts b/structures/Member.ts index f5a5baf..5e04ac7 100644 --- a/structures/Member.ts +++ b/structures/Member.ts @@ -113,3 +113,5 @@ export class Member implements Model { return `<@!${this.user.id}>`; } } + +export default Member; diff --git a/structures/Message.ts b/structures/Message.ts index b545221..f900eb7 100644 --- a/structures/Message.ts +++ b/structures/Message.ts @@ -145,7 +145,9 @@ export class Message implements Model { return message; } - inGuild(): this is { guildId: string } & Message { - return Boolean(this.guildId); + inGuild(): this is { guildId: Snowflake } & Message { + return !!this.guildId; } } + +export default Message; diff --git a/structures/NewsChannel.ts b/structures/NewsChannel.ts index 664532e..5be27c8 100644 --- a/structures/NewsChannel.ts +++ b/structures/NewsChannel.ts @@ -1,9 +1,14 @@ -import { DiscordChannel, Guild, Session, TextChannel } from "../mod.ts"; +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordChannel } from "../vendor/external.ts"; +import { TextChannel } from "./TextChannel.ts"; export class NewsChannel extends TextChannel { - constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) { + constructor(session: Session, data: DiscordChannel, guildId: Snowflake) { super(session, data, guildId); this.defaultAutoArchiveDuration = data.default_auto_archive_duration; } defaultAutoArchiveDuration?: number; } + +export default NewsChannel; diff --git a/structures/Role.ts b/structures/Role.ts index be4c156..a4c9b02 100644 --- a/structures/Role.ts +++ b/structures/Role.ts @@ -1,13 +1,13 @@ import type { Model } from "./Base.ts"; -import type { Session } from "../session/Session.ts"; import type { DiscordRole } from "../vendor/external.ts"; -import { Snowflake } from "../mod.ts"; +import { Snowflake } from "../util/Snowflake.ts"; +import { Session } from "../session/Session.ts"; import { iconHashToBigInt } from "../util/hash.ts"; import { Permissions } from "./Permissions.ts"; import { Guild } from "./Guild.ts"; export class Role implements Model { - constructor(session: Session, guildId: Snowflake, data: DiscordRole) { + constructor(session: Session, data: DiscordRole, guildId: Snowflake) { this.session = session; this.id = data.id; this.guildId = guildId; @@ -59,3 +59,5 @@ export class Role implements Model { } } } + +export default Role; diff --git a/structures/TextChannel.ts b/structures/TextChannel.ts index 446bdcc..0fa640a 100644 --- a/structures/TextChannel.ts +++ b/structures/TextChannel.ts @@ -1,15 +1,17 @@ +import type { Session } from "../session/Session.ts"; +import type { Snowflake } from "../util/Snowflake.ts"; +import type { GetMessagesOptions } from "../util/Routes.ts"; +import type { DiscordChannel, DiscordInviteCreate, DiscordMessage } from "../vendor/external.ts"; import { GuildChannel } from "./GuildChannel.ts"; import { Guild } from "./Guild.ts"; import { ThreadChannel } from "./ThreadChannel.ts"; import { Message } from "./Message.ts"; -import { DiscordChannel, DiscordInviteCreate, DiscordMessage, Routes, Session, Snowflake } from "../mod.ts"; -import { GetMessagesOptions } from "../util/Routes.ts"; +import { Routes } from "../util/mod.ts"; /** * Represents the options object to create an invitation * @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params */ - export interface DiscordInviteOptions { max_age?: number; max_uses?: number; @@ -22,7 +24,6 @@ export interface DiscordInviteOptions { * Represent the options object to create a Thread Channel * @link https://discord.com/developers/docs/resources/channel#start-thread-without-message */ - export interface ThreadCreateOptions { name: string; autoArchiveDuration: 60 | 1440 | 4320 | 10080; @@ -83,11 +84,13 @@ export class TextChannel extends GuildChannel { return messages[0] ? messages.map((x) => new Message(this.session, x)) : []; } - sendTyping() { - this.session.rest.runMethod( + async sendTyping() { + await this.session.rest.runMethod( this.session.rest, "POST", Routes.CHANNEL_TYPING(this.id), ); } } + +export default TextChannel; diff --git a/structures/ThreadChannel.ts b/structures/ThreadChannel.ts index 9987c4a..d52b54c 100644 --- a/structures/ThreadChannel.ts +++ b/structures/ThreadChannel.ts @@ -1,9 +1,10 @@ +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordChannel } from "../vendor/external.ts"; import { GuildChannel } from "./GuildChannel.ts"; -import { Guild } from "./Guild.ts"; -import { DiscordChannel, Session, Snowflake } from "../mod.ts"; export class ThreadChannel extends GuildChannel { - constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) { + constructor(session: Session, data: DiscordChannel, guildId: Snowflake) { super(session, data, guildId); this.archived = !!data.thread_metadata?.archived; this.archiveTimestamp = data.thread_metadata?.archive_timestamp; @@ -21,3 +22,5 @@ export class ThreadChannel extends GuildChannel { memberCount?: number; ownerId?: Snowflake; } + +export default ThreadChannel; diff --git a/structures/User.ts b/structures/User.ts index 42c623c..7ed47a4 100644 --- a/structures/User.ts +++ b/structures/User.ts @@ -57,3 +57,5 @@ export class User implements Model { return `<@${this.id}>`; } } + +export default User; diff --git a/structures/VoiceChannel.ts b/structures/VoiceChannel.ts index 7f285c3..56f682f 100644 --- a/structures/VoiceChannel.ts +++ b/structures/VoiceChannel.ts @@ -1,9 +1,10 @@ +import type { Snowflake } from "../util/Snowflake.ts"; +import type { Session } from "../session/Session.ts"; +import type { DiscordChannel, VideoQualityModes } from "../vendor/external.ts"; import { GuildChannel } from "./GuildChannel.ts"; -import { Guild } from "./Guild.ts"; -import { DiscordChannel, Session, Snowflake, VideoQualityModes } from "../mod.ts"; export class VoiceChannel extends GuildChannel { - constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) { + constructor(session: Session, guildId: Snowflake, data: DiscordChannel) { super(session, data, guildId); this.bitRate = data.bitrate; this.userLimit = data.user_limit ?? 0; @@ -16,5 +17,7 @@ export class VoiceChannel extends GuildChannel { rtcRegion?: Snowflake; videoQuality?: VideoQualityModes; - nsfw?: boolean; + nsfw: boolean; } + +export default VoiceChannel;