mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
f
This commit is contained in:
@@ -32,7 +32,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) {
|
||||
|
||||
await cacheHandlers.delete("channels", payload.id);
|
||||
cacheHandlers.forEach("messages", (message) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach messages loop in CHANNEL_DELTE file.`,
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function handleGuildDelete(
|
||||
}
|
||||
|
||||
cacheHandlers.forEach("messages", (message) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running forEach messages loop in CHANNEL_DELTE file.`,
|
||||
);
|
||||
@@ -37,7 +37,7 @@ export async function handleGuildDelete(
|
||||
});
|
||||
|
||||
cacheHandlers.forEach("channels", (channel) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running forEach channels loop in CHANNEL_DELTE file.`,
|
||||
);
|
||||
@@ -47,7 +47,7 @@ export async function handleGuildDelete(
|
||||
});
|
||||
|
||||
cacheHandlers.forEach("members", (member) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`3. Running forEach members loop in CHANNEL_DELTE file.`,
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
const roleIds = guildMember.roles || [];
|
||||
|
||||
roleIds.forEach((id) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running forEach loop in GUILD_MEMBER_UPDATE file.`,
|
||||
);
|
||||
@@ -56,7 +56,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
});
|
||||
|
||||
payload.roles.forEach((id) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running forEach loop in GUILD_MEMBER_UPDATE file.`,
|
||||
);
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function handleReady(
|
||||
|
||||
// Start ready check in 2 seconds
|
||||
setTimeout(async () => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running setTimeout in READY file.`,
|
||||
);
|
||||
@@ -60,7 +60,7 @@ async function checkReady(payload: DiscordReady, shardId: number, now: number) {
|
||||
} else {
|
||||
// Not all guilds were loaded but 10 seconds haven't passed so check again
|
||||
setTimeout(async () => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running setTimeout in READY file.`,
|
||||
);
|
||||
@@ -84,7 +84,7 @@ async function loaded(shardId: number) {
|
||||
// Still some shards are loading so wait another 2 seconds for them
|
||||
if (ws.shards.some((shard) => !shard.ready)) {
|
||||
setTimeout(async () => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`3. Running setTimeout in CHANNEL_DELTE file.`,
|
||||
);
|
||||
@@ -96,7 +96,7 @@ async function loaded(shardId: number) {
|
||||
|
||||
// All the members that came in on guild creates should now be processed 1 by 1
|
||||
for (const [guildId, members] of initialMemberLoadQueue.entries()) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
"Running for of loop in READY file for loading members.",
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function handleUserUpdate(data: DiscordGatewayPayload) {
|
||||
if (!member) return;
|
||||
|
||||
Object.entries(userData).forEach(([key, value]) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in USER_UPDATE file.`,
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) {
|
||||
|
||||
// For bots without GUILD_MEMBERS member.roles is never updated breaking permissions checking.
|
||||
cacheHandlers.forEach("members", (member) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running forEach members loop in GUILD_ROLE_DELETE file.`,
|
||||
);
|
||||
@@ -23,7 +23,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) {
|
||||
if (!member.guilds.has(guild.id)) return;
|
||||
|
||||
member.guilds.forEach((g) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running forEach loop in CHANNEL_DELTE file.`,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function createChannel(
|
||||
const requiredPerms: Set<PermissionStrings> = new Set(["MANAGE_CHANNELS"]);
|
||||
|
||||
options?.permissionOverwrites?.forEach((overwrite) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in create_channel file.`,
|
||||
);
|
||||
|
||||
@@ -78,7 +78,7 @@ function processEditChannelQueue() {
|
||||
|
||||
const now = Date.now();
|
||||
editChannelNameTopicQueue.forEach((request) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in edit_channel file.`,
|
||||
);
|
||||
@@ -102,7 +102,7 @@ function processEditChannelQueue() {
|
||||
|
||||
if (editChannelNameTopicQueue.size) {
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running setTimeout in EDIT_CHANNEL file.`,
|
||||
);
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function sendInteractionResponse(
|
||||
cache.executedSlashCommands.set(token, id);
|
||||
setTimeout(
|
||||
() => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running setTimeout in send_interaction_response file.`,
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function getEmojis(guildId: string, addToCache = true) {
|
||||
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
||||
|
||||
result.forEach((emoji) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in get_emojis file.`,
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) {
|
||||
(options?.limit ?? guild.memberCount) > members.size &&
|
||||
membersLeft > 0
|
||||
) {
|
||||
eventHandlers.debug("loop", "Running while loop in getMembers function.");
|
||||
eventHandlers.debug?.("loop", "Running while loop in getMembers function.");
|
||||
|
||||
if (options?.limit && options.limit > 1000) {
|
||||
console.log(
|
||||
@@ -67,7 +67,7 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) {
|
||||
if (!memberStructures.length) break;
|
||||
|
||||
memberStructures.forEach((member) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in get_members file.`,
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function addReactions(
|
||||
);
|
||||
} else {
|
||||
for (const reaction of reactions) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
"Running for of loop in addReactions function.",
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { rest } from "./rest.ts";
|
||||
/** Cleans up the queues by checking if there is nothing left and removing it. */
|
||||
export function cleanupQueues() {
|
||||
for (const [key, queue] of rest.pathQueues) {
|
||||
rest.eventHandlers.debug(
|
||||
rest.eventHandlers.debug?.(
|
||||
"loop",
|
||||
"Running for of loop in cleanupQueues function.",
|
||||
);
|
||||
|
||||
@@ -9,14 +9,14 @@ export async function processQueue(id: string) {
|
||||
if (!queue) return;
|
||||
|
||||
while (queue.length) {
|
||||
rest.eventHandlers.debug(
|
||||
rest.eventHandlers.debug?.(
|
||||
"loop",
|
||||
"Running while loop in processQueue function.",
|
||||
);
|
||||
// IF THE BOT IS GLOBALLY RATELIMITED TRY AGAIN
|
||||
if (rest.globallyRateLimited) {
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running setTimeout in processQueue function.`,
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ export function processRateLimitedPaths() {
|
||||
const now = Date.now();
|
||||
|
||||
rest.ratelimitedPaths.forEach((value, key) => {
|
||||
rest.eventHandlers.debug(
|
||||
rest.eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in process_rate_limited_paths file.`,
|
||||
);
|
||||
@@ -26,7 +26,7 @@ export function processRateLimitedPaths() {
|
||||
rest.processingRateLimitedPaths = true;
|
||||
// RECHECK IN 1 SECOND
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running setTimeout in processRateLimitedPaths function.`,
|
||||
);
|
||||
|
||||
@@ -82,7 +82,7 @@ export async function createChannelStruct(
|
||||
|
||||
const props: Record<string, PropertyDescriptor> = {};
|
||||
Object.keys(rest).forEach((key) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in createChannelStruct function.`,
|
||||
);
|
||||
|
||||
@@ -147,7 +147,7 @@ export async function createGuildStruct(
|
||||
|
||||
const props: Record<string, ReturnType<typeof createNewProp>> = {};
|
||||
for (const key of Object.keys(rest)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in createGuildStruct function.`,
|
||||
);
|
||||
|
||||
@@ -88,7 +88,7 @@ export async function createMemberStruct(
|
||||
const props: Record<string, ReturnType<typeof createNewProp>> = {};
|
||||
|
||||
for (const key of Object.keys(rest)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop for Object.keys(rest) in createMemberStruct function.`,
|
||||
);
|
||||
@@ -97,7 +97,7 @@ export async function createMemberStruct(
|
||||
}
|
||||
|
||||
for (const key of Object.keys(user)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of for Object.keys(user) loop in createMemberStruct function.`,
|
||||
);
|
||||
@@ -114,7 +114,7 @@ export async function createMemberStruct(
|
||||
const cached = await cacheHandlers.get("members", user.id);
|
||||
if (cached) {
|
||||
for (const [id, guild] of cached.guilds.entries()) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of for cached.guilds.entries() loop in createMemberStruct function.`,
|
||||
);
|
||||
|
||||
@@ -130,7 +130,7 @@ export async function createMessageStruct(data: DiscordMessage) {
|
||||
|
||||
const props: Record<string, ReturnType<typeof createNewProp>> = {};
|
||||
for (const key of Object.keys(rest)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in createMessageStruct function.`,
|
||||
);
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function createRoleStruct(data: DiscordGuildRoleCreate) {
|
||||
|
||||
const props: Record<string, ReturnType<typeof createNewProp>> = {};
|
||||
for (const key of Object.keys(rest)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in createRoleStruct function.`,
|
||||
);
|
||||
|
||||
@@ -26,7 +26,7 @@ export function createTemplateStruct(
|
||||
|
||||
const restProps: Record<string, Partial<PropertyDescriptor>> = {};
|
||||
for (const key of Object.keys(rest)) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in createTemplateStruct function.`,
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ export function editBotStatus(
|
||||
data: Pick<GatewayStatusUpdatePayload, "activities" | "status">,
|
||||
) {
|
||||
ws.shards.forEach((shard) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in editBotStatus function.`,
|
||||
);
|
||||
@@ -85,7 +85,7 @@ export function camelKeysToSnakeCase<T>(
|
||||
const convertedObject: Record<string, any> = {};
|
||||
|
||||
Object.keys(obj).forEach((key) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in camelKeysToSnakeCase function.`,
|
||||
);
|
||||
@@ -111,7 +111,7 @@ export function snakeKeysToCamelCase<T>(
|
||||
const convertedObject: Record<string, any> = {};
|
||||
|
||||
Object.keys(obj).forEach((key) => {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in snakeKeysToCamelCase function.`,
|
||||
);
|
||||
@@ -134,7 +134,7 @@ function validateSlashOptionChoices(
|
||||
optionType: SlashCommandOptionType,
|
||||
) {
|
||||
for (const choice of choices) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in validateSlashOptionChoices function.`,
|
||||
);
|
||||
@@ -158,7 +158,7 @@ function validateSlashOptionChoices(
|
||||
/** @private */
|
||||
function validateSlashOptions(options: SlashCommandOption[]) {
|
||||
for (const option of options) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in validateSlashOptions function.`,
|
||||
);
|
||||
@@ -192,7 +192,7 @@ export function validateSlashCommands(
|
||||
create = false,
|
||||
) {
|
||||
for (const command of commands) {
|
||||
eventHandlers.debug(
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running for of loop in validateSlashCommands function.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user