Skip to content

Commit

Permalink
Add missing functionality methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Aug 17, 2021
1 parent 5184e45 commit b405958
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 0 deletions.
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ declare namespace Eris {
type FriendSuggestionReasons = { name: string; platform_type: string; type: number }[];
type Status = "online" | "idle" | "dnd" | "offline";

// Thread
type EditThreadOptions = Pick<EditChannelOptions, "archived" | "autoArchiveDuration" | "locked" | "name" | "rateLimitPerUser">;

// Voice
type ConverterCommand = "./ffmpeg" | "./avconv" | "ffmpeg" | "avconv";
type StageInstancePrivacyLevel = 1 | 2;
Expand Down Expand Up @@ -2432,6 +2435,11 @@ declare namespace Eris {

export class NewsThreadChannel extends ThreadChannel {
type: 10;
createMessage(content: AdvancedMessageContent, file?: MessageFile | MessageFile): Promise<Message<NewsThreadChannel>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<NewsThreadChannel>>;
getMessage(messageID: string): Promise<Message<NewsThreadChannel>>;
getMessages(options?: GetMessagesOptions): Promise<Message<NewsThreadChannel>[]>;
getPins(): Promise<Message<NewsThreadChannel>[]>;
}

export class Permission extends Base {
Expand Down Expand Up @@ -2499,10 +2507,20 @@ declare namespace Eris {

export class PrivateThreadChannel extends ThreadChannel {
type: 12;
createMessage(content: AdvancedMessageContent, file?: MessageFile | MessageFile): Promise<Message<PrivateThreadChannel>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<PrivateThreadChannel>>;
getMessage(messageID: string): Promise<Message<PrivateThreadChannel>>;
getMessages(options?: GetMessagesOptions): Promise<Message<PrivateThreadChannel>[]>;
getPins(): Promise<Message<PrivateThreadChannel>[]>;
}

export class PublicThreadChannel extends ThreadChannel {
type: 10 | 11;
createMessage(content: AdvancedMessageContent, file?: MessageFile | MessageFile): Promise<Message<PublicThreadChannel>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<PublicThreadChannel>>;
getMessage(messageID: string): Promise<Message<PublicThreadChannel>>;
getMessages(options?: GetMessagesOptions): Promise<Message<PublicThreadChannel>[]>;
getPins(): Promise<Message<PublicThreadChannel>[]>;
}

export class Relationship extends Base implements Omit<Presence, "activities"> {
Expand Down Expand Up @@ -2740,9 +2758,27 @@ declare namespace Eris {
threadMetadata: ThreadMetadata;
type: 10 | 11 | 12;
constructor(data: BaseData, client: Client, messageLimit?: number);
addMessageReaction(messageID: string, reaction: string): Promise<void>;
createMessage(content: AdvancedMessageContent, file?: MessageFile | MessageFile): Promise<Message<ThreadChannel>>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
edit(options: Pick<EditChannelOptions, "archived" | "autoArchiveDuration" | "locked" | "name" | "rateLimitPerUser">, reason?: string): Promise<this>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<ThreadChannel>>;
getMembers(): Promise<ThreadMember[]>;
getMessage(messageID: string): Promise<Message<ThreadChannel>>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
getMessages(options?: GetMessagesOptions): Promise<Message<ThreadChannel>[]>;
getPins(): Promise<Message<ThreadChannel>[]>;
join(userID?: string): Promise<void>;
leave(userID?: string): Promise<void>;
pinMessage(messageID: string): Promise<void>;
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>;
unpinMessage(messageID: string): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}

export class ThreadMember extends Base {
Expand Down
198 changes: 198 additions & 0 deletions lib/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,82 @@ class ThreadChannel extends GuildChannel {
}
}

/**
* Add a reaction to a message
* @arg {String} messageID The ID of the message
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
* @returns {Promise}
*/
addMessageReaction(messageID, reaction) {
return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction);
}

/**
* Create a message in the channel
* @arg {String | Object} content A string or object. If an object is passed:
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
* @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
* @arg {String} content.content A content string
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Object} [file] A file object
* @arg {Buffer} file.file A buffer containing file data
* @arg {String} file.name What to name the file
* @returns {Promise<Message>}
*/
createMessage(content, file) {
return this.client.createMessage.call(this.client, this.id, content, file);
}

/**
* Delete a message
* @arg {String} messageID The ID of the message
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise}
*/
deleteMessage(messageID, reason) {
return this.client.deleteMessage.call(this.client, this.id, messageID, reason);
}

/**
* Bulk delete messages (bot accounts only)
* @arg {Array<String>} messageIDs Array of message IDs to delete
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise}
*/
deleteMessages(messageIDs, reason) {
return this.client.deleteMessages.call(this.client, this.id, messageIDs, reason);
}

/**
* Edit a message
* @arg {String} messageID The ID of the message
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
* @arg {String} content.content A content string
* @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default)
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
* @arg {Buffer} content.file[].file A buffer containing file data
* @arg {String} content.file[].name What to name the file
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
* @returns {Promise<Message>}
*/
editMessage(messageID, content) {
return this.client.editMessage.call(this.client, this.id, messageID, content);
}

/**
* Get a list of members that are part of this thread channel
Expand All @@ -71,6 +147,49 @@ class ThreadChannel extends GuildChannel {
return this.client.getThreadMembers.call(this.client, this.id);
}

/**
* Get a previous message in the channel
* @arg {String} messageID The ID of the message
* @returns {Promise<Message>}
*/
getMessage(messageID) {
return this.client.getMessage.call(this.client, this.id, messageID);
}

/**
* Get a list of users who reacted with a specific reaction
* @arg {String} messageID The ID of the message
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
* @arg {Object} [options] Options for the request.
* @arg {Number} [options.limit=100] The maximum number of users to get
* @arg {String} [options.after] Get users after this user ID
* @returns {Promise<Array<User>>}
*/
getMessageReaction(messageID, reaction, options) {
return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options);
}

/**
* Get previous messages in the channel
* @arg {Object} [options] Options for the request
* @arg {String} [options.after] Get messages after this message ID
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
* @arg {String} [options.before] Get messages before this message ID
* @arg {Number} [options.limit=50] The max number of messages to get
* @returns {Promise<Array<Message>>}
*/
getMessages(options) {
return this.client.getMessages.call(this.client, this.id, options);
}

/**
* Get all the pins in the channel
* @returns {Promise<Array<Message>>}
*/
getPins() {
return this.client.getPins.call(this.client, this.id);
}

/**
* Join a thread
* @arg {String} [userID="@me"] The user ID of the user joining
Expand All @@ -89,6 +208,85 @@ class ThreadChannel extends GuildChannel {
return this.client.leaveThread.call(this.client, this.id, userID);
}

/**
* Pin a message
* @arg {String} messageID The ID of the message
* @returns {Promise}
*/
pinMessage(messageID) {
return this.client.pinMessage.call(this.client, this.id, messageID);
}

/**
* Purge previous messages in the channel with an optional filter (bot accounts only)
* @arg {Object} options Options for the request. If this is a number
* @arg {String} [options.after] Get messages after this message ID
* @arg {String} [options.before] Get messages before this message ID
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
* @arg {String} [options.reason] The reason to be displayed in audit logs
* @returns {Promise<Number>} Resolves with the number of messages deleted
*/
purge(options) {
return this.client.purgeChannel.call(this.client, this.id, options);
}

/**
* Remove a reaction from a message
* @arg {String} messageID The ID of the message
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
* @returns {Promise}
*/
removeMessageReaction(messageID, reaction, userID) {
return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID);
}

/**
* Remove all reactions from a message for a single emoji
* @arg {String} messageID The ID of the message
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
* @returns {Promise}
*/
removeMessageReactionEmoji(messageID, reaction) {
return this.client.removeMessageReactionEmoji.call(this.client, this.id, messageID, reaction);
}

/**
* Remove all reactions from a message
* @arg {String} messageID The ID of the message
* @returns {Promise}
*/
removeMessageReactions(messageID) {
return this.client.removeMessageReactions.call(this.client, this.id, messageID);
}

/**
* Send typing status in the channel
* @returns {Promise}
*/
sendTyping() {
return this.client.sendChannelTyping.call(this.client, this.id);
}

/**
* Unpin a message
* @arg {String} messageID The ID of the message
* @returns {Promise}
*/
unpinMessage(messageID) {
return this.client.unpinMessage.call(this.client, this.id, messageID);
}

/**
* Un-send a message. You're welcome Programmix
* @arg {String} messageID The ID of the message
* @returns {Promise}
*/
unsendMessage(messageID) {
return this.client.deleteMessage.call(this.client, this.id, messageID);
}

toJSON(props = []) {
return super.toJSON([
"lastMessageID",
Expand Down

0 comments on commit b405958

Please sign in to comment.