mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat: more structures
This commit is contained in:
parent
0f68995136
commit
ebca648b61
20
structures/Channel.ts
Normal file
20
structures/Channel.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import type { Model } from "./Base.ts";
|
||||||
|
import { Snowflake, Session, DiscordChannel, ChannelTypes } from "../mod.ts";
|
||||||
|
|
||||||
|
export class Channel implements Model {
|
||||||
|
constructor(session: Session, data: DiscordChannel) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.data = data;
|
||||||
|
this.session = session;
|
||||||
|
this.name = this.data.name;
|
||||||
|
}
|
||||||
|
readonly data: DiscordChannel;
|
||||||
|
readonly id: Snowflake;
|
||||||
|
readonly session: Session;
|
||||||
|
public readonly name: string | undefined;
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
return ChannelTypes[this.data.type];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
structures/GuildChannel.ts
Normal file
30
structures/GuildChannel.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { Channel } from "./Channel.ts";
|
||||||
|
import { DiscordChannel, Routes, Session } from "../mod.ts";
|
||||||
|
|
||||||
|
export class GuildChannel extends Channel {
|
||||||
|
constructor(session: Session, data: DiscordChannel) {
|
||||||
|
super(session, data);
|
||||||
|
this.guild_id = data.guild_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
guild_id?: string;
|
||||||
|
|
||||||
|
get topic() {
|
||||||
|
return this.data.topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
get guildId() {
|
||||||
|
return this.guild_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(reason?: string) {
|
||||||
|
return this.session.rest.runMethod<DiscordChannel>(
|
||||||
|
this.session.rest,
|
||||||
|
"DELETE",
|
||||||
|
Routes.CHANNEL(this.id),
|
||||||
|
{
|
||||||
|
reason,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
27
structures/TextChannel.ts
Normal file
27
structures/TextChannel.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { GuildChannel } from "./GuildChannel.ts";
|
||||||
|
import { DiscordChannel, Session } from "../mod.ts";
|
||||||
|
|
||||||
|
export class TextChannel extends GuildChannel {
|
||||||
|
constructor(session: Session, data: DiscordChannel) {
|
||||||
|
super(session, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
get lastMessageId() {
|
||||||
|
return this.data.last_message_id;
|
||||||
|
}
|
||||||
|
get rateLimitPerUser() {
|
||||||
|
return this.data.rate_limit_per_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
get parentId() {
|
||||||
|
return this.data.parent_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get permissionOverwrites() {
|
||||||
|
return this.data.permission_overwrites;
|
||||||
|
}
|
||||||
|
|
||||||
|
get nsfw() {
|
||||||
|
return this.data.nsfw;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,10 @@ export interface GetMessagesOptions {
|
|||||||
limit?: number;
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function CHANNEL(channelId: Snowflake) {
|
||||||
|
return `/channels/${channelId}`;
|
||||||
|
}
|
||||||
|
|
||||||
/** used to send messages */
|
/** used to send messages */
|
||||||
export function CHANNEL_MESSAGES(channelId: Snowflake, options?: GetMessagesOptions) {
|
export function CHANNEL_MESSAGES(channelId: Snowflake, options?: GetMessagesOptions) {
|
||||||
let url = `/channels/${channelId}/messages?`;
|
let url = `/channels/${channelId}/messages?`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user