diff --git a/src/helpers/misc/edit_bot_status.ts b/src/helpers/misc/edit_bot_status.ts new file mode 100644 index 000000000..7a1917492 --- /dev/null +++ b/src/helpers/misc/edit_bot_status.ts @@ -0,0 +1,23 @@ +import { eventHandlers } from "../../bot.ts"; +import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; +import { StatusUpdate } from "../../types/gateway/status_update.ts"; +import { ws } from "../../ws/ws.ts"; + +export function editBotStatus(data: Omit) { + ws.shards.forEach((shard) => { + eventHandlers.debug?.( + "loop", + `Running forEach loop in editBotStatus function.` + ); + shard.ws.send( + JSON.stringify({ + op: DiscordGatewayOpcodes.StatusUpdate, + d: { + since: null, + afk: false, + ...data, + }, + }) + ); + }); +} diff --git a/src/util/utils.ts b/src/util/utils.ts index c47e6d266..2a87114a1 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -1,36 +1,11 @@ import { encode } from "../../deps.ts"; import { eventHandlers } from "../bot.ts"; -import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts"; -import { StatusUpdate } from "../types/gateway/status_update.ts"; import { DiscordApplicationCommandOptionTypes } from "../types/interactions/application_command_option_types.ts"; import { Errors } from "../types/misc/errors.ts"; import { DiscordImageFormat } from "../types/misc/image_format.ts"; import { DiscordImageSize } from "../types/misc/image_size.ts"; -import { ws } from "../ws/ws.ts"; import { SLASH_COMMANDS_NAME_REGEX } from "./constants.ts"; -// TODO: move this function to helpers -export function editBotStatus( - data: Omit, -) { - ws.shards.forEach((shard) => { - eventHandlers.debug?.( - "loop", - `Running forEach loop in editBotStatus function.`, - ); - shard.ws.send( - JSON.stringify({ - op: DiscordGatewayOpcodes.StatusUpdate, - d: { - since: null, - afk: false, - ...data, - }, - }), - ); - }); -} - export async function urlToBase64(url: string) { const buffer = await fetch(url).then((res) => res.arrayBuffer()); const imageStr = encode(buffer);