mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
refactor: remove unused imports (#2021)
* make lib faster (delete unused import) * Revert deno.json change * Missing }
This commit is contained in:
37
src/bot.ts
37
src/bot.ts
@@ -1,19 +1,5 @@
|
||||
import {
|
||||
checkRateLimits,
|
||||
cleanupQueues,
|
||||
createRequestBody,
|
||||
createRestManager,
|
||||
CreateRestManagerOptions,
|
||||
processGlobalQueue,
|
||||
processQueue,
|
||||
processRateLimitedPaths,
|
||||
processRequest,
|
||||
processRequestHeaders,
|
||||
runMethod,
|
||||
simplifyUrl,
|
||||
} from "./rest/mod.ts";
|
||||
import type { RestPayload, RestRateLimitedPath, RestRequest } from "./rest/rest.ts";
|
||||
import { GatewayIntents, Intents } from "./types/gateway/gatewayIntents.ts";
|
||||
import { createRestManager, CreateRestManagerOptions } from "./rest/mod.ts";
|
||||
import { GatewayIntents } from "./types/gateway/gatewayIntents.ts";
|
||||
import { GetGatewayBot } from "./types/gateway/getGatewayBot.ts";
|
||||
import { bigintToSnowflake, snowflakeToBigint } from "./util/bigint.ts";
|
||||
import { Collection } from "./util/collection.ts";
|
||||
@@ -45,23 +31,7 @@ import {
|
||||
} from "./util/constants.ts";
|
||||
import { Errors } from "./types/discordeno/errors.ts";
|
||||
import { DiscordGatewayPayload, GatewayDispatchEventNames, GatewayPayload } from "./types/gateway/gatewayPayload.ts";
|
||||
import {
|
||||
closeWS,
|
||||
createGatewayManager,
|
||||
createShard,
|
||||
DiscordenoShard,
|
||||
GatewayManager,
|
||||
handleOnMessage,
|
||||
heartbeat,
|
||||
identify,
|
||||
prepareBuckets,
|
||||
processGatewayQueue,
|
||||
resharder,
|
||||
resume,
|
||||
sendShardMessage,
|
||||
spawnShards,
|
||||
tellWorkerToIdentify,
|
||||
} from "./ws/mod.ts";
|
||||
import { createGatewayManager, GatewayManager } from "./ws/mod.ts";
|
||||
import { validateLength } from "./util/validateLength.ts";
|
||||
import { delay, formatImageURL, hasProperty } from "./util/utils.ts";
|
||||
import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts";
|
||||
@@ -85,7 +55,6 @@ import { transformComponent } from "./transformers/component.ts";
|
||||
import { transformWebhook } from "./transformers/webhook.ts";
|
||||
import { transformAuditlogEntry } from "./transformers/auditlogEntry.ts";
|
||||
import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts";
|
||||
import { StatusUpdate } from "./types/gateway/statusUpdate.ts";
|
||||
import { calculateBits, calculatePermissions } from "./util/permissions.ts";
|
||||
import { transformScheduledEvent } from "./transformers/scheduledEvent.ts";
|
||||
import { DiscordenoScheduledEvent } from "./transformers/scheduledEvent.ts";
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Bot } from "../../bot.ts";
|
||||
import { ThreadListSync } from "../../types/channels/threads/threadListSync.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
|
||||
export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<ThreadListSync>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Channel } from "../../types/channels/channel.ts";
|
||||
import { ChannelTypes } from "../../types/channels/channelTypes.ts";
|
||||
import type { CreateGuildChannel, DiscordCreateGuildChannel } from "../../types/guilds/createGuildChannel.ts";
|
||||
import type { CreateGuildChannel } from "../../types/guilds/createGuildChannel.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ChannelTypes } from "../../types/channels/channelTypes.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { ListActiveThreads } from "../../../types/channels/threads/listActiveThreads.ts";
|
||||
import { ListPublicArchivedThreads } from "../../../types/channels/threads/listPublicArchivedThreads.ts";
|
||||
import { PermissionStrings } from "../../../types/permissions/permissionStrings.ts";
|
||||
import { Collection } from "../../../util/collection.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
// import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Get the archived threads for this channel, defaults to public */
|
||||
export async function getArchivedThreads(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ValidateDiscoverySearchTerm } from "../../types/discovery/validateDiscoverySearchTerm.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function validDiscoveryTerm(bot: Bot, term: string) {
|
||||
const result = await bot.rest.runMethod<ValidateDiscoverySearchTerm>(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Emoji } from "../../types/emojis/emoji.ts";
|
||||
import { Errors } from "../../types/discordeno/errors.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { Emoji } from "../../types/emojis/emoji.ts";
|
||||
import { Errors } from "../../types/discordeno/errors.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Bot } from "../../../bot.ts";
|
||||
import { EditScheduledEvent, ScheduledEvent, ScheduledEventEntityType } from "../../../types/guilds/scheduledEvents.ts";
|
||||
import { EditScheduledEvent, ScheduledEvent } from "../../../types/guilds/scheduledEvents.ts";
|
||||
|
||||
/** Modify a guild scheduled event. To start or end an event, use this endpoint to modify the event's status. */
|
||||
export async function editScheduledEvent(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { DiscordenoEditWebhookMessage } from "../../../types/discordeno/editWebhookMessage.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { AllowedMentionsTypes } from "../../../types/messages/allowedMentionsTypes.ts";
|
||||
import { MessageComponentTypes } from "../../../types/messages/components/messageComponentTypes.ts";
|
||||
|
||||
/** To edit your response to a application command. If a messageId is not provided it will default to editing the original response. */
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { EditGlobalApplicationCommand } from "../../../types/interactions/c
|
||||
import type { MakeRequired } from "../../../types/util.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { Collection } from "../../../util/collection.ts";
|
||||
import { ApplicationCommandOption } from "../../../types/interactions/commands/applicationCommandOption.ts";
|
||||
import { makeOptionsForCommand } from "./createApplicationCommand.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Bot } from "../../../bot.ts";
|
||||
import { AllowedMentionsTypes } from "../../../types/messages/allowedMentionsTypes.ts";
|
||||
import { MessageComponentTypes } from "../../../types/messages/components/messageComponentTypes.ts";
|
||||
import { Message } from "../../../types/messages/message.ts";
|
||||
import { EditWebhookMessage } from "../../../types/webhooks/editWebhookMessage.ts";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Returns the initial Interaction response. Functions the same as Get Webhook Message */
|
||||
export async function getOriginalInteractionResponse(bot: Bot, token: string) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { InviteMetadata } from "../../types/invites/inviteMetadata.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import type { RequestGuildMembers } from "../../types/members/requestGuildMembers.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { GatewayIntents } from "../../types/gateway/gatewayIntents.ts";
|
||||
import { GatewayOpcodes } from "../../types/codes/gatewayOpcodes.ts";
|
||||
import type { DiscordenoMember } from "../../transformers/member.ts";
|
||||
|
||||
/**
|
||||
* Highly recommended to use this function to fetch members instead of getMember from REST.
|
||||
|
||||
@@ -2,7 +2,6 @@ import type { GuildMemberWithUser } from "../../types/members/guildMember.ts";
|
||||
import type { ListGuildMembers } from "../../types/members/listGuildMembers.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import type { DiscordenoMember } from "../../transformers/member.ts";
|
||||
|
||||
/**
|
||||
* Highly recommended to **NOT** use this function to get members instead use fetchMembers().
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Crosspost a message in a News Channel to following channels. */
|
||||
export async function publishMessage(bot: Bot, channelId: bigint, messageId: bigint) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { AllowedMentionsTypes } from "../../types/messages/allowedMentionsTypes.ts";
|
||||
import type { CreateMessage } from "../../types/messages/createMessage.ts";
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Errors } from "../../types/discordeno/errors.ts";
|
||||
import type { User } from "../../types/users/user.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { GetGatewayBot } from "../../types/gateway/getGatewayBot.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */
|
||||
export async function getGatewayBot(bot: Bot): Promise<GetGatewayBot> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { User } from "../../types/users/user.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */
|
||||
export async function getUser(bot: Bot, userId: bigint) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ModifyWebhook } from "../../types/webhooks/modifyWebhook.ts";
|
||||
import type { Webhook } from "../../types/webhooks/webhook.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Edit a webhook. Returns the updated webhook object on success. */
|
||||
export async function editWebhookWithToken(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { Webhook } from "../../types/webhooks/webhook.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
/** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */
|
||||
export async function getWebhooks(bot: Bot, guildId: bigint) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { AllowedMentionsTypes } from "../../types/messages/allowedMentionsTypes.ts";
|
||||
import type { Message } from "../../types/messages/message.ts";
|
||||
import type { ExecuteWebhook } from "../../types/webhooks/executeWebhook.ts";
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { AuditLogEntry } from "../types/auditLog/auditLogEntry.ts";
|
||||
import { AuditLogEvents } from "../types/auditLog/auditLogEvents.ts";
|
||||
import { DiscordOverwrite, Overwrite } from "../types/channels/overwrite.ts";
|
||||
import { Role } from "../types/permissions/role.ts";
|
||||
import { DiscordOverwrite } from "../types/channels/overwrite.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
|
||||
import { DiscordenoUser } from "./member.ts";
|
||||
|
||||
export function transformAuditlogEntry(
|
||||
bot: Bot,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import type { Emoji } from "../types/emojis/emoji.ts";
|
||||
import type { Guild } from "../types/guilds/guild.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
import { DiscordenoRole } from "./role.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Bot } from "../bot.ts";
|
||||
import { Invite, InviteCreate, TargetTypes } from "../types/mod.ts";
|
||||
import { InviteCreate, TargetTypes } from "../types/mod.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
|
||||
import { DiscordenoApplication } from "./application.ts";
|
||||
import { DiscordenoUser } from "./member.ts";
|
||||
|
||||
@@ -2,7 +2,6 @@ import { FileContent } from "../../discordeno/fileContent.ts";
|
||||
import { Embed } from "../../embeds/embed.ts";
|
||||
import { AllowedMentions } from "../../messages/allowedMentions.ts";
|
||||
import { MessageComponents } from "../../messages/components/messageComponents.ts";
|
||||
import { CreateMessage } from "../../messages/createMessage.ts";
|
||||
import { ApplicationCommandOptionChoice } from "./applicationCommandOptionChoice.ts";
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { SnakeCasedPropertiesDeep } from "../../util.ts";
|
||||
import { ButtonStyles } from "./buttonStyles.ts";
|
||||
import { MessageComponentTypes } from "./messageComponentTypes.ts";
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Embed } from "../embeds/embed.ts";
|
||||
import { AllowedMentions } from "../messages/allowedMentions.ts";
|
||||
import { MessageReference } from "../messages/messageReference.ts";
|
||||
import { FileContent } from "../discordeno/fileContent.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../util.ts";
|
||||
import { MessageComponents } from "./components/messageComponents.ts";
|
||||
|
||||
Reference in New Issue
Block a user