mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
refactor: channels.ts
This commit is contained in:
parent
c993699aab
commit
00008ac29d
@ -211,6 +211,7 @@ export type TextBasedChannels =
|
|||||||
| ChannelTypes.GuildPrivateThread
|
| ChannelTypes.GuildPrivateThread
|
||||||
| ChannelTypes.GuildPublicThread
|
| ChannelTypes.GuildPublicThread
|
||||||
| ChannelTypes.GuildNews
|
| ChannelTypes.GuildNews
|
||||||
|
| ChannelTypes.GuildNewsThread
|
||||||
| ChannelTypes.GuildVoice
|
| ChannelTypes.GuildVoice
|
||||||
| ChannelTypes.GuildText;
|
| ChannelTypes.GuildText;
|
||||||
|
|
||||||
@ -238,14 +239,6 @@ export namespace TextChannel {
|
|||||||
/** When the last pinned message was pinned. This may be undefined in events such as GUILD_CREATE when a message is not pinned. */
|
/** When the last pinned message was pinned. This may be undefined in events such as GUILD_CREATE when a message is not pinned. */
|
||||||
lastPinTimestamp?: string;
|
lastPinTimestamp?: string;
|
||||||
|
|
||||||
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
|
|
||||||
// TODO: move this
|
|
||||||
// rateLimitPerUser: number;
|
|
||||||
|
|
||||||
/** If the channel is NSFW (Not-Safe-For-Work content) */
|
|
||||||
// TODO: move this
|
|
||||||
// nsfw: boolean;
|
|
||||||
|
|
||||||
// methods to be implemented
|
// methods to be implemented
|
||||||
|
|
||||||
fetchPins(): Promise<Message[]>;
|
fetchPins(): Promise<Message[]>;
|
||||||
@ -589,6 +582,7 @@ export class GuildChannel extends BaseChannel implements Model {
|
|||||||
this.permissionOverwrites = data.permission_overwrites
|
this.permissionOverwrites = data.permission_overwrites
|
||||||
? ChannelFactory.permissionOverwrites(data.permission_overwrites)
|
? ChannelFactory.permissionOverwrites(data.permission_overwrites)
|
||||||
: [];
|
: [];
|
||||||
|
this.nsfw = data.nsfw ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Channel type. */
|
/** Channel type. */
|
||||||
@ -609,6 +603,9 @@ export class GuildChannel extends BaseChannel implements Model {
|
|||||||
/** Explicit permission overwrites for members and roles */
|
/** Explicit permission overwrites for members and roles */
|
||||||
permissionOverwrites: PermissionsOverwrites[];
|
permissionOverwrites: PermissionsOverwrites[];
|
||||||
|
|
||||||
|
/** If the channel is NSFW (Not-Safe-For-Work content) */
|
||||||
|
nsfw: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the channel invites for the channel.
|
* Gets the channel invites for the channel.
|
||||||
*/
|
*/
|
||||||
@ -811,6 +808,10 @@ export class DMChannel extends BaseChannel implements Model, TextChannel.T {
|
|||||||
if (data.last_message_id) {
|
if (data.last_message_id) {
|
||||||
this.lastMessageId = data.last_message_id;
|
this.lastMessageId = data.last_message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.rate_limit_per_user) {
|
||||||
|
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override type: ChannelTypes.DM | ChannelTypes.GroupDm;
|
override type: ChannelTypes.DM | ChannelTypes.GroupDm;
|
||||||
@ -826,6 +827,10 @@ export class DMChannel extends BaseChannel implements Model, TextChannel.T {
|
|||||||
/** When the last pinned message was pinned. This may be undefined in events such as GUILD_CREATE when a message is not pinned. */
|
/** When the last pinned message was pinned. This may be undefined in events such as GUILD_CREATE when a message is not pinned. */
|
||||||
lastPinTimestamp?: string;
|
lastPinTimestamp?: string;
|
||||||
|
|
||||||
|
|
||||||
|
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
|
||||||
|
rateLimitPerUser?: number;
|
||||||
|
|
||||||
async close(): Promise<DMChannel> {
|
async close(): Promise<DMChannel> {
|
||||||
const channel = await this.session.rest.delete<DiscordChannel>(CHANNEL(this.id), {});
|
const channel = await this.session.rest.delete<DiscordChannel>(CHANNEL(this.id), {});
|
||||||
|
|
||||||
@ -848,9 +853,12 @@ export class VoiceChannel extends BaseVoiceChannel implements Model, TextChannel
|
|||||||
constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
|
constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
|
||||||
super(session, data, guildId);
|
super(session, data, guildId);
|
||||||
this.type = data.type as number;
|
this.type = data.type as number;
|
||||||
|
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
override type: ChannelTypes.GuildVoice;
|
override type: ChannelTypes.GuildVoice;
|
||||||
|
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
|
||||||
|
rateLimitPerUser?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(VoiceChannel.prototype, TextChannel);
|
Object.assign(VoiceChannel.prototype, TextChannel);
|
||||||
@ -863,11 +871,15 @@ export class NewsChannel extends GuildChannel implements Model, TextChannel.T {
|
|||||||
super(session, data, guildId);
|
super(session, data, guildId);
|
||||||
this.type = data.type as ChannelTypes.GuildNews;
|
this.type = data.type as ChannelTypes.GuildNews;
|
||||||
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
|
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
|
||||||
|
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
override type: ChannelTypes.GuildNews;
|
override type: ChannelTypes.GuildNews;
|
||||||
defaultAutoArchiveDuration?: number;
|
defaultAutoArchiveDuration?: number;
|
||||||
|
|
||||||
|
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
|
||||||
|
rateLimitPerUser?: number;
|
||||||
|
|
||||||
crosspostMessage(messageId: Snowflake): Promise<Message> {
|
crosspostMessage(messageId: Snowflake): Promise<Message> {
|
||||||
return Message.prototype.crosspost.call({ id: messageId, channelId: this.id, session: this.session });
|
return Message.prototype.crosspost.call({ id: messageId, channelId: this.id, session: this.session });
|
||||||
}
|
}
|
||||||
@ -905,6 +917,7 @@ export class ThreadChannel extends GuildChannel implements Model, TextChannel.T
|
|||||||
this.messageCount = data.message_count;
|
this.messageCount = data.message_count;
|
||||||
this.memberCount = data.member_count;
|
this.memberCount = data.member_count;
|
||||||
this.ownerId = data.owner_id;
|
this.ownerId = data.owner_id;
|
||||||
|
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||||
|
|
||||||
if (data.member) {
|
if (data.member) {
|
||||||
this.member = new ThreadMember(session, data.member);
|
this.member = new ThreadMember(session, data.member);
|
||||||
@ -927,6 +940,9 @@ export class ThreadChannel extends GuildChannel implements Model, TextChannel.T
|
|||||||
totalMessageSent?: number;
|
totalMessageSent?: number;
|
||||||
appliedTags?: string[];
|
appliedTags?: string[];
|
||||||
|
|
||||||
|
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
|
||||||
|
rateLimitPerUser?: number;
|
||||||
|
|
||||||
async joinThread(): Promise<void> {
|
async joinThread(): Promise<void> {
|
||||||
await this.session.rest.put<undefined>(THREAD_ME(this.id), {});
|
await this.session.rest.put<undefined>(THREAD_ME(this.id), {});
|
||||||
}
|
}
|
||||||
@ -991,8 +1007,13 @@ export class ForumChannel extends GuildChannel {
|
|||||||
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user;
|
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the IDs of the set of tags that have been applied to a thread in a GUILD_FORUM channel */
|
||||||
availableTags?: ForumTag[];
|
availableTags?: ForumTag[];
|
||||||
|
|
||||||
|
/** the emoji to show in the add reaction button on a thread in a GUILD_FORUM channel */
|
||||||
defaultReactionEmoji?: DefaultReactionEmoji;
|
defaultReactionEmoji?: DefaultReactionEmoji;
|
||||||
|
|
||||||
|
/** the initial rate_limit_per_user to set on newly created threads in a channel. this field is copied to the thread at creation time and does not live update */
|
||||||
defaultThreadRateLimitPerUser?: number;
|
defaultThreadRateLimitPerUser?: number;
|
||||||
|
|
||||||
async setAvailableTags(tags: ForumTag[]) {
|
async setAvailableTags(tags: ForumTag[]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user