diff --git a/structures/DMChannel.ts b/structures/DMChannel.ts index 077514f..d3407f1 100644 --- a/structures/DMChannel.ts +++ b/structures/DMChannel.ts @@ -1,16 +1,23 @@ +import type { Model } from "./Base.ts"; 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 * as Routes from "../util/Routes.ts"; -export class DMChannel extends Channel { +export class DMChannel extends Channel implements Model { constructor(session: Session, data: DiscordChannel) { super(session, data); - data.last_message_id ? this.lastMessageId = data.last_message_id : undefined; - // Waiting for implementation of botId in session - //this.user = new User(this.session, data.recipents!.find((r) => r.id !== this.session.botId)); + + this.user = new User(this.session, data.recipents!.find((r) => r.id !== this.session.botId)!); + + if (data.last_message_id) { + this.lastMessageId = data.last_message_id; + } } + + user: User; lastMessageId?: Snowflake; async close() { diff --git a/structures/TextChannel.ts b/structures/TextChannel.ts index e5e9d1e..bbc9bd2 100644 --- a/structures/TextChannel.ts +++ b/structures/TextChannel.ts @@ -4,7 +4,6 @@ import type { GetMessagesOptions, GetReactions } from "../util/Routes.ts"; import type { DiscordChannel, DiscordInvite, DiscordMessage, TargetTypes } from "../vendor/external.ts"; import type { ReactionResolvable } from "./Message.ts"; import GuildChannel from "./GuildChannel.ts"; -import Guild from "./Guild.ts"; import ThreadChannel from "./ThreadChannel.ts"; import Message from "./Message.ts"; import Invite from "./Invite.ts"; @@ -38,7 +37,7 @@ export interface ThreadCreateOptions { } export class TextChannel extends GuildChannel { - constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) { + constructor(session: Session, data: DiscordChannel, guildId: Snowflake) { super(session, data, guildId); data.last_message_id ? this.lastMessageId = data.last_message_id : undefined; data.last_pin_timestamp ? this.lastPinTimestamp = data.last_pin_timestamp : undefined;