Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text in Guild Voice Channels #1298

Merged
merged 21 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ declare namespace Eris {
type AnyChannel = AnyGuildChannel | PrivateChannel;
type AnyGuildChannel = GuildTextableChannel | AnyVoiceChannel | CategoryChannel | StoreChannel;
type AnyThreadChannel = NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | ThreadChannel;
type AnyVoiceChannel = VoiceChannel | StageChannel;
type GuildTextableChannel = TextChannel | NewsChannel;
type AnyVoiceChannel = GuildVoiceChannel | StageChannel;
type GuildTextableChannel = TextChannel | NewsChannel | GuildVoiceChannel;
type GuildTextableWithThread = GuildTextableChannel | AnyThreadChannel;
type InviteChannel = InvitePartialChannel | Exclude<AnyGuildChannel, CategoryChannel | AnyThreadChannel>;
type PossiblyUncachedTextable = Textable | Uncached;
Expand Down Expand Up @@ -313,10 +313,20 @@ declare namespace Eris {
before?: string;
limit?: number;
}

interface Pinnable {
getPins(): Promise<Message[]>;
pinMessage(messageID: string): Promise<void>;
unpinMessage(messageID: string): Promise<void>;
}

interface GuildPinnable extends Pinnable {
lastPinTimestamp: number | null;
topic?: string;
DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
}

interface GuildTextable extends Textable {
lastPinTimestamp: number | null;
rateLimitPerUser: number;
topic: string | null;
createWebhook(options: { name: string; avatar?: string | null }, reason?: string): Promise<Webhook>;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
getWebhooks(): Promise<Webhook[]>;
Expand Down Expand Up @@ -360,15 +370,12 @@ declare namespace Eris {
getMessages(options?: GetMessagesOptions): Promise<Message[]>;
/** @deprecated */
getMessages(limit?: number, before?: string, after?: string, around?: string): Promise<Message[]>;
getPins(): Promise<Message[]>;
pinMessage(messageID: string): Promise<void>;
removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
sendTyping(): Promise<void>;
unpinMessage(messageID: string): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}
// @ts-ignore ts(2430) - ThreadTextable can't properly extend Textable because of getMessageReaction deprecated overload
interface ThreadTextable extends Textable {
interface ThreadTextable extends Textable, Pinnable {
lastPinTimestamp?: number;
createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise<Message<ThreadChannel>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<ThreadChannel>>;
Expand Down Expand Up @@ -2875,6 +2882,34 @@ declare namespace Eris {
toJSON(props?: string[]): JSONCache;
}

export class GuildVoiceChannel extends VoiceChannel implements GuildTextable {
lastMessageID: string;
messages: Collection<Message<this>>;
rateLimitPerUser: number;
addMessageReaction(messageID: string, reaction: string): Promise<void>;
/** @deprecated */
addMessageReaction(messageID: string, reaction: string, userID: string): Promise<void>;
createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise<Message>;
createWebhook(options: { name: string; avatar?: string | null }, reason?: string): Promise<Webhook>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message>;
getMessage(messageID: string): Promise<Message>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
/** @deprecated */
getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise<User[]>;
getMessages(options?: GetMessagesOptions): Promise<Message[]>;
/** @deprecated */
getMessages(limit?: number, before?: string, after?: string, around?: string): Promise<Message[]>;
getWebhooks(): Promise<Webhook[]>;
purge(options: PurgeChannelOptions): Promise<number>;
removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
removeMessageReactionEmoji(messageID: string, reaction: string): Promise<void>;
removeMessageReactions(messageID: string): Promise<void>;
sendTyping(): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}

//Interaction
type AnyInteraction = PingInteraction | CommandInteraction | ComponentInteraction | AutocompleteInteraction;

Expand Down Expand Up @@ -3116,7 +3151,7 @@ declare namespace Eris {
}

// News channel rate limit is always 0
export class NewsChannel extends TextChannel {
export class NewsChannel extends TextChannel implements GuildPinnable {
rateLimitPerUser: 0;
type: Constants["ChannelTypes"]["GUILD_NEWS"];
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", NewsChannel>>;
Expand Down Expand Up @@ -3175,7 +3210,7 @@ declare namespace Eris {
stop(e: Error, source: Duplex): void;
}

export class PrivateChannel extends Channel implements Textable {
export class PrivateChannel extends Channel implements Textable, Pinnable {
lastMessageID: string;
messages: Collection<Message<this>>;
recipient: User;
Expand Down Expand Up @@ -3421,13 +3456,13 @@ declare namespace Eris {
edit(options: Omit<EditChannelOptions, "icon" | "ownerID">, reason?: string): Promise<this>;
}

export class TextChannel extends GuildChannel implements GuildTextable, Invitable {
export class TextChannel extends GuildChannel implements GuildTextable, Invitable, GuildPinnable {
defaultAutoArchiveDuration: AutoArchiveDuration;
lastMessageID: string;
lastPinTimestamp: number | null;
messages: Collection<Message<this>>;
rateLimitPerUser: number;
topic: string | null;
topic?: string;
DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
type: GuildTextChannelTypes;
constructor(data: BaseData, client: Client, messageLimit: number);
addMessageReaction(messageID: string, reaction: string): Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions lib/structures/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Channel extends Base {
return new PrivateChannel(data, client);
}
case ChannelTypes.GUILD_VOICE: {
return new VoiceChannel(data, client);
return new GuildVoiceChannel(data, client);
}
case ChannelTypes.GROUP_DM: {
return new GroupChannel(data, client);
Expand Down Expand Up @@ -92,4 +92,4 @@ const PublicThreadChannel = require("./PublicThreadChannel");
const StageChannel = require("./StageChannel");
const StoreChannel = require("./StoreChannel");
const TextChannel = require("./TextChannel");
const VoiceChannel = require("./VoiceChannel");
const GuildVoiceChannel = require("./GuildVoiceChannel");
Loading