mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fix(snowflake): snowflakes length (#9144)
* fix(snowflake): fix snowflakes length * fix(snowflake): fix length
This commit is contained in:
@@ -148,7 +148,7 @@ class ThreadManager extends CachedManager {
|
|||||||
let id;
|
let id;
|
||||||
const query = makeURLSearchParams({ limit });
|
const query = makeURLSearchParams({ limit });
|
||||||
if (typeof before !== 'undefined') {
|
if (typeof before !== 'undefined') {
|
||||||
if (before instanceof ThreadChannel || /^\d{16,19}$/.test(String(before))) {
|
if (before instanceof ThreadChannel || /^\d{17,19}$/.test(String(before))) {
|
||||||
id = this.resolveId(before);
|
id = this.resolveId(before);
|
||||||
timestamp = this.resolve(before)?.archivedAt?.toISOString();
|
timestamp = this.resolve(before)?.archivedAt?.toISOString();
|
||||||
const toUse = type === 'private' && !fetchAll ? id : timestamp;
|
const toUse = type === 'private' && !fetchAll ? id : timestamp;
|
||||||
|
|||||||
@@ -499,14 +499,14 @@ export class RequestManager extends EventEmitter {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private static generateRouteData(endpoint: RouteLike, method: RequestMethod): RouteData {
|
private static generateRouteData(endpoint: RouteLike, method: RequestMethod): RouteData {
|
||||||
const majorIdMatch = /^\/(?:channels|guilds|webhooks)\/(\d{16,19})/.exec(endpoint);
|
const majorIdMatch = /^\/(?:channels|guilds|webhooks)\/(\d{17,19})/.exec(endpoint);
|
||||||
|
|
||||||
// Get the major id for this route - global otherwise
|
// Get the major id for this route - global otherwise
|
||||||
const majorId = majorIdMatch?.[1] ?? 'global';
|
const majorId = majorIdMatch?.[1] ?? 'global';
|
||||||
|
|
||||||
const baseRoute = endpoint
|
const baseRoute = endpoint
|
||||||
// Strip out all ids
|
// Strip out all ids
|
||||||
.replaceAll(/\d{16,19}/g, ':id')
|
.replaceAll(/\d{17,19}/g, ':id')
|
||||||
// Strip out reaction as they fall under the same bucket
|
// Strip out reaction as they fall under the same bucket
|
||||||
.replace(/\/reactions\/(.*)/, '/reactions/:reaction');
|
.replace(/\/reactions\/(.*)/, '/reactions/:reaction');
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ export class RequestManager extends EventEmitter {
|
|||||||
// Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket)
|
// Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket)
|
||||||
// https://github.com/discord/discord-api-docs/issues/1295
|
// https://github.com/discord/discord-api-docs/issues/1295
|
||||||
if (method === RequestMethod.Delete && baseRoute === '/channels/:id/messages/:id') {
|
if (method === RequestMethod.Delete && baseRoute === '/channels/:id/messages/:id') {
|
||||||
const id = /\d{16,19}$/.exec(endpoint)![0]!;
|
const id = /\d{17,19}$/.exec(endpoint)![0]!;
|
||||||
const timestamp = DiscordSnowflake.timestampFrom(id);
|
const timestamp = DiscordSnowflake.timestampFrom(id);
|
||||||
if (Date.now() - timestamp > 1_000 * 60 * 60 * 24 * 14) {
|
if (Date.now() - timestamp > 1_000 * 60 * 60 * 24 * 14) {
|
||||||
exceptions += '/Delete Old Message';
|
exceptions += '/Delete Old Message';
|
||||||
|
|||||||
Reference in New Issue
Block a user