Skip to content

Commit

Permalink
Update method names and docs to match Discord
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Aug 17, 2021
1 parent a3b0fea commit 6709477
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
14 changes: 7 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1697,10 +1697,10 @@ declare namespace Eris {
createGuildFromTemplate(code: string, name: string, icon?: string): Promise<Guild>;
createGuildTemplate(guildID: string, name: string, description?: string | null): Promise<GuildTemplate>;
createMessage(channelID: string, content: MessageContent, file?: MessageFile | MessageFile[]): Promise<Message>;
createPrivateThread(channelID: string, options: CreateThreadOptions): Promise<PrivateThreadChannel>;
createPublicThread(channelID: string, options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
createRole(guildID: string, options?: RoleOptions | Role, reason?: string): Promise<Role>;
createStageInstance(channelID: string, options: StageInstanceOptions): Promise<StageInstance>;
createThreadWithMessage(channelID: string, options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
createThreadWithoutMessage(channelID: string, options: CreateThreadOptions): Promise<PrivateThreadChannel>;
crosspostMessage(channelID: string, messageID: string): Promise<Message>;
deleteChannel(channelID: string, reason?: string): Promise<void>;
deleteChannelPermission(channelID: string, overwriteID: string, reason?: string): Promise<void>;
Expand Down Expand Up @@ -2393,7 +2393,7 @@ declare namespace Eris {
addReaction(reaction: string): Promise<void>;
/** @deprecated */
addReaction(reaction: string, userID: string): Promise<void>;
createPublicThread(options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise<NewsThreadChannel | PublicThreadChannel>;
crosspost(): Promise<T extends NewsChannel ? Message<NewsChannel> : never>;
delete(reason?: string): Promise<void>;
deleteWebhook(token: string): Promise<void>;
Expand All @@ -2415,7 +2415,7 @@ declare namespace Eris {
type: 5;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", NewsChannel>>;
createMessage(content: MessageContent, file?: MessageFile | MessageFile[]): Promise<Message<NewsChannel>>;
createPublicThread(messageID: string, options: CreateThreadOptions): Promise<NewsThreadChannel>;
createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise<NewsThreadChannel>;
crosspostMessage(messageID: string): Promise<Message<NewsChannel>>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<NewsChannel>>;
follow(webhookChannelID: string): Promise<ChannelFollow>;
Expand Down Expand Up @@ -2499,7 +2499,7 @@ declare namespace Eris {
}

export class PublicThreadChannel extends ThreadChannel {
type: 11;
type: 10 | 11;
}

export class Relationship extends Base implements Omit<Presence, "activities"> {
Expand Down Expand Up @@ -2692,8 +2692,8 @@ declare namespace Eris {
addMessageReaction(messageID: string, reaction: string, userID: string): Promise<void>;
createInvite(options?: CreateInviteOptions, reason?: string): Promise<Invite<"withMetadata", TextChannel>>;
createMessage(content: MessageContent, file?: MessageFile | MessageFile[]): Promise<Message<TextChannel>>;
createPrivateThread(options: CreateThreadOptions): Promise<PrivateThreadChannel>;
createPublicThread(messageID: string, options: CreateThreadOptions): Promise<PublicThreadChannel>;
createThreadWithoutMessage(options: CreateThreadOptions): Promise<PrivateThreadChannel>;
createThreadWithMessage(messageID: string, options: CreateThreadOptions): Promise<PublicThreadChannel>;
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>;
Expand Down
74 changes: 37 additions & 37 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,37 +639,6 @@ class Client extends EventEmitter {
return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this));
}

/**
* Create a private thread
* @arg {String} channelID The ID of the channel
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<PrivateThreadChannel>}
*/
createPrivateThread(channelID, options) {
return this.requestHandler.request("POST", Endpoints.GUILD_THREAD_PRIVATE(channelID), true, {
name: options.name,
auto_archive_duration: options.autoArchiveDuration
}).then((channel) => Channel.from(channel, this));
}

/**
* Create a public thread
* @arg {String} channelID The ID of the channel
* @arg {String} messageID The ID of the message to create the thread from
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
*/
createPublicThread(channelID, messageID, options) {
return this.requestHandler.request("POST", Endpoints.GUILD_THREAD_PUBLIC(channelID, messageID), true, {
name: options.name,
auto_archive_duration: options.autoArchiveDuration
}).then((channel) => Channel.from(channel, this));
}

/**
* Create a guild role
* @arg {String} guildID The ID of the guild to create the role in
Expand Down Expand Up @@ -719,6 +688,37 @@ class Client extends EventEmitter {
}).then((instance) => new StageInstance(instance, this));
}

/**
* Create a thread with an existing message
* @arg {String} channelID The ID of the channel
* @arg {String} messageID The ID of the message to create the thread from
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
*/
createThreadWithMessage(channelID, messageID, options) {
return this.requestHandler.request("POST", Endpoints.THREAD_WITH_MESSAGE(channelID, messageID), true, {
name: options.name,
auto_archive_duration: options.autoArchiveDuration
}).then((channel) => Channel.from(channel, this));
}

/**
* Create a thread without an existing message
* @arg {String} channelID The ID of the channel
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<PrivateThreadChannel>}
*/
createThreadWithoutMessage(channelID, options) {
return this.requestHandler.request("POST", Endpoints.THREAD_WITHOUT_MESSAGE(channelID), true, {
name: options.name,
auto_archive_duration: options.autoArchiveDuration
}).then((channel) => Channel.from(channel, this));
}

/**
* Crosspost (publish) a message to subscribed channels
* @arg {String} channelID The ID of the NewsChannel
Expand Down Expand Up @@ -1685,7 +1685,7 @@ class Client extends EventEmitter {
* @returns {Promise<Array<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>>}
*/
getActiveThreads(channelID) {
return this.requestHandler.request("GET", Endpoints.GUILD_THREADS_ACTIVE(channelID), true).then((channels) => channels.map((c) => Channel.from(c, this)));
return this.requestHandler.request("GET", Endpoints.THREADS_ACTIVE(channelID), true).then((channels) => channels.map((c) => Channel.from(c, this)));
}

/**
Expand All @@ -1698,7 +1698,7 @@ class Client extends EventEmitter {
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getArchivedThreads(channelID, type, options = {}) {
return this.requestHandler.request("GET", Endpoints.GUILD_THREADS_ARCHIVED(channelID, type), true, options).then((response) => {
return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED(channelID, type), true, options).then((response) => {
return {
hasMore: response.has_more,
members: response.members.map((member) => new ThreadMember(member, this)),
Expand Down Expand Up @@ -2001,7 +2001,7 @@ class Client extends EventEmitter {
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getJoinedPrivateArchivedThreads(channelID, options = {}) {
return this.requestHandler.request("GET", Endpoints.GUILD_THREADS_ARCHIVED_JOINED(channelID), true, options).then((response) => {
return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED_JOINED(channelID), true, options).then((response) => {
return {
hasMore: response.has_more,
members: response.members.map((member) => new ThreadMember(member, this)),
Expand Down Expand Up @@ -2377,7 +2377,7 @@ class Client extends EventEmitter {
* @returns {Promise<Array<ThreadMember>>}
*/
getThreadMembers(channelID) {
return this.requestHandler.request("GET", Endpoints.GUILD_THREAD_MEMBERS(channelID), true).then((members) => members.map((member) => new ThreadMember(member, this)));
return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true).then((members) => members.map((member) => new ThreadMember(member, this)));
}

/**
Expand Down Expand Up @@ -2426,7 +2426,7 @@ class Client extends EventEmitter {
* @returns {Promise}
*/
joinThread(channelID, userID = "@me") {
return this.requestHandler.request("PUT", Endpoints.GUILD_THREAD_MEMBER(channelID, userID), true);
return this.requestHandler.request("PUT", Endpoints.THREAD_MEMBER(channelID, userID), true);
}

/**
Expand Down Expand Up @@ -2486,7 +2486,7 @@ class Client extends EventEmitter {
* @returns {Promise}
*/
leaveThread(channelID, userID = "@me") {
return this.requestHandler.request("DELETE", Endpoints.GUILD_THREAD_MEMBER(channelID, userID), true);
return this.requestHandler.request("DELETE", Endpoints.THREAD_MEMBER(channelID, userID), true);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions lib/rest/Endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ module.exports.GUILD_ROLES = (guildID)
module.exports.GUILD_TEMPLATE = (code) => `/guilds/templates/${code}`;
module.exports.GUILD_TEMPLATES = (guildID) => `/guilds/${guildID}/templates`;
module.exports.GUILD_TEMPLATE_GUILD = (guildID, code) => `/guilds/${guildID}/templates/${code}`;
module.exports.GUILD_THREAD_MEMBER = (channelID, userID) => `/channels/${channelID}/thread-members/${userID}`;
module.exports.GUILD_THREAD_MEMBERS = (channelID) => `/channels/${channelID}/thread-members`;
module.exports.GUILD_THREAD_PRIVATE = (channelID) => `/channels/${channelID}/threads`;
module.exports.GUILD_THREAD_PUBLIC = (channelID, msgID) => `/channels/${channelID}/messages/${msgID}/threads`;
module.exports.GUILD_THREADS_ACTIVE = (channelID) => `/channels/${channelID}/threads/active`;
module.exports.GUILD_THREADS_ARCHIVED = (channelID, type) => `/channels/${channelID}/threads/archived/${type}`;
module.exports.GUILD_THREADS_ARCHIVED_JOINED = (channelID) => `/channels/${channelID}/users/@me/threads/archived/private`;
module.exports.GUILD_VOICE_REGIONS = (guildID) => `/guilds/${guildID}/regions`;
module.exports.GUILD_WEBHOOKS = (guildID) => `/guilds/${guildID}/webhooks`;
module.exports.GUILD_WELCOME_SCREEN = (guildID) => `/guilds/${guildID}/welcome-screen`;
Expand All @@ -76,6 +69,13 @@ module.exports.INVITE = (inviteID)
module.exports.OAUTH2_APPLICATION = (appID) => `/oauth2/applications/${appID}`;
module.exports.STAGE_INSTANCE = (channelID) => `/stage-instances/${channelID}`;
module.exports.STAGE_INSTANCES = "/stage-instances";
module.exports.THREAD_MEMBER = (channelID, userID) => `/channels/${channelID}/thread-members/${userID}`;
module.exports.THREAD_MEMBERS = (channelID) => `/channels/${channelID}/thread-members`;
module.exports.THREAD_WITH_MESSAGE = (channelID, msgID) => `/channels/${channelID}/messages/${msgID}/threads`;
module.exports.THREAD_WITHOUT_MESSAGE = (channelID) => `/channels/${channelID}/threads`;
module.exports.THREADS_ACTIVE = (channelID) => `/channels/${channelID}/threads/active`;
module.exports.THREADS_ARCHIVED = (channelID, type) => `/channels/${channelID}/threads/archived/${type}`;
module.exports.THREADS_ARCHIVED_JOINED = (channelID) => `/channels/${channelID}/users/@me/threads/archived/private`;
module.exports.USER = (userID) => `/users/${userID}`;
module.exports.USER_BILLING = (userID) => `/users/${userID}/billing`;
module.exports.USER_BILLING_PAYMENTS = (userID) => `/users/${userID}/billing/payments`;
Expand Down
6 changes: 3 additions & 3 deletions lib/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,14 @@ class Message extends Base {
}

/**
* Create a public thread from this message
* Create a thread with this message
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
*/
createPublicThread(options) {
return this.client.createPublicThread.call(this.client, this.channel.id, this.id, options);
createThreadWithMessage(options) {
return this.client.createThreadWithMessage.call(this.client, this.channel.id, this.id, options);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,26 @@ class TextChannel extends GuildChannel {
}

/**
* Create a private thread
* Create a thread with an existing message
* @arg {String} messageID The ID of the message to create the thread from
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<PrivateThreadChannel>}
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
*/
createPrivateThread(options) {
return this.client.createPrivateThread.call(this.client, this.id, options);
createThreadWithMessage(messageID, options) {
return this.client.createThreadWithMessage.call(this.client, this.id, messageID, options);
}

/**
* Create a public thread
* @arg {String} messageID The ID of the message to create the thread from
* Create a thread without an existing message
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {String} options.name The thread channel name
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
* @returns {Promise<PrivateThreadChannel>}
*/
createPublicThread(messageID, options) {
return this.client.createPublicThread.call(this.client, this.id, messageID, options);
createThreadWithoutMessage(options) {
return this.client.createThreadWithoutMessage.call(this.client, this.id, options);
}

/**
Expand Down

0 comments on commit 6709477

Please sign in to comment.