mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
Fix: typing (#2589)
* deno fmt * import SortOrderTypes * add bigString to reverse snowflake
This commit is contained in:
@@ -421,7 +421,7 @@ export interface Transformers {
|
||||
user: (bot: Bot, payload: User) => DiscordUser;
|
||||
team: (bot: Bot, payload: Team) => DiscordTeam;
|
||||
application: (bot: Bot, payload: Application) => DiscordApplication;
|
||||
snowflake: (snowflake: bigint) => string;
|
||||
snowflake: (snowflake: BigString) => string;
|
||||
createApplicationCommand: (bot: Bot, payload: CreateApplicationCommand) => DiscordCreateApplicationCommand;
|
||||
applicationCommand: (bot: Bot, payload: ApplicationCommand) => DiscordApplicationCommand;
|
||||
applicationCommandOption: (bot: Bot, payload: ApplicationCommandOption) => DiscordApplicationCommandOption;
|
||||
|
||||
@@ -18,7 +18,9 @@ export function calculateBasePermissions(
|
||||
memberOrId: bigint | Member,
|
||||
) {
|
||||
const guild = typeof guildOrId === "bigint" ? bot.guilds.get(guildOrId) : guildOrId;
|
||||
const member = typeof memberOrId === "bigint" ? bot.members.get(bot.transformers.snowflake(`${memberOrId}${guild?.id}`)) : memberOrId;
|
||||
const member = typeof memberOrId === "bigint"
|
||||
? bot.members.get(bot.transformers.snowflake(`${memberOrId}${guild?.id}`))
|
||||
: memberOrId;
|
||||
|
||||
if (!guild || !member) return 8n;
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@ export function isQueueClearable(queue: QueueBucket) {
|
||||
if (!queue.interval) return false;
|
||||
if (queue.processing) return false;
|
||||
if (queue.processingPending) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export function createInvalidRequestBucket(options: InvalidRequestBucketOptions)
|
||||
if (!bucket.errorStatuses.includes(code)) return;
|
||||
// Shared scope is not considered invalid
|
||||
if (code === 429 && sharedScope) return;
|
||||
|
||||
|
||||
// INVALID REQUEST WAS MADE
|
||||
|
||||
// If it was not frozen before, mark it frozen
|
||||
|
||||
@@ -70,9 +70,7 @@ export function createQueueBucket(rest: RestManager, options: QueueBucketOptions
|
||||
bucket.processingPending = true;
|
||||
|
||||
while (bucket.pending.length) {
|
||||
|
||||
if (bucket.firstRequest || bucket.isRequestAllowed()) {
|
||||
|
||||
const [queuedRequest] = bucket.pending;
|
||||
if (queuedRequest) {
|
||||
const basicURL = rest.simplifyUrl(queuedRequest.request.url, queuedRequest.request.method);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RestRequest,RestPayload } from "./rest.ts";
|
||||
import { RestPayload, RestRequest } from "./rest.ts";
|
||||
import { RestManager } from "./restManager.ts";
|
||||
|
||||
export async function processGlobalQueue(rest: RestManager, request: {
|
||||
|
||||
+4
-1
@@ -97,7 +97,10 @@ export async function sendRequest<T>(rest: RestManager, options: RestSendRequest
|
||||
return;
|
||||
} // RATE LIMITED, ADD BACK TO QUEUE
|
||||
else {
|
||||
rest.invalidBucket.handleCompletedRequest(response.status, response.headers.get('X-RateLimit-Scope') === 'shared');
|
||||
rest.invalidBucket.handleCompletedRequest(
|
||||
response.status,
|
||||
response.headers.get("X-RateLimit-Scope") === "shared",
|
||||
);
|
||||
await delay(json.retry_after * 1000);
|
||||
return options.retryRequest?.();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
ScheduledEventEntityType,
|
||||
ScheduledEventPrivacyLevel,
|
||||
ScheduledEventStatus,
|
||||
SortOrderTypes,
|
||||
StickerFormatTypes,
|
||||
StickerTypes,
|
||||
SystemChannelFlags,
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ export function snowflakeToBigint(snowflake: BigString) {
|
||||
return BigInt(snowflake) | 0n;
|
||||
}
|
||||
|
||||
export function bigintToSnowflake(snowflake: bigint) {
|
||||
export function bigintToSnowflake(snowflake: BigString) {
|
||||
return snowflake === 0n ? "" : snowflake.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user