mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Remove changes of helpers, will change them on another pr
This commit is contained in:
@@ -6,6 +6,7 @@ import type { ModifyGuild } from "../../types/guilds/modify_guild.ts";
|
|||||||
import { endpoints } from "../../util/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||||
import { snakelize, urlToBase64 } from "../../util/utils.ts";
|
import { snakelize, urlToBase64 } from "../../util/utils.ts";
|
||||||
|
import { ws } from "../../ws/ws.ts";
|
||||||
|
|
||||||
/** Modify a guilds settings. Requires the MANAGE_GUILD permission. */
|
/** Modify a guilds settings. Requires the MANAGE_GUILD permission. */
|
||||||
export async function editGuild(guildId: bigint, options: ModifyGuild) {
|
export async function editGuild(guildId: bigint, options: ModifyGuild) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Errors } from "../../types/discordeno/errors.ts";
|
|||||||
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
||||||
import type { RequestGuildMembers } from "../../types/members/request_guild_members.ts";
|
import type { RequestGuildMembers } from "../../types/members/request_guild_members.ts";
|
||||||
import { Collection } from "../../util/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
import {GatewayManager} from "../../bot.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()
|
||||||
@@ -15,10 +15,10 @@ import {GatewayManager} from "../../bot.ts";
|
|||||||
* REST: 50/s global(across all shards) rate limit with ALL requests this included
|
* REST: 50/s global(across all shards) rate limit with ALL requests this included
|
||||||
* GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m.
|
* GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m.
|
||||||
*/
|
*/
|
||||||
export function fetchMembers(gateway: GatewayManager, guildId: bigint, shardId: number, options?: Omit<RequestGuildMembers, "guildId">) {
|
export function fetchMembers(guildId: bigint, shardId: number, options?: Omit<RequestGuildMembers, "guildId">) {
|
||||||
// You can request 1 member without the intent
|
// You can request 1 member without the intent
|
||||||
// Check if intents is not 0 as proxy gateway won't set intents in other instances
|
// Check if intents is not 0 as proxy ws won't set intents in other instances
|
||||||
if (gateway.identifyPayload.intents && (!options?.limit || options.limit > 1) && !(gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
|
if (ws.identifyPayload.intents && (!options?.limit || options.limit > 1) && !(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
|
||||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export function fetchMembers(gateway: GatewayManager, guildId: bigint, shardId:
|
|||||||
const nonce = `${guildId}-${Date.now()}`;
|
const nonce = `${guildId}-${Date.now()}`;
|
||||||
cache.fetchAllMembersProcessingRequests.set(nonce, resolve);
|
cache.fetchAllMembersProcessingRequests.set(nonce, resolve);
|
||||||
|
|
||||||
gateway.sendShardMessage(gateway, shardId, {
|
ws.sendShardMessage(shardId, {
|
||||||
op: DiscordGatewayOpcodes.RequestGuildMembers,
|
op: DiscordGatewayOpcodes.RequestGuildMembers,
|
||||||
d: {
|
d: {
|
||||||
guild_id: guildId,
|
guild_id: guildId,
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import {eventHandlers, GatewayManager} from "../../bot.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
|
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
|
||||||
import type { StatusUpdate } from "../../types/gateway/status_update.ts";
|
import type { StatusUpdate } from "../../types/gateway/status_update.ts";
|
||||||
import { snakelize } from "../../util/utils.ts";
|
import { snakelize } from "../../util/utils.ts";
|
||||||
|
import { ws } from "../../ws/ws.ts";
|
||||||
|
|
||||||
export function editBotStatus(gateway: GatewayManager, data: Omit<StatusUpdate, "afk" | "since">) {
|
export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) {
|
||||||
gateway.shards.forEach((shard) => {
|
ws.shards.forEach((shard) => {
|
||||||
eventHandlers.debug?.("loop", `Running forEach loop in editBotStatus function.`);
|
eventHandlers.debug?.("loop", `Running forEach loop in editBotStatus function.`);
|
||||||
|
|
||||||
gateway.sendShardMessage(gateway, shard, {
|
ws.sendShardMessage(shard, {
|
||||||
op: DiscordGatewayOpcodes.StatusUpdate,
|
op: DiscordGatewayOpcodes.StatusUpdate,
|
||||||
d: {
|
d: {
|
||||||
since: null,
|
since: null,
|
||||||
|
|||||||
@@ -3,19 +3,18 @@ import type { UpdateVoiceState } from "../../types/voice/update_voice_state.ts";
|
|||||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||||
import { calculateShardId } from "../../util/calculate_shard_id.ts";
|
import { calculateShardId } from "../../util/calculate_shard_id.ts";
|
||||||
import { snakelize } from "../../util/utils.ts";
|
import { snakelize } from "../../util/utils.ts";
|
||||||
|
import { ws } from "../../ws/ws.ts";
|
||||||
import type { AtLeastOne } from "../../types/util.ts";
|
import type { AtLeastOne } from "../../types/util.ts";
|
||||||
import {GatewayManager} from "../../bot.ts";
|
|
||||||
|
|
||||||
/** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */
|
/** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */
|
||||||
export async function connectToVoiceChannel(
|
export async function connectToVoiceChannel(
|
||||||
gateway: GatewayManager,
|
|
||||||
guildId: bigint,
|
guildId: bigint,
|
||||||
channelId: bigint,
|
channelId: bigint,
|
||||||
options?: AtLeastOne<Omit<UpdateVoiceState, "guildId" | "channelId">>
|
options?: AtLeastOne<Omit<UpdateVoiceState, "guildId" | "channelId">>
|
||||||
) {
|
) {
|
||||||
await requireBotChannelPermissions(channelId, ["CONNECT", "VIEW_CHANNEL"]);
|
await requireBotChannelPermissions(channelId, ["CONNECT", "VIEW_CHANNEL"]);
|
||||||
|
|
||||||
gateway.sendShardMessage(gateway, calculateShardId(gateway, guildId), {
|
ws.sendShardMessage(calculateShardId(guildId), {
|
||||||
op: DiscordGatewayOpcodes.VoiceStateUpdate,
|
op: DiscordGatewayOpcodes.VoiceStateUpdate,
|
||||||
d: snakelize<UpdateVoiceState>({
|
d: snakelize<UpdateVoiceState>({
|
||||||
guildId,
|
guildId,
|
||||||
|
|||||||
Reference in New Issue
Block a user