mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
remove identifyPayload
This commit is contained in:
+3
-23
@@ -14,18 +14,6 @@ export let eventHandlers: EventHandlers = {};
|
|||||||
|
|
||||||
export let proxyWSURL = `wss://gateway.discord.gg`;
|
export let proxyWSURL = `wss://gateway.discord.gg`;
|
||||||
|
|
||||||
export const identifyPayload = {
|
|
||||||
token: "",
|
|
||||||
compress: true,
|
|
||||||
properties: {
|
|
||||||
$os: "linux",
|
|
||||||
$browser: "Discordeno",
|
|
||||||
$device: "Discordeno",
|
|
||||||
},
|
|
||||||
intents: 0,
|
|
||||||
shard: [0, 0],
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function startBot(config: BotConfig) {
|
export async function startBot(config: BotConfig) {
|
||||||
if (config.eventHandlers) eventHandlers = config.eventHandlers;
|
if (config.eventHandlers) eventHandlers = config.eventHandlers;
|
||||||
authorization = `Bot ${config.token}`;
|
authorization = `Bot ${config.token}`;
|
||||||
@@ -49,17 +37,8 @@ export async function startBot(config: BotConfig) {
|
|||||||
ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`;
|
ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`;
|
||||||
|
|
||||||
proxyWSURL = ws.botGatewayData.url;
|
proxyWSURL = ws.botGatewayData.url;
|
||||||
identifyPayload.token = config.token;
|
|
||||||
identifyPayload.intents = config.intents.reduce(
|
// ws.lastShardId = ws.maxShards;
|
||||||
(
|
|
||||||
bits,
|
|
||||||
next,
|
|
||||||
) => (bits |= typeof next === "string"
|
|
||||||
? DiscordGatewayIntents[next]
|
|
||||||
: next),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
identifyPayload.shard = [0, ws.botGatewayData.shards];
|
|
||||||
|
|
||||||
ws.spawnShards();
|
ws.spawnShards();
|
||||||
}
|
}
|
||||||
@@ -122,6 +101,7 @@ export async function startBigBrainBot(config: BigBrainBotConfig) {
|
|||||||
console.log(ws.botGatewayData);
|
console.log(ws.botGatewayData);
|
||||||
ws.maxShards = ws.maxShards || config.lastShardId ||
|
ws.maxShards = ws.maxShards || config.lastShardId ||
|
||||||
ws.botGatewayData.shards;
|
ws.botGatewayData.shards;
|
||||||
|
ws.lastShardId = config.lastShardId || ws.botGatewayData.shards;
|
||||||
// Explicitly append gateway version and encoding
|
// Explicitly append gateway version and encoding
|
||||||
ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`;
|
ws.botGatewayData.url += `?v=${GATEWAY_VERSION}&encoding=json`;
|
||||||
proxyWSURL = ws.botGatewayData.url;
|
proxyWSURL = ws.botGatewayData.url;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { identifyPayload } from "../../bot.ts";
|
|
||||||
import { DiscordenoMember } from "../../structures/member.ts";
|
import { DiscordenoMember } from "../../structures/member.ts";
|
||||||
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
||||||
import { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts";
|
import { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts";
|
||||||
import { Errors } from "../../types/misc/errors.ts";
|
import { Errors } from "../../types/misc/errors.ts";
|
||||||
import { Collection } from "../../util/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
|
import { ws } from "../../ws/ws.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
||||||
@@ -21,7 +21,7 @@ export function fetchMembers(
|
|||||||
// You can request 1 member without the intent
|
// You can request 1 member without the intent
|
||||||
if (
|
if (
|
||||||
(!options?.limit || options.limit > 1) &&
|
(!options?.limit || options.limit > 1) &&
|
||||||
!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)
|
!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)
|
||||||
) {
|
) {
|
||||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eventHandlers, identifyPayload } from "../../bot.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { cacheHandlers } from "../../cache.ts";
|
import { cacheHandlers } from "../../cache.ts";
|
||||||
import { rest } from "../../rest/rest.ts";
|
import { rest } from "../../rest/rest.ts";
|
||||||
import { DiscordenoMember } from "../../structures/member.ts";
|
import { DiscordenoMember } from "../../structures/member.ts";
|
||||||
@@ -12,6 +12,7 @@ import { ListGuildMembers } from "../../types/guilds/list_guild_members.ts";
|
|||||||
import { Errors } from "../../types/misc/errors.ts";
|
import { Errors } from "../../types/misc/errors.ts";
|
||||||
import { Collection } from "../../util/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
import { endpoints } from "../../util/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
|
import { ws } from "../../ws/ws.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
||||||
@@ -22,7 +23,7 @@ import { endpoints } from "../../util/constants.ts";
|
|||||||
* GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m.
|
* GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m.
|
||||||
*/
|
*/
|
||||||
export async function getMembers(guildId: string, options?: ListGuildMembers) {
|
export async function getMembers(guildId: string, options?: ListGuildMembers) {
|
||||||
if (!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
|
if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
|
||||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user