mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 14:06:07 +00:00
refactor: Channel -> BaseChannel
This commit is contained in:
parent
3f714eb295
commit
b99218bdc3
2
mod.ts
2
mod.ts
@ -2,7 +2,7 @@ export * from "./structures/AnonymousGuild.ts";
|
||||
export * from "./structures/Attachment.ts";
|
||||
export * from "./structures/Base.ts";
|
||||
export * from "./structures/BaseGuild.ts";
|
||||
export * from "./structures/Channel.ts";
|
||||
export * from "./structures/BaseChannel.ts";
|
||||
export * from "./structures/Component.ts";
|
||||
export * from "./structures/DMChannel.ts";
|
||||
export * from "./structures/Embed.ts";
|
||||
|
49
structures/BaseChannel.ts
Normal file
49
structures/BaseChannel.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { ChannelTypes, DiscordChannel } from "../vendor/external.ts";
|
||||
import TextChannel from "./TextChannel.ts";
|
||||
import VoiceChannel from "./VoiceChannel.ts";
|
||||
import DMChannel from "./DMChannel.ts";
|
||||
import NewsChannel from "./NewsChannel.ts";
|
||||
import ThreadChannel from "./ThreadChannel.ts";
|
||||
|
||||
export abstract class BaseChannel implements Model {
|
||||
constructor(session: Session, data: DiscordChannel) {
|
||||
this.id = data.id;
|
||||
this.session = session;
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
}
|
||||
readonly id: Snowflake;
|
||||
readonly session: Session;
|
||||
|
||||
name?: string;
|
||||
type: ChannelTypes;
|
||||
|
||||
isText(): this is TextChannel {
|
||||
return this instanceof TextChannel;
|
||||
}
|
||||
|
||||
isVoice(): this is VoiceChannel {
|
||||
return this instanceof VoiceChannel;
|
||||
}
|
||||
|
||||
isDM(): this is DMChannel {
|
||||
return this instanceof DMChannel;
|
||||
}
|
||||
|
||||
isNews(): this is NewsChannel {
|
||||
return this instanceof NewsChannel;
|
||||
}
|
||||
|
||||
isThread(): this is ThreadChannel {
|
||||
return this instanceof ThreadChannel;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<#${this.id}>`;
|
||||
}
|
||||
}
|
||||
|
||||
export default BaseChannel;
|
@ -1,24 +0,0 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { ChannelTypes, DiscordChannel } from "../vendor/external.ts";
|
||||
|
||||
export abstract class Channel implements Model {
|
||||
constructor(session: Session, data: DiscordChannel) {
|
||||
this.id = data.id;
|
||||
this.session = session;
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
}
|
||||
readonly id: Snowflake;
|
||||
readonly session: Session;
|
||||
|
||||
name?: string;
|
||||
type: ChannelTypes;
|
||||
|
||||
toString(): string {
|
||||
return `<#${this.id}>`;
|
||||
}
|
||||
}
|
||||
|
||||
export default Channel;
|
@ -2,11 +2,11 @@ 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 BaseChannel from "./BaseChannel.ts";
|
||||
import User from "./User.ts";
|
||||
import * as Routes from "../util/Routes.ts";
|
||||
|
||||
export class DMChannel extends Channel implements Model {
|
||||
export class DMChannel extends BaseChannel implements Model {
|
||||
constructor(session: Session, data: DiscordChannel) {
|
||||
super(session, data);
|
||||
|
||||
|
@ -2,11 +2,11 @@ import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordChannel, DiscordInviteMetadata } from "../vendor/external.ts";
|
||||
import Channel from "./Channel.ts";
|
||||
import BaseChannel from "./BaseChannel.ts";
|
||||
import Invite from "./Invite.ts";
|
||||
import * as Routes from "../util/Routes.ts";
|
||||
|
||||
export abstract class GuildChannel extends Channel implements Model {
|
||||
export abstract class GuildChannel extends BaseChannel implements Model {
|
||||
constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
|
||||
super(session, data);
|
||||
this.guildId = guildId;
|
||||
|
Loading…
x
Reference in New Issue
Block a user