mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 01:40:08 +00:00
refactor: move edit_bot_status to another file in helpers (#838)
This commit is contained in:
23
src/helpers/misc/edit_bot_status.ts
Normal file
23
src/helpers/misc/edit_bot_status.ts
Normal file
@@ -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<StatusUpdate, "afk" | "since">) {
|
||||
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,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -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<StatusUpdate, "afk" | "since">,
|
||||
) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user