Skip to content

Commit

Permalink
feat(gateway/REST): V10 API changes (#1371)
Browse files Browse the repository at this point in the history
Co-authored-by: Bsian <[email protected]>
  • Loading branch information
coolcalcacol and bsian03 authored Jan 5, 2024
1 parent 65ab78b commit a331615
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 41 deletions.
13 changes: 5 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ declare namespace Eris {
icon: string | null;
id: string;
name: string;
summary: string;
summary: ""; // Returns an empty string
}
interface IntegrationOptions {
enableEmoticons?: string;
Expand Down Expand Up @@ -1798,10 +1798,11 @@ declare namespace Eris {
directMessages: 4096;
directMessageReactions: 8192;
directMessageTyping: 16384;
guildScheduledEvents: 65536;
messageContent: 32768;
guildScheduledEvents: 65536
allNonPrivileged: 98045;
allPrivileged: 258;
all: 98303;
allPrivileged: 33026;
all: 131071;
};
InteractionResponseTypes: {
PONG: 1;
Expand Down Expand Up @@ -2488,8 +2489,6 @@ declare namespace Eris {
executeWebhook(webhookID: string, token: string, options: WebhookPayload): Promise<void>;
followChannel(channelID: string, webhookChannelID: string): Promise<ChannelFollow>;
getActiveGuildThreads(guildID: string): Promise<ListedGuildThreads>;
/** @deprecated */
getActiveThreads(channelID: string): Promise<ListedChannelThreads>;
getArchivedThreads(channelID: string, type: "private", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getArchivedThreads(channelID: string, type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getBotGateway(): Promise<{ session_start_limit: { max_concurrency: number; remaining: number; reset_after: number; total: number }; shards: number; url: string }>;
Expand Down Expand Up @@ -3645,8 +3644,6 @@ declare namespace Eris {
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
edit(options: Omit<EditChannelOptions, "icon" | "ownerID">, reason?: string): Promise<this>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<this>>;
/** @deprecated */
getActiveThreads(): Promise<ListedChannelThreads>;
getArchivedThreads(type: "private", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PrivateThreadChannel>>;
getArchivedThreads(type: "public", options?: GetArchivedThreadsOptions): Promise<ListedChannelThreads<PublicThreadChannel>>;
getInvites(): Promise<(Invite<"withMetadata", this>)[]>;
Expand Down
15 changes: 0 additions & 15 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2266,21 +2266,6 @@ class Client extends EventEmitter {
});
}

/**
* [DEPRECATED] Get all active threads in a channel. Use getActiveGuildThreads instead
* @arg {String} channelID The ID of the channel
* @returns {Promise<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
*/
getActiveThreads(channelID) {
return this.requestHandler.request("GET", Endpoints.THREADS_ACTIVE(channelID), true).then((response) => {
return {
hasMore: response.has_more,
members: response.members.map((member) => new ThreadMember(member, this)),
threads: response.threads.map((thread) => Channel.from(thread, this))
};
});
}

/**
* Get all archived threads in a channel
* @arg {String} channelID The ID of the channel
Expand Down
10 changes: 6 additions & 4 deletions lib/Constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

module.exports.GATEWAY_VERSION = 9;
module.exports.REST_VERSION = 9;
module.exports.GATEWAY_VERSION = 10;
module.exports.REST_VERSION = 10;

module.exports.ActivityTypes = {
GAME: 0,
Expand Down Expand Up @@ -234,9 +234,10 @@ const Intents = {
directMessages: 1 << 12,
directMessageReactions: 1 << 13,
directMessageTyping: 1 << 14,

messageContent: 1 << 15,
guildScheduledEvents: 1 << 16
};

Intents.allNonPrivileged = Intents.guilds
| Intents.guildBans
| Intents.guildEmojisAndStickers
Expand All @@ -252,7 +253,8 @@ Intents.allNonPrivileged = Intents.guilds
| Intents.directMessageTyping
| Intents.guildScheduledEvents;
Intents.allPrivileged = Intents.guildMembers
| Intents.guildPresences;
| Intents.guildPresences
| Intents.messageContent;
Intents.all = Intents.allNonPrivileged | Intents.allPrivileged;
module.exports.Intents = Intents;

Expand Down
1 change: 0 additions & 1 deletion lib/rest/Endpoints.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions lib/rest/RequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ class RequestHandler {
}
}
headers["X-Audit-Log-Reason"] = encodeURIComponent(unencodedReason);
if((method !== "PUT" || !url.includes("/bans")) && (method !== "POST" || !url.includes("/prune"))) {
delete body.reason;
} else {
body.reason = unencodedReason;
}
delete body.reason;

}
if(file) {
data = new MultipartData();
Expand Down
8 changes: 0 additions & 8 deletions lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,6 @@ class TextChannel extends GuildChannel {
return this.client.editMessage.call(this.client, this.id, messageID, content);
}

/**
* [DEPRECATED] Get all active threads in this channel. Use guild.getActiveThreads instead
* @returns {Promise<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
*/
getActiveThreads() {
return this.client.getActiveThreads.call(this.client, this.id);
}

/**
* Get all archived threads in this channel
* @arg {String} type The type of thread channel, either "public" or "private"
Expand Down

0 comments on commit a331615

Please sign in to comment.