mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
9e664bfcbe
commit
7cfef63782
+41
-15
@@ -11,26 +11,52 @@ import {
|
||||
requireChannelPermissions,
|
||||
highestRole,
|
||||
higherRolePosition,
|
||||
requireBotChannelPermissions
|
||||
requireBotChannelPermissions,
|
||||
} from "./util/permissions.ts";
|
||||
import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts";
|
||||
import { checkRateLimits, processQueue, cleanupQueues, createRequestBody, processRateLimitedPaths, processRequest, processRequestHeaders, runMethod, processGlobalQueue, simplifyUrl } from "./rest/mod.ts";
|
||||
import {
|
||||
checkRateLimits,
|
||||
processQueue,
|
||||
cleanupQueues,
|
||||
createRequestBody,
|
||||
processRateLimitedPaths,
|
||||
processRequest,
|
||||
processRequestHeaders,
|
||||
runMethod,
|
||||
processGlobalQueue,
|
||||
simplifyUrl,
|
||||
} from "./rest/mod.ts";
|
||||
import type { RestPayload, RestRateLimitedPath, RestRequest } from "./rest/rest.ts";
|
||||
import { DiscordGatewayIntents } from "./types/gateway/gateway_intents.ts";
|
||||
import { GetGatewayBot } from "./types/gateway/get_gateway_bot.ts";
|
||||
import {bigintToSnowflake, snowflakeToBigint} from "./util/bigint.ts";
|
||||
import { bigintToSnowflake, snowflakeToBigint } from "./util/bigint.ts";
|
||||
import { Collection } from "./util/collection.ts";
|
||||
import {DiscordenoMember, DiscordenoUser, transformMember, transformUser, DiscordenoGuild, transformGuild, DiscordenoChannel, transformChannel, transformMessage, transformRole, DiscordenoVoiceState, transformVoiceState} from "./transformers/mod.ts";
|
||||
import {
|
||||
baseEndpoints, CHANNEL_MENTION_REGEX,
|
||||
CONTEXT_MENU_COMMANDS_NAME_REGEX, DISCORD_SNOWFLAKE_REGEX,
|
||||
DiscordenoMember,
|
||||
DiscordenoUser,
|
||||
transformMember,
|
||||
transformUser,
|
||||
DiscordenoGuild,
|
||||
transformGuild,
|
||||
DiscordenoChannel,
|
||||
transformChannel,
|
||||
transformMessage,
|
||||
transformRole,
|
||||
DiscordenoVoiceState,
|
||||
transformVoiceState,
|
||||
} from "./transformers/mod.ts";
|
||||
import {
|
||||
baseEndpoints,
|
||||
CHANNEL_MENTION_REGEX,
|
||||
CONTEXT_MENU_COMMANDS_NAME_REGEX,
|
||||
DISCORD_SNOWFLAKE_REGEX,
|
||||
DISCORDENO_VERSION,
|
||||
endpoints,
|
||||
SLASH_COMMANDS_NAME_REGEX,
|
||||
USER_AGENT
|
||||
USER_AGENT,
|
||||
} from "./util/constants.ts";
|
||||
import {Errors} from "./types/discordeno/errors.ts";
|
||||
import {GatewayPayload} from "./types/gateway/gateway_payload.ts";
|
||||
import { Errors } from "./types/discordeno/errors.ts";
|
||||
import { GatewayPayload } from "./types/gateway/gateway_payload.ts";
|
||||
import {
|
||||
closeWS,
|
||||
handleOnMessage,
|
||||
@@ -45,12 +71,12 @@ import {
|
||||
handleDiscordPayload,
|
||||
tellClusterToIdentify,
|
||||
sendShardMessage,
|
||||
DiscordenoShard
|
||||
DiscordenoShard,
|
||||
} from "./ws/mod.ts";
|
||||
import {validateLength} from "./util/validate_length.ts";
|
||||
import {delay, validateSlashOptionChoices, validateSlashOptions} from "./util/utils.ts";
|
||||
import {iconBigintToHash, iconHashToBigInt} from "./util/hash.ts";
|
||||
import {calculateShardId} from "./util/calculate_shard_id.ts";
|
||||
import { validateLength } from "./util/validate_length.ts";
|
||||
import { delay, validateSlashOptionChoices, validateSlashOptions } from "./util/utils.ts";
|
||||
import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts";
|
||||
import { calculateShardId } from "./util/calculate_shard_id.ts";
|
||||
|
||||
export async function createBot(options: CreateBotOptions) {
|
||||
return {
|
||||
@@ -531,6 +557,6 @@ export function createBotConstants() {
|
||||
CHANNEL_MENTION_REGEX,
|
||||
DISCORD_SNOWFLAKE_REGEX,
|
||||
},
|
||||
Errors
|
||||
Errors,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,5 +10,9 @@ export async function addReaction(bot: Bot, channelId: bigint, messageId: bigint
|
||||
reaction = reaction.substring(3, reaction.length - 1);
|
||||
}
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest, "put", bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction));
|
||||
return await bot.rest.runMethod<undefined>(
|
||||
bot.rest,
|
||||
"put",
|
||||
bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import {Bot} from "../../bot.ts";
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { addReaction } from "./add_reaction.ts";
|
||||
|
||||
/** Adds multiple reactions to a message. If `ordered` is true(default is false), it will add the reactions one at a time in the order provided. Note: Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */
|
||||
export async function addReactions(bot: Bot, channelId: bigint, messageId: bigint, reactions: string[], ordered = false) {
|
||||
export async function addReactions(
|
||||
bot: Bot,
|
||||
channelId: bigint,
|
||||
messageId: bigint,
|
||||
reactions: string[],
|
||||
ordered = false
|
||||
) {
|
||||
if (!ordered) {
|
||||
await Promise.all(reactions.map((reaction) => addReaction(bot, channelId, messageId, reaction)));
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,13 @@ import { cacheHandlers } from "../../cache.ts";
|
||||
import { delay } from "../../util/utils.ts";
|
||||
|
||||
/** Delete a message with the channel id and message id only. */
|
||||
export async function deleteMessage(bot: Bot, channelId: bigint, messageId: bigint, reason?: string, delayMilliseconds = 0) {
|
||||
export async function deleteMessage(
|
||||
bot: Bot,
|
||||
channelId: bigint,
|
||||
messageId: bigint,
|
||||
reason?: string,
|
||||
delayMilliseconds = 0
|
||||
) {
|
||||
const message = await cacheHandlers.get("messages", messageId);
|
||||
|
||||
if (message && message.authorId !== bot.id) {
|
||||
@@ -12,5 +18,10 @@ export async function deleteMessage(bot: Bot, channelId: bigint, messageId: bigi
|
||||
|
||||
if (delayMilliseconds) await delay(delayMilliseconds);
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.CHANNEL_MESSAGE(channelId, messageId), { reason });
|
||||
return await bot.rest.runMethod<undefined>(
|
||||
bot.rest,
|
||||
"delete",
|
||||
bot.constants.endpoints.CHANNEL_MESSAGE(channelId, messageId),
|
||||
{ reason }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export async function deleteMessages(bot: Bot, channelId: bigint, ids: bigint[],
|
||||
console.warn(`This endpoint only accepts a maximum of 100 messages. Deleting the first 100 message ids provided.`);
|
||||
}
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest,"post", bot.constants.endpoints.CHANNEL_BULK_DELETE(channelId), {
|
||||
return await bot.rest.runMethod<undefined>(bot.rest, "post", bot.constants.endpoints.CHANNEL_BULK_DELETE(channelId), {
|
||||
messages: ids.splice(0, 100),
|
||||
reason,
|
||||
});
|
||||
|
||||
@@ -3,8 +3,8 @@ import { EditMessage } from "../../types/messages/edit_message.ts";
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import type { PermissionStrings } from "../../types/permissions/permission_strings.ts";
|
||||
import { validateComponents } from "../../util/utils.ts";
|
||||
import {Bot} from "../../bot.ts";
|
||||
import {SnakeCasedPropertiesDeep} from "../../types/util.ts";
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Edit the message. */
|
||||
export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint, content: string | EditMessage) {
|
||||
@@ -32,7 +32,7 @@ export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint
|
||||
}
|
||||
|
||||
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(
|
||||
bot.rest,
|
||||
bot.rest,
|
||||
"patch",
|
||||
bot.constants.endpoints.CHANNEL_MESSAGE(channelId, messageId),
|
||||
bot.utils.snakelize(content)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import {Bot} from "../../bot.ts";
|
||||
import {SnakeCasedPropertiesDeep} from "../../types/util.ts";
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */
|
||||
export async function getMessage(bot: Bot, channelId: bigint, id: bigint) {
|
||||
@@ -9,7 +9,11 @@ export async function getMessage(bot: Bot, channelId: bigint, id: bigint) {
|
||||
await bot.utils.requireBotChannelPermissions(channelId, ["VIEW_CHANNEL", "READ_MESSAGE_HISTORY"]);
|
||||
}
|
||||
|
||||
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(bot.rest,"get", bot.constants.endpoints.CHANNEL_MESSAGE(channelId, id));
|
||||
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(
|
||||
bot.rest,
|
||||
"get",
|
||||
bot.constants.endpoints.CHANNEL_MESSAGE(channelId, id)
|
||||
);
|
||||
|
||||
return await bot.transformers.message(bot, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user