diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 42ad9a86c..609f329d2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing - Read the [style guide](#style-guide). -- Ask for help on the [official Discord server](https:) +- Ask for help on the [official Discord server](https://discord.gg/5vBgXk3UcZ) - If you are going to work on an issue, mention so in the issue comments before you start working on the issue. - If you are going to work on a new feature, create an issue and discuss with @@ -38,10 +38,9 @@ ## Types Guide -- Must use snake case (according to Discord API). +- Must use camel case (same property name as in the docs just in camel case). - Each field or property must be accompanied with a reasonable JSDoc comment right above its type definition. -- The name of the type must be prefixed with `Discord`. - Must be placed inside of the types module (in `src/types` directory). Example: @@ -61,6 +60,4 @@ export interface User { flags?: number; premiumType?: number; } - -export type DiscordUser = SnakeCasedPropertiesDeep; ``` diff --git a/src/bot.ts b/src/bot.ts index f23043674..ae0dc92ff 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,6 +1,6 @@ import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts"; import { rest } from "./rest/rest.ts"; -import { EventHandlers } from "./types/discordeno/eventHandlers.ts"; +import type { EventHandlers } from "./types/discordeno/eventHandlers.ts"; import { DiscordGatewayIntents } from "./types/gateway/gateway_intents.ts"; import { snowflakeToBigint } from "./util/bigint.ts"; import { baseEndpoints, GATEWAY_VERSION } from "./util/constants.ts"; diff --git a/src/cache.ts b/src/cache.ts index 3beadbb7b..6da6e43ed 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -1,10 +1,10 @@ // deno-lint-ignore-file require-await no-explicit-any prefer-const -import { DiscordenoChannel } from "./structures/channel.ts"; -import { DiscordenoGuild } from "./structures/guild.ts"; -import { DiscordenoMember } from "./structures/member.ts"; -import { DiscordenoMessage } from "./structures/message.ts"; -import { Emoji } from "./types/emojis/emoji.ts"; -import { PresenceUpdate } from "./types/misc/presence_update.ts"; +import type { DiscordenoChannel } from "./structures/channel.ts"; +import type { DiscordenoGuild } from "./structures/guild.ts"; +import type { DiscordenoMember } from "./structures/member.ts"; +import type { DiscordenoMessage } from "./structures/message.ts"; +import type { Emoji } from "./types/emojis/emoji.ts"; +import type { PresenceUpdate } from "./types/misc/presence_update.ts"; import { Collection } from "./util/collection.ts"; export const cache = { diff --git a/src/handlers/channels/CHANNEL_CREATE.ts b/src/handlers/channels/CHANNEL_CREATE.ts index 135dbc0d9..679241f19 100644 --- a/src/handlers/channels/CHANNEL_CREATE.ts +++ b/src/handlers/channels/CHANNEL_CREATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Channel } from "../../types/channels/channel.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; export async function handleChannelCreate(data: DiscordGatewayPayload) { const payload = data.d as Channel; diff --git a/src/handlers/channels/CHANNEL_DELETE.ts b/src/handlers/channels/CHANNEL_DELETE.ts index f81341b08..511aae6c9 100644 --- a/src/handlers/channels/CHANNEL_DELETE.ts +++ b/src/handlers/channels/CHANNEL_DELETE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { Channel } from "../../types/channels/channel.ts"; +import type { Channel } from "../../types/channels/channel.ts"; import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleChannelDelete(data: DiscordGatewayPayload) { diff --git a/src/handlers/channels/CHANNEL_PINS_UPDATE.ts b/src/handlers/channels/CHANNEL_PINS_UPDATE.ts index b5570bc2e..529e33195 100644 --- a/src/handlers/channels/CHANNEL_PINS_UPDATE.ts +++ b/src/handlers/channels/CHANNEL_PINS_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { ChannelPinsUpdate } from "../../types/channels/channel_pins_update.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { ChannelPinsUpdate } from "../../types/channels/channel_pins_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleChannelPinsUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/channels/CHANNEL_UPDATE.ts b/src/handlers/channels/CHANNEL_UPDATE.ts index 4a30abb2f..59a0d8693 100644 --- a/src/handlers/channels/CHANNEL_UPDATE.ts +++ b/src/handlers/channels/CHANNEL_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Channel } from "../../types/channels/channel.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleChannelUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/commands/APPLICATION_COMMAND_CREATE.ts b/src/handlers/commands/APPLICATION_COMMAND_CREATE.ts index 2ceae936b..c52eddfa1 100644 --- a/src/handlers/commands/APPLICATION_COMMAND_CREATE.ts +++ b/src/handlers/commands/APPLICATION_COMMAND_CREATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { ApplicationCommandCreateUpdateDelete, } from "../../types/interactions/application_command_create_update_delete.ts"; diff --git a/src/handlers/commands/APPLICATION_COMMAND_DELETE.ts b/src/handlers/commands/APPLICATION_COMMAND_DELETE.ts index 63d96b23e..674b23330 100644 --- a/src/handlers/commands/APPLICATION_COMMAND_DELETE.ts +++ b/src/handlers/commands/APPLICATION_COMMAND_DELETE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { ApplicationCommandCreateUpdateDelete, } from "../../types/interactions/application_command_create_update_delete.ts"; diff --git a/src/handlers/commands/APPLICATION_COMMAND_UPDATE.ts b/src/handlers/commands/APPLICATION_COMMAND_UPDATE.ts index ad9ffde28..b5ac20ee3 100644 --- a/src/handlers/commands/APPLICATION_COMMAND_UPDATE.ts +++ b/src/handlers/commands/APPLICATION_COMMAND_UPDATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { ApplicationCommandCreateUpdateDelete, } from "../../types/interactions/application_command_create_update_delete.ts"; diff --git a/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts b/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts index bbb1c817d..04dba3335 100644 --- a/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts +++ b/src/handlers/emojis/GUILD_EMOJIS_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { GuildEmojisUpdate } from "../../types/emojis/guild_emojis_update.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildEmojisUpdate } from "../../types/emojis/guild_emojis_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { Collection } from "../../util/collection.ts"; diff --git a/src/handlers/guilds/GUILD_BAN_ADD.ts b/src/handlers/guilds/GUILD_BAN_ADD.ts index 70d233ff0..584369503 100644 --- a/src/handlers/guilds/GUILD_BAN_ADD.ts +++ b/src/handlers/guilds/GUILD_BAN_ADD.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildBanAdd(data: DiscordGatewayPayload) { diff --git a/src/handlers/guilds/GUILD_BAN_REMOVE.ts b/src/handlers/guilds/GUILD_BAN_REMOVE.ts index eb588bd2c..8e7805fbe 100644 --- a/src/handlers/guilds/GUILD_BAN_REMOVE.ts +++ b/src/handlers/guilds/GUILD_BAN_REMOVE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildBanRemove(data: DiscordGatewayPayload) { diff --git a/src/handlers/guilds/GUILD_CREATE.ts b/src/handlers/guilds/GUILD_CREATE.ts index a9cc05791..3c62e57ea 100644 --- a/src/handlers/guilds/GUILD_CREATE.ts +++ b/src/handlers/guilds/GUILD_CREATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cache, cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { Guild } from "../../types/guilds/guild.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { ws } from "../../ws/ws.ts"; diff --git a/src/handlers/guilds/GUILD_DELETE.ts b/src/handlers/guilds/GUILD_DELETE.ts index 5b32388e8..ea30c220b 100644 --- a/src/handlers/guilds/GUILD_DELETE.ts +++ b/src/handlers/guilds/GUILD_DELETE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { UnavailableGuild } from "../../types/guilds/unavailable_guild.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { UnavailableGuild } from "../../types/guilds/unavailable_guild.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { ws } from "../../ws/ws.ts"; diff --git a/src/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts b/src/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts index 36b013ec6..136db1a4d 100644 --- a/src/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts +++ b/src/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildIntegrationsUpdate } from "../../types/integration/guild_integrations_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildIntegrationsUpdate } from "../../types/integration/guild_integrations_update.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildIntegrationsUpdate( diff --git a/src/handlers/guilds/GUILD_UPDATE.ts b/src/handlers/guilds/GUILD_UPDATE.ts index 9504e9df0..173337717 100644 --- a/src/handlers/guilds/GUILD_UPDATE.ts +++ b/src/handlers/guilds/GUILD_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { GuildUpdateChange } from "../../types/discordeno/guild_update_change.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { Guild } from "../../types/guilds/guild.ts"; +import type { GuildUpdateChange } from "../../types/discordeno/guild_update_change.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/integrations/INTEGRATION_CREATE.ts b/src/handlers/integrations/INTEGRATION_CREATE.ts index 1f6aede60..147831a5a 100644 --- a/src/handlers/integrations/INTEGRATION_CREATE.ts +++ b/src/handlers/integrations/INTEGRATION_CREATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { IntegrationCreateUpdate, } from "../../types/integration/integration_create_update.ts"; diff --git a/src/handlers/integrations/INTEGRATION_DELETE.ts b/src/handlers/integrations/INTEGRATION_DELETE.ts index 1718d2a3c..d7fcbe088 100644 --- a/src/handlers/integrations/INTEGRATION_DELETE.ts +++ b/src/handlers/integrations/INTEGRATION_DELETE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { IntegrationDelete } from "../../types/integration/integration_delete.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { IntegrationDelete } from "../../types/integration/integration_delete.ts"; export function handleIntegrationDelete(data: DiscordGatewayPayload) { eventHandlers.integrationDelete?.( diff --git a/src/handlers/integrations/INTEGRATION_UPDATE.ts b/src/handlers/integrations/INTEGRATION_UPDATE.ts index c756ee2b3..4ce7fa940 100644 --- a/src/handlers/integrations/INTEGRATION_UPDATE.ts +++ b/src/handlers/integrations/INTEGRATION_UPDATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { IntegrationCreateUpdate, } from "../../types/integration/integration_create_update.ts"; diff --git a/src/handlers/interactions/INTERACTION_CREATE.ts b/src/handlers/interactions/INTERACTION_CREATE.ts index 026af104c..6c5a03913 100644 --- a/src/handlers/interactions/INTERACTION_CREATE.ts +++ b/src/handlers/interactions/INTERACTION_CREATE.ts @@ -1,9 +1,9 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; -import { Interaction } from "../../types/interactions/interaction.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { Interaction } from "../../types/interactions/interaction.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleInteractionCreate(data: DiscordGatewayPayload) { diff --git a/src/handlers/invites/INVITE_CREATE.ts b/src/handlers/invites/INVITE_CREATE.ts index bb5a4d8c7..44ffec43f 100644 --- a/src/handlers/invites/INVITE_CREATE.ts +++ b/src/handlers/invites/INVITE_CREATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { InviteCreate } from "../../types/invites/invite_create.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { InviteCreate } from "../../types/invites/invite_create.ts"; export function handleInviteCreate(data: DiscordGatewayPayload) { eventHandlers.inviteCreate?.( diff --git a/src/handlers/invites/INVITE_DELETE.ts b/src/handlers/invites/INVITE_DELETE.ts index 6c7b137a8..2f09e6f52 100644 --- a/src/handlers/invites/INVITE_DELETE.ts +++ b/src/handlers/invites/INVITE_DELETE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { InviteDelete } from "../../types/invites/invite_delete.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { InviteDelete } from "../../types/invites/invite_delete.ts"; export function handleInviteDelete(data: DiscordGatewayPayload) { eventHandlers.inviteDelete?.( diff --git a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts index f1b76e556..65d1eeb76 100644 --- a/src/handlers/members/GUILD_MEMBERS_CHUNK.ts +++ b/src/handlers/members/GUILD_MEMBERS_CHUNK.ts @@ -1,7 +1,7 @@ import { cache, cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMembersChunk } from "../../types/members/guild_members_chunk.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMembersChunk } from "../../types/members/guild_members_chunk.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { Collection } from "../../util/collection.ts"; diff --git a/src/handlers/members/GUILD_MEMBER_ADD.ts b/src/handlers/members/GUILD_MEMBER_ADD.ts index 7743d3d75..8e6e597de 100644 --- a/src/handlers/members/GUILD_MEMBER_ADD.ts +++ b/src/handlers/members/GUILD_MEMBER_ADD.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMemberAdd } from "../../types/members/guild_member_add.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMemberAdd } from "../../types/members/guild_member_add.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildMemberAdd(data: DiscordGatewayPayload) { diff --git a/src/handlers/members/GUILD_MEMBER_REMOVE.ts b/src/handlers/members/GUILD_MEMBER_REMOVE.ts index 9a18461f0..dfc051200 100644 --- a/src/handlers/members/GUILD_MEMBER_REMOVE.ts +++ b/src/handlers/members/GUILD_MEMBER_REMOVE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMemberRemove } from "../../types/members/guild_member_remove.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMemberRemove } from "../../types/members/guild_member_remove.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildMemberRemove(data: DiscordGatewayPayload) { diff --git a/src/handlers/members/GUILD_MEMBER_UPDATE.ts b/src/handlers/members/GUILD_MEMBER_UPDATE.ts index 05c4f5a38..72185ddb8 100644 --- a/src/handlers/members/GUILD_MEMBER_UPDATE.ts +++ b/src/handlers/members/GUILD_MEMBER_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMemberUpdate } from "../../types/members/guild_member_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMemberUpdate } from "../../types/members/guild_member_update.ts"; import { bigintToSnowflake, snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/messages/MESSAGE_CREATE.ts b/src/handlers/messages/MESSAGE_CREATE.ts index 51d6856cc..5492f8664 100644 --- a/src/handlers/messages/MESSAGE_CREATE.ts +++ b/src/handlers/messages/MESSAGE_CREATE.ts @@ -1,9 +1,9 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { Message } from "../../types/messages/message.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleMessageCreate(data: DiscordGatewayPayload) { diff --git a/src/handlers/messages/MESSAGE_DELETE.ts b/src/handlers/messages/MESSAGE_DELETE.ts index 078d6cfb2..89430f202 100644 --- a/src/handlers/messages/MESSAGE_DELETE.ts +++ b/src/handlers/messages/MESSAGE_DELETE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { MessageDelete } from "../../types/messages/message_delete.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageDelete } from "../../types/messages/message_delete.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleMessageDelete(data: DiscordGatewayPayload) { diff --git a/src/handlers/messages/MESSAGE_DELETE_BULK.ts b/src/handlers/messages/MESSAGE_DELETE_BULK.ts index f5b5ad680..2b585d338 100644 --- a/src/handlers/messages/MESSAGE_DELETE_BULK.ts +++ b/src/handlers/messages/MESSAGE_DELETE_BULK.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { MessageDeleteBulk } from "../../types/messages/message_delete_bulk.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageDeleteBulk } from "../../types/messages/message_delete_bulk.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleMessageDeleteBulk(data: DiscordGatewayPayload) { diff --git a/src/handlers/messages/MESSAGE_REACTION_ADD.ts b/src/handlers/messages/MESSAGE_REACTION_ADD.ts index ec6871a73..1bd69cf8c 100644 --- a/src/handlers/messages/MESSAGE_REACTION_ADD.ts +++ b/src/handlers/messages/MESSAGE_REACTION_ADD.ts @@ -1,8 +1,8 @@ import { botId, eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageReactionAdd, } from "../../types/messages/message_reaction_add.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; diff --git a/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts b/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts index 652baa592..59c5d77ef 100644 --- a/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts +++ b/src/handlers/messages/MESSAGE_REACTION_REMOVE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageReactionRemove, } from "../../types/messages/message_reaction_remove.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; diff --git a/src/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts b/src/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts index 0cb0088ed..81b365241 100644 --- a/src/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts +++ b/src/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageReactionRemoveAll, } from "../../types/messages/message_reaction_remove_all.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; diff --git a/src/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts b/src/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts index 43ca252ef..4241e718e 100644 --- a/src/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts +++ b/src/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { MessageReactionRemoveEmoji } from "../../types/messages/message_reaction_remove_emoji.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { MessageReactionRemoveEmoji } from "../../types/messages/message_reaction_remove_emoji.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleMessageReactionRemoveEmoji( diff --git a/src/handlers/messages/MESSAGE_UPDATE.ts b/src/handlers/messages/MESSAGE_UPDATE.ts index 648aeec06..61383517e 100644 --- a/src/handlers/messages/MESSAGE_UPDATE.ts +++ b/src/handlers/messages/MESSAGE_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Message } from "../../types/messages/message.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleMessageUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/misc/PRESENCE_UPDATE.ts b/src/handlers/misc/PRESENCE_UPDATE.ts index c770dc8b4..d1c2127c9 100644 --- a/src/handlers/misc/PRESENCE_UPDATE.ts +++ b/src/handlers/misc/PRESENCE_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { PresenceUpdate } from "../../types/misc/presence_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { PresenceUpdate } from "../../types/misc/presence_update.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handlePresenceUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/misc/READY.ts b/src/handlers/misc/READY.ts index 782e88f29..0ff0afa34 100644 --- a/src/handlers/misc/READY.ts +++ b/src/handlers/misc/READY.ts @@ -2,9 +2,9 @@ import { eventHandlers, setApplicationId, setBotId } from "../../bot.ts"; import { cache, cacheHandlers } from "../../cache.ts"; import { initialMemberLoadQueue } from "../../structures/guild.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { Ready } from "../../types/gateway/ready.ts"; -import { GuildMemberWithUser } from "../../types/mod.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { Ready } from "../../types/gateway/ready.ts"; +import type { GuildMemberWithUser } from "../../types/mod.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { ws } from "../../ws/ws.ts"; diff --git a/src/handlers/misc/TYPING_START.ts b/src/handlers/misc/TYPING_START.ts index 1cfde4296..707edfc4f 100644 --- a/src/handlers/misc/TYPING_START.ts +++ b/src/handlers/misc/TYPING_START.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { TypingStart } from "../../types/misc/typing_start.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { TypingStart } from "../../types/misc/typing_start.ts"; export function handleTypingStart(data: DiscordGatewayPayload) { eventHandlers.typingStart?.( diff --git a/src/handlers/misc/USER_UPDATE.ts b/src/handlers/misc/USER_UPDATE.ts index 02297cce9..fbe68ff70 100644 --- a/src/handlers/misc/USER_UPDATE.ts +++ b/src/handlers/misc/USER_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { User } from "../../types/users/user.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { User } from "../../types/users/user.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleUserUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/roles/GUILD_ROLE_CREATE.ts b/src/handlers/roles/GUILD_ROLE_CREATE.ts index acdc40c0b..c8801e2ce 100644 --- a/src/handlers/roles/GUILD_ROLE_CREATE.ts +++ b/src/handlers/roles/GUILD_ROLE_CREATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildRoleCreate } from "../../types/mod.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildRoleCreate } from "../../types/mod.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildRoleCreate(data: DiscordGatewayPayload) { diff --git a/src/handlers/roles/GUILD_ROLE_DELETE.ts b/src/handlers/roles/GUILD_ROLE_DELETE.ts index 8fd35f5e1..bed41d946 100644 --- a/src/handlers/roles/GUILD_ROLE_DELETE.ts +++ b/src/handlers/roles/GUILD_ROLE_DELETE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildRoleDelete } from "../../types/guilds/guild_role_delete.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildRoleDelete } from "../../types/guilds/guild_role_delete.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildRoleDelete(data: DiscordGatewayPayload) { diff --git a/src/handlers/roles/GUILD_ROLE_UPDATE.ts b/src/handlers/roles/GUILD_ROLE_UPDATE.ts index ae9c6e6d1..e3c1b445f 100644 --- a/src/handlers/roles/GUILD_ROLE_UPDATE.ts +++ b/src/handlers/roles/GUILD_ROLE_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { GuildRoleUpdate } from "../../types/mod.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { GuildRoleUpdate } from "../../types/mod.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleGuildRoleUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/voice/VOICE_SERVER_UPDATE.ts b/src/handlers/voice/VOICE_SERVER_UPDATE.ts index 3f6128a52..8150f7f01 100644 --- a/src/handlers/voice/VOICE_SERVER_UPDATE.ts +++ b/src/handlers/voice/VOICE_SERVER_UPDATE.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { VoiceServerUpdate } from "../../types/voice/voice_server_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { VoiceServerUpdate } from "../../types/voice/voice_server_update.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleVoiceServerUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/voice/VOICE_STATE_UPDATE.ts b/src/handlers/voice/VOICE_STATE_UPDATE.ts index e358eb3b6..7c9b93751 100644 --- a/src/handlers/voice/VOICE_STATE_UPDATE.ts +++ b/src/handlers/voice/VOICE_STATE_UPDATE.ts @@ -1,8 +1,8 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { VoiceState } from "../../types/voice/voice_state.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { VoiceState } from "../../types/voice/voice_state.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) { diff --git a/src/handlers/webhooks/WEBHOOKS_UPDATE.ts b/src/handlers/webhooks/WEBHOOKS_UPDATE.ts index 110a6761d..9512aa58f 100644 --- a/src/handlers/webhooks/WEBHOOKS_UPDATE.ts +++ b/src/handlers/webhooks/WEBHOOKS_UPDATE.ts @@ -1,6 +1,6 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; -import { WebhookUpdate } from "../../types/webhooks/webhooks_update.ts"; +import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import type { WebhookUpdate } from "../../types/webhooks/webhooks_update.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; export function handleWebhooksUpdate(data: DiscordGatewayPayload) { diff --git a/src/helpers/channels/channel_overwrite_has_permission.ts b/src/helpers/channels/channel_overwrite_has_permission.ts index bcf6b3407..2b0adcd12 100644 --- a/src/helpers/channels/channel_overwrite_has_permission.ts +++ b/src/helpers/channels/channel_overwrite_has_permission.ts @@ -1,6 +1,6 @@ -import { DiscordOverwrite } from "../../types/channels/overwrite.ts"; +import type { DiscordOverwrite } from "../../types/channels/overwrite.ts"; import { DiscordBitwisePermissionFlags } from "../../types/permissions/bitwise_permission_flags.ts"; -import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; +import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; /** Checks if a channel overwrite for a user id or a role id has permission in this channel */ export function channelOverwriteHasPermission( diff --git a/src/helpers/channels/clone_channel.ts b/src/helpers/channels/clone_channel.ts index 077c9e85a..632fc770f 100644 --- a/src/helpers/channels/clone_channel.ts +++ b/src/helpers/channels/clone_channel.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; -import { CreateGuildChannel } from "../../types/guilds/create_guild_channel.ts"; +import type { CreateGuildChannel } from "../../types/guilds/create_guild_channel.ts"; import { Errors } from "../../types/misc/errors.ts"; import { bigintToSnowflake } from "../../util/bigint.ts"; import { calculatePermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/channels/create_channel.ts b/src/helpers/channels/create_channel.ts index f0428041e..ec5288575 100644 --- a/src/helpers/channels/create_channel.ts +++ b/src/helpers/channels/create_channel.ts @@ -1,9 +1,9 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; +import type { Channel } from "../../types/channels/channel.ts"; import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; -import { +import type { CreateGuildChannel, DiscordCreateGuildChannel, } from "../../types/guilds/create_guild_channel.ts"; diff --git a/src/helpers/channels/edit_channel.ts b/src/helpers/channels/edit_channel.ts index 4dad7c838..d22feab6e 100644 --- a/src/helpers/channels/edit_channel.ts +++ b/src/helpers/channels/edit_channel.ts @@ -1,13 +1,11 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { ModifyChannel } from "../../types/channels/modify_channel.ts"; -import { ModifyThread } from "../../types/channels/threads/modify_thread.ts"; -import { - Channel, - DiscordChannelTypes, - PermissionStrings, -} from "../../types/mod.ts"; +import type { Channel } from "../../types/channels/channel.ts"; +import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; +import type { ModifyChannel } from "../../types/channels/modify_channel.ts"; +import type { ModifyThread } from "../../types/channels/threads/modify_thread.ts"; +import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { endpoints } from "../../util/constants.ts"; import { calculateBits, diff --git a/src/helpers/channels/edit_channel_overwrite.ts b/src/helpers/channels/edit_channel_overwrite.ts index 056cd6fc4..179bddbd1 100644 --- a/src/helpers/channels/edit_channel_overwrite.ts +++ b/src/helpers/channels/edit_channel_overwrite.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Overwrite } from "../../types/channels/overwrite.ts"; +import type { Overwrite } from "../../types/channels/overwrite.ts"; import { endpoints } from "../../util/constants.ts"; import { calculateBits, diff --git a/src/helpers/channels/follow_channel.ts b/src/helpers/channels/follow_channel.ts index 6ef4ed0e7..ede74126e 100644 --- a/src/helpers/channels/follow_channel.ts +++ b/src/helpers/channels/follow_channel.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { FollowedChannel } from "../../types/channels/followed_channel.ts"; +import type { FollowedChannel } from "../../types/channels/followed_channel.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/channels/get_channel.ts b/src/helpers/channels/get_channel.ts index 122f075c8..4818bba41 100644 --- a/src/helpers/channels/get_channel.ts +++ b/src/helpers/channels/get_channel.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; +import type { Channel } from "../../types/channels/channel.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/channels/get_channel_webhooks.ts b/src/helpers/channels/get_channel_webhooks.ts index d3752ff97..9f4110c43 100644 --- a/src/helpers/channels/get_channel_webhooks.ts +++ b/src/helpers/channels/get_channel_webhooks.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/channels/get_channels.ts b/src/helpers/channels/get_channels.ts index 681601cd1..53d72529d 100644 --- a/src/helpers/channels/get_channels.ts +++ b/src/helpers/channels/get_channels.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; +import type { Channel } from "../../types/channels/channel.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/channels/get_pins.ts b/src/helpers/channels/get_pins.ts index dd4d26954..63c2090f4 100644 --- a/src/helpers/channels/get_pins.ts +++ b/src/helpers/channels/get_pins.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; /** Get pinned messages in this channel. */ diff --git a/src/helpers/channels/swap_channels.ts b/src/helpers/channels/swap_channels.ts index 21dddd139..a3b3135f5 100644 --- a/src/helpers/channels/swap_channels.ts +++ b/src/helpers/channels/swap_channels.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyGuildChannelPositions } from "../../types/guilds/modify_guild_channel_position.ts"; +import type { ModifyGuildChannelPositions } from "../../types/guilds/modify_guild_channel_position.ts"; import { endpoints } from "../../util/constants.ts"; /** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permisison. */ diff --git a/src/helpers/commands/batch_edit_slash_command_permissions.ts b/src/helpers/commands/batch_edit_slash_command_permissions.ts index 139ee5981..8be782bff 100644 --- a/src/helpers/commands/batch_edit_slash_command_permissions.ts +++ b/src/helpers/commands/batch_edit_slash_command_permissions.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; +import type { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/commands/create_slash_command.ts b/src/helpers/commands/create_slash_command.ts index 9a6f1f36d..b5241f556 100644 --- a/src/helpers/commands/create_slash_command.ts +++ b/src/helpers/commands/create_slash_command.ts @@ -1,7 +1,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { CreateGlobalApplicationCommand } from "../../types/interactions/create_global_application_command.ts"; -import { ApplicationCommand } from "../../types/mod.ts"; +import type { ApplicationCommand } from "../../types/interactions/application_command.ts"; +import type { CreateGlobalApplicationCommand } from "../../types/interactions/create_global_application_command.ts"; import { endpoints } from "../../util/constants.ts"; import { camelKeysToSnakeCase, diff --git a/src/helpers/commands/edit_slash_command_permissions.ts b/src/helpers/commands/edit_slash_command_permissions.ts index 743780b45..bbaae3bc4 100644 --- a/src/helpers/commands/edit_slash_command_permissions.ts +++ b/src/helpers/commands/edit_slash_command_permissions.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; +import type { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/commands/edit_slash_response.ts b/src/helpers/commands/edit_slash_response.ts index 2c458f047..9857805e6 100644 --- a/src/helpers/commands/edit_slash_response.ts +++ b/src/helpers/commands/edit_slash_response.ts @@ -1,7 +1,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordenoEditWebhookMessage } from "../../types/discordeno/edit_webhook_message.ts"; +import type { DiscordenoEditWebhookMessage } from "../../types/discordeno/edit_webhook_message.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/commands/get_slash_command.ts b/src/helpers/commands/get_slash_command.ts index 2c0f9be01..846b47bf0 100644 --- a/src/helpers/commands/get_slash_command.ts +++ b/src/helpers/commands/get_slash_command.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { ApplicationCommand } from "../../types/interactions/application_command.ts"; +import type { ApplicationCommand } from "../../types/interactions/application_command.ts"; import { endpoints } from "../../util/constants.ts"; /** Fetchs the global command for the given Id. If a guildId is provided, the guild command will be fetched. */ diff --git a/src/helpers/commands/get_slash_command_permission.ts b/src/helpers/commands/get_slash_command_permission.ts index ead639b36..f07c92f18 100644 --- a/src/helpers/commands/get_slash_command_permission.ts +++ b/src/helpers/commands/get_slash_command_permission.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; +import type { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; /** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */ diff --git a/src/helpers/commands/get_slash_command_permissions.ts b/src/helpers/commands/get_slash_command_permissions.ts index 821642c8d..07c12fb8f 100644 --- a/src/helpers/commands/get_slash_command_permissions.ts +++ b/src/helpers/commands/get_slash_command_permissions.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; +import type { GuildApplicationCommandPermissions } from "../../types/interactions/guild_application_command_permissions.ts"; import { endpoints } from "../../util/constants.ts"; /** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */ diff --git a/src/helpers/commands/get_slash_commands.ts b/src/helpers/commands/get_slash_commands.ts index bdac9a9bc..c4f4c8eff 100644 --- a/src/helpers/commands/get_slash_commands.ts +++ b/src/helpers/commands/get_slash_commands.ts @@ -1,6 +1,6 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { ApplicationCommand } from "../../types/interactions/application_command.ts"; +import type { ApplicationCommand } from "../../types/interactions/application_command.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/commands/send_interaction_response.ts b/src/helpers/commands/send_interaction_response.ts index 6200c6641..dae5c23bd 100644 --- a/src/helpers/commands/send_interaction_response.ts +++ b/src/helpers/commands/send_interaction_response.ts @@ -1,7 +1,7 @@ import { applicationId, eventHandlers } from "../../bot.ts"; import { cache } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { DiscordenoInteractionResponse } from "../../types/discordeno/interaction_response.ts"; +import type { DiscordenoInteractionResponse } from "../../types/discordeno/interaction_response.ts"; import { endpoints } from "../../util/constants.ts"; /** diff --git a/src/helpers/commands/upsert_slash_command.ts b/src/helpers/commands/upsert_slash_command.ts index d0211400d..ed2dc20f9 100644 --- a/src/helpers/commands/upsert_slash_command.ts +++ b/src/helpers/commands/upsert_slash_command.ts @@ -1,7 +1,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { EditGlobalApplicationCommand } from "../../types/interactions/edit_global_application_command.ts"; -import { ApplicationCommand } from "../../types/mod.ts"; +import type { ApplicationCommand } from "../../types/interactions/application_command.ts"; +import type { EditGlobalApplicationCommand } from "../../types/interactions/edit_global_application_command.ts"; import { endpoints } from "../../util/constants.ts"; import { validateSlashCommands } from "../../util/utils.ts"; diff --git a/src/helpers/commands/upsert_slash_commands.ts b/src/helpers/commands/upsert_slash_commands.ts index 3be28f765..b49c2cb41 100644 --- a/src/helpers/commands/upsert_slash_commands.ts +++ b/src/helpers/commands/upsert_slash_commands.ts @@ -1,7 +1,7 @@ import { applicationId } from "../../bot.ts"; import { rest } from "../../rest/rest.ts"; -import { EditGlobalApplicationCommand } from "../../types/interactions/edit_global_application_command.ts"; -import { ApplicationCommand } from "../../types/mod.ts"; +import type { ApplicationCommand } from "../../types/interactions/application_command.ts"; +import type { EditGlobalApplicationCommand } from "../../types/interactions/edit_global_application_command.ts"; import { endpoints } from "../../util/constants.ts"; import { validateSlashCommands } from "../../util/utils.ts"; diff --git a/src/helpers/discovery/add_discovery_subcategory.ts b/src/helpers/discovery/add_discovery_subcategory.ts index 3341f394c..4061925cd 100644 --- a/src/helpers/discovery/add_discovery_subcategory.ts +++ b/src/helpers/discovery/add_discovery_subcategory.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { +import type { AddGuildDiscoverySubcategory, } from "../../types/discovery/add_guild_discovery_subcategory.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/discovery/edit_discovery.ts b/src/helpers/discovery/edit_discovery.ts index e94c7a60b..71f7e3ab5 100644 --- a/src/helpers/discovery/edit_discovery.ts +++ b/src/helpers/discovery/edit_discovery.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { DiscoveryMetadata } from "../../types/discovery/discovery_metadata.ts"; -import { ModifyGuildDiscoveryMetadata } from "../../types/discovery/modify_guild_discovery_metadata.ts"; +import type { DiscoveryMetadata } from "../../types/discovery/discovery_metadata.ts"; +import type { ModifyGuildDiscoveryMetadata } from "../../types/discovery/modify_guild_discovery_metadata.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/discovery/get_discovery_categories.ts b/src/helpers/discovery/get_discovery_categories.ts index 8ec9858f5..0ac60d848 100644 --- a/src/helpers/discovery/get_discovery_categories.ts +++ b/src/helpers/discovery/get_discovery_categories.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { DiscoveryCategory } from "../../types/discovery/discovery_category.ts"; +import type { DiscoveryCategory } from "../../types/discovery/discovery_category.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/discovery/valid_discovery_term.ts b/src/helpers/discovery/valid_discovery_term.ts index 5a96016af..b41a60742 100644 --- a/src/helpers/discovery/valid_discovery_term.ts +++ b/src/helpers/discovery/valid_discovery_term.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { ValidateDiscoverySearchTerm } from "../../types/discovery/validate_discovery_search_term.ts"; +import type { ValidateDiscoverySearchTerm } from "../../types/discovery/validate_discovery_search_term.ts"; import { endpoints } from "../../util/constants.ts"; export async function validDiscoveryTerm(term: string) { diff --git a/src/helpers/emojis/create_emoji.ts b/src/helpers/emojis/create_emoji.ts index 504bdd299..432885fc0 100644 --- a/src/helpers/emojis/create_emoji.ts +++ b/src/helpers/emojis/create_emoji.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; import { CreateGuildEmoji } from "../../types/emojis/create_guild_emoji.ts"; -import { Emoji } from "../../types/emojis/emoji.ts"; +import type { Emoji } from "../../types/emojis/emoji.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/emojis/edit_emoji.ts b/src/helpers/emojis/edit_emoji.ts index 5d2a0f8ed..87264c5f6 100644 --- a/src/helpers/emojis/edit_emoji.ts +++ b/src/helpers/emojis/edit_emoji.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyGuildEmoji } from "../../types/emojis/modify_guild_emoji.ts"; -import { Emoji } from "../../types/mod.ts"; +import type { Emoji } from "../../types/emojis/emoji.ts"; +import type { ModifyGuildEmoji } from "../../types/emojis/modify_guild_emoji.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/emojis/get_emoji.ts b/src/helpers/emojis/get_emoji.ts index d66ac2aa1..9679ee86a 100644 --- a/src/helpers/emojis/get_emoji.ts +++ b/src/helpers/emojis/get_emoji.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Emoji } from "../../types/emojis/emoji.ts"; +import type { Emoji } from "../../types/emojis/emoji.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/emojis/get_emojis.ts b/src/helpers/emojis/get_emojis.ts index c0e56b65f..e3dfa30fd 100644 --- a/src/helpers/emojis/get_emojis.ts +++ b/src/helpers/emojis/get_emojis.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Emoji } from "../../types/emojis/emoji.ts"; +import type { Emoji } from "../../types/emojis/emoji.ts"; import { Errors } from "../../types/misc/errors.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { Collection } from "../../util/collection.ts"; diff --git a/src/helpers/guilds/create_guild.ts b/src/helpers/guilds/create_guild.ts index 40c28f3fa..517a0f63c 100644 --- a/src/helpers/guilds/create_guild.ts +++ b/src/helpers/guilds/create_guild.ts @@ -2,8 +2,8 @@ import { botId } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { CreateGuild } from "../../types/guilds/create_guild.ts"; -import { Guild } from "../../types/guilds/guild.ts"; +import type { CreateGuild } from "../../types/guilds/create_guild.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; import { endpoints } from "../../util/constants.ts"; import { getMember } from "../members/get_member.ts"; diff --git a/src/helpers/guilds/edit_guild.ts b/src/helpers/guilds/edit_guild.ts index 212419486..278597312 100644 --- a/src/helpers/guilds/edit_guild.ts +++ b/src/helpers/guilds/edit_guild.ts @@ -1,8 +1,8 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Guild } from "../../types/guilds/guild.ts"; -import { ModifyGuild } from "../../types/guilds/modify_guild.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; +import type { ModifyGuild } from "../../types/guilds/modify_guild.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; import { urlToBase64 } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/edit_welcome_screen.ts b/src/helpers/guilds/edit_welcome_screen.ts index 284f1fb96..29114dea3 100644 --- a/src/helpers/guilds/edit_welcome_screen.ts +++ b/src/helpers/guilds/edit_welcome_screen.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyGuildWelcomeScreen } from "../../types/guilds/modify_guild_welcome_screen.ts"; -import { WelcomeScreen } from "../../types/mod.ts"; +import type { ModifyGuildWelcomeScreen } from "../../types/guilds/modify_guild_welcome_screen.ts"; +import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts"; import { endpoints } from "../../util/constants.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/edit_widget.ts b/src/helpers/guilds/edit_widget.ts index 8a27129b3..9cc0ccd69 100644 --- a/src/helpers/guilds/edit_widget.ts +++ b/src/helpers/guilds/edit_widget.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { GuildWidget } from "../../types/guilds/guild_widget.ts"; +import type { GuildWidget } from "../../types/guilds/guild_widget.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/guilds/get_audit_logs.ts b/src/helpers/guilds/get_audit_logs.ts index babcc0354..a090fbf49 100644 --- a/src/helpers/guilds/get_audit_logs.ts +++ b/src/helpers/guilds/get_audit_logs.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { AuditLog } from "../../types/audit_log/audit_log.ts"; -import { GetGuildAuditLog } from "../../types/audit_log/get_guild_audit_log.ts"; +import type { AuditLog } from "../../types/audit_log/audit_log.ts"; +import type { GetGuildAuditLog } from "../../types/audit_log/get_guild_audit_log.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/get_available_voice_regions.ts b/src/helpers/guilds/get_available_voice_regions.ts index 5570e4916..2111f6a3d 100644 --- a/src/helpers/guilds/get_available_voice_regions.ts +++ b/src/helpers/guilds/get_available_voice_regions.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { VoiceRegion } from "../../types/voice/voice_region.ts"; +import type { VoiceRegion } from "../../types/voice/voice_region.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns an array of voice regions that can be used when creating servers. */ diff --git a/src/helpers/guilds/get_ban.ts b/src/helpers/guilds/get_ban.ts index db70fc796..c6f73a22a 100644 --- a/src/helpers/guilds/get_ban.ts +++ b/src/helpers/guilds/get_ban.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Ban } from "../../types/guilds/ban.ts"; +import type { Ban } from "../../types/guilds/ban.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/guilds/get_bans.ts b/src/helpers/guilds/get_bans.ts index ba939dfb8..f2a09617d 100644 --- a/src/helpers/guilds/get_bans.ts +++ b/src/helpers/guilds/get_bans.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Ban } from "../../types/guilds/ban.ts"; +import type { Ban } from "../../types/guilds/ban.ts"; import { snowflakeToBigint } from "../../util/bigint.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/guilds/get_guild.ts b/src/helpers/guilds/get_guild.ts index 0a809bbf2..3b13a74dc 100644 --- a/src/helpers/guilds/get_guild.ts +++ b/src/helpers/guilds/get_guild.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Guild } from "../../types/guilds/guild.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; import { endpoints } from "../../util/constants.ts"; import { ws } from "../../ws/ws.ts"; diff --git a/src/helpers/guilds/get_guild_preview.ts b/src/helpers/guilds/get_guild_preview.ts index b5024f2b8..a62379a6d 100644 --- a/src/helpers/guilds/get_guild_preview.ts +++ b/src/helpers/guilds/get_guild_preview.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { GuildPreview } from "../../types/guilds/guild_preview.ts"; +import type { GuildPreview } from "../../types/guilds/guild_preview.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. */ diff --git a/src/helpers/guilds/get_prune_count.ts b/src/helpers/guilds/get_prune_count.ts index 27f1691cc..fe25797d6 100644 --- a/src/helpers/guilds/get_prune_count.ts +++ b/src/helpers/guilds/get_prune_count.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { GetGuildPruneCountQuery } from "../../types/guilds/get_guild_prune_count.ts"; +import type { GetGuildPruneCountQuery } from "../../types/guilds/get_guild_prune_count.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/guilds/get_vainty_url.ts b/src/helpers/guilds/get_vainty_url.ts index c14719b30..9554b2b04 100644 --- a/src/helpers/guilds/get_vainty_url.ts +++ b/src/helpers/guilds/get_vainty_url.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { InviteMetadata } from "../../types/invites/invite_metadata.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the code and uses of the vanity url for this server if it is enabled else `code` will be null. Requires the `MANAGE_GUILD` permission. */ diff --git a/src/helpers/guilds/get_voice_regions.ts b/src/helpers/guilds/get_voice_regions.ts index ad1598ce5..966867d82 100644 --- a/src/helpers/guilds/get_voice_regions.ts +++ b/src/helpers/guilds/get_voice_regions.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { VoiceRegion } from "../../types/voice/voice_region.ts"; +import type { VoiceRegion } from "../../types/voice/voice_region.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/guilds/get_welcome_screen.ts b/src/helpers/guilds/get_welcome_screen.ts index f30b8e9c7..2b20e2826 100644 --- a/src/helpers/guilds/get_welcome_screen.ts +++ b/src/helpers/guilds/get_welcome_screen.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { WelcomeScreen } from "../../types/mod.ts"; +import type { WelcomeScreen } from "../../types/mod.ts"; import { endpoints } from "../../util/constants.ts"; export async function getWelcomeScreen(guildId: bigint) { diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index 0be0e4991..9a31b2c30 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { GuildWidgetDetails } from "../../types/guilds/guild_widget_details.ts"; +import type { GuildWidgetDetails } from "../../types/guilds/guild_widget_details.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/guilds/get_widget_image_url.ts b/src/helpers/guilds/get_widget_image_url.ts index ede9e97ff..e754b0aba 100644 --- a/src/helpers/guilds/get_widget_image_url.ts +++ b/src/helpers/guilds/get_widget_image_url.ts @@ -1,5 +1,5 @@ import { cacheHandlers } from "../../cache.ts"; -import { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts"; +import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/guilds/get_widget_settings.ts b/src/helpers/guilds/get_widget_settings.ts index e8a106816..622199621 100644 --- a/src/helpers/guilds/get_widget_settings.ts +++ b/src/helpers/guilds/get_widget_settings.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { GuildWidget } from "../../types/guilds/guild_widget.ts"; +import type { GuildWidget } from "../../types/guilds/guild_widget.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/guilds/guild_banner_url.ts b/src/helpers/guilds/guild_banner_url.ts index 030d2cab6..b539b27be 100644 --- a/src/helpers/guilds/guild_banner_url.ts +++ b/src/helpers/guilds/guild_banner_url.ts @@ -1,5 +1,5 @@ -import { DiscordImageFormat } from "../../types/misc/image_format.ts"; -import { DiscordImageSize } from "../../types/misc/image_size.ts"; +import type { DiscordImageFormat } from "../../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../../types/misc/image_size.ts"; import { endpoints } from "../../util/constants.ts"; import { formatImageURL } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/guild_icon_url.ts b/src/helpers/guilds/guild_icon_url.ts index 09982fec3..5a4c2104a 100644 --- a/src/helpers/guilds/guild_icon_url.ts +++ b/src/helpers/guilds/guild_icon_url.ts @@ -1,5 +1,5 @@ -import { DiscordImageFormat } from "../../types/misc/image_format.ts"; -import { DiscordImageSize } from "../../types/misc/image_size.ts"; +import type { DiscordImageFormat } from "../../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../../types/misc/image_size.ts"; import { endpoints } from "../../util/constants.ts"; import { formatImageURL } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/guild_splash_url.ts b/src/helpers/guilds/guild_splash_url.ts index 83d734a07..b8aef6d56 100644 --- a/src/helpers/guilds/guild_splash_url.ts +++ b/src/helpers/guilds/guild_splash_url.ts @@ -1,5 +1,5 @@ -import { DiscordImageFormat } from "../../types/misc/image_format.ts"; -import { DiscordImageSize } from "../../types/misc/image_size.ts"; +import type { DiscordImageFormat } from "../../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../../types/misc/image_size.ts"; import { endpoints } from "../../util/constants.ts"; import { formatImageURL } from "../../util/utils.ts"; diff --git a/src/helpers/guilds/update_bot_voice_state.ts b/src/helpers/guilds/update_bot_voice_state.ts index e75d5ce9c..60426da49 100644 --- a/src/helpers/guilds/update_bot_voice_state.ts +++ b/src/helpers/guilds/update_bot_voice_state.ts @@ -1,6 +1,5 @@ -import { RequestManager } from "../../rest/request_manager.ts"; -import { - DiscordUpdateSelfVoiceState, +import { rest } from "../../rest/rest.ts"; +import type { UpdateSelfVoiceState, } from "../../types/guilds/update_self_voice_state.ts"; import { endpoints } from "../../util/constants.ts"; @@ -15,14 +14,13 @@ import { camelKeysToSnakeCase } from "../../util/utils.ts"; * - You must have the `REQUEST_TO_SPEAK` permission to request to speak. You can always clear your own request to speak. * - You are able to set `request_to_speak_timestamp` to any present or future time. */ -export function updateBotVoiceState( +export async function updateBotVoiceState( guildId: bigint, data: UpdateSelfVoiceState, ) { - const payload = camelKeysToSnakeCase(data); - - return RequestManager.patch( + return await rest.runMethod( + "patch", endpoints.UPDATE_VOICE_STATE(guildId), - payload, + camelKeysToSnakeCase(data), ); } diff --git a/src/helpers/guilds/update_user_voice_state.ts b/src/helpers/guilds/update_user_voice_state.ts index 88708ad10..6a8e47ebd 100644 --- a/src/helpers/guilds/update_user_voice_state.ts +++ b/src/helpers/guilds/update_user_voice_state.ts @@ -1,6 +1,5 @@ -import { RequestManager } from "../../rest/request_manager.ts"; -import { - DiscordUpdateOthersVoiceState, +import { rest } from "../../rest/rest.ts"; +import type { UpdateOthersVoiceState, } from "../../types/guilds/update_others_voice_state.ts"; import { endpoints } from "../../util/constants.ts"; @@ -20,10 +19,9 @@ export function updateVoiceState( userId: bigint, data: UpdateOthersVoiceState, ) { - const payload = camelKeysToSnakeCase(data); - - return RequestManager.patch( + return rest.runMethod( + "patch", endpoints.UPDATE_VOICE_STATE(guildId, userId), - payload, + camelKeysToSnakeCase(data), ); } diff --git a/src/helpers/integrations/get_integrations.ts b/src/helpers/integrations/get_integrations.ts index 96fd2110c..1947d3317 100644 --- a/src/helpers/integrations/get_integrations.ts +++ b/src/helpers/integrations/get_integrations.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Integration } from "../../types/mod.ts"; +import type { Integration } from "../../types/integration/integration.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index 6761d9048..e6e3e6008 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { CreateChannelInvite } from "../../types/invites/create_channel_invite.ts"; -import { Invite } from "../../types/invites/invite.ts"; +import type { CreateChannelInvite } from "../../types/invites/create_channel_invite.ts"; +import type { Invite } from "../../types/invites/invite.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/invites/delete_invite.ts b/src/helpers/invites/delete_invite.ts index 130cd2488..01d1d1c48 100644 --- a/src/helpers/invites/delete_invite.ts +++ b/src/helpers/invites/delete_invite.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Invite } from "../../types/invites/invite.ts"; +import type { Invite } from "../../types/invites/invite.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { diff --git a/src/helpers/invites/get_channel_invites.ts b/src/helpers/invites/get_channel_invites.ts index ecd27a6d5..42fa1e9d9 100644 --- a/src/helpers/invites/get_channel_invites.ts +++ b/src/helpers/invites/get_channel_invites.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Invite } from "../../types/invites/invite.ts"; +import type { Invite } from "../../types/invites/invite.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/invites/get_invite.ts b/src/helpers/invites/get_invite.ts index de91249fe..f0781e927 100644 --- a/src/helpers/invites/get_invite.ts +++ b/src/helpers/invites/get_invite.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Invite } from "../../types/invites/invite.ts"; +import type { Invite } from "../../types/invites/invite.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns an invite for the given code or throws an error if the invite doesn't exists. */ diff --git a/src/helpers/invites/get_invites.ts b/src/helpers/invites/get_invites.ts index 0ad0fda87..f2d1a732f 100644 --- a/src/helpers/invites/get_invites.ts +++ b/src/helpers/invites/get_invites.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Invite } from "../../types/invites/invite.ts"; +import type { Invite } from "../../types/invites/invite.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/members/avatar_url.ts b/src/helpers/members/avatar_url.ts index 64a136370..0f9ad36da 100644 --- a/src/helpers/members/avatar_url.ts +++ b/src/helpers/members/avatar_url.ts @@ -1,5 +1,5 @@ -import { DiscordImageFormat } from "../../types/misc/image_format.ts"; -import { DiscordImageSize } from "../../types/misc/image_size.ts"; +import type { DiscordImageFormat } from "../../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../../types/misc/image_size.ts"; import { endpoints } from "../../util/constants.ts"; import { formatImageURL } from "../../util/utils.ts"; diff --git a/src/helpers/members/ban_member.ts b/src/helpers/members/ban_member.ts index 57215ba59..7af64906c 100644 --- a/src/helpers/members/ban_member.ts +++ b/src/helpers/members/ban_member.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { CreateGuildBan } from "../../types/guilds/create_guild_ban.ts"; +import type { CreateGuildBan } from "../../types/guilds/create_guild_ban.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/members/edit_bot_profile.ts b/src/helpers/members/edit_bot_profile.ts index 2e4fd6c7c..719351636 100644 --- a/src/helpers/members/edit_bot_profile.ts +++ b/src/helpers/members/edit_bot_profile.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { User } from "../../types/mod.ts"; +import type { User } from "../../types/users/user.ts"; import { endpoints } from "../../util/constants.ts"; import { urlToBase64 } from "../../util/utils.ts"; diff --git a/src/helpers/members/edit_member.ts b/src/helpers/members/edit_member.ts index b9ad4efea..8b28e890b 100644 --- a/src/helpers/members/edit_member.ts +++ b/src/helpers/members/edit_member.ts @@ -1,10 +1,10 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { ModifyGuildMember } from "../../types/guilds/modify_guild_member.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { ModifyGuildMember } from "../../types/mod.ts"; -import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; +import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { bigintToSnowflake } from "../../util/bigint.ts"; import { endpoints } from "../../util/constants.ts"; import { diff --git a/src/helpers/members/get_member.ts b/src/helpers/members/get_member.ts index 4949f3165..b2c17db17 100644 --- a/src/helpers/members/get_member.ts +++ b/src/helpers/members/get_member.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns a guild member object for the specified user. diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 9e0b10a02..6a7c95dd4 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -4,8 +4,8 @@ import { rest } from "../../rest/rest.ts"; import { DiscordenoMember } from "../../structures/member.ts"; import { structures } from "../../structures/mod.ts"; import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; -import { ListGuildMembers } from "../../types/guilds/list_guild_members.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { ListGuildMembers } from "../../types/guilds/list_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { bigintToSnowflake } from "../../util/bigint.ts"; import { Collection } from "../../util/collection.ts"; diff --git a/src/helpers/members/prune_members.ts b/src/helpers/members/prune_members.ts index 0ee5010fb..a59860ad5 100644 --- a/src/helpers/members/prune_members.ts +++ b/src/helpers/members/prune_members.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts"; +import type { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/members/search_members.ts b/src/helpers/members/search_members.ts index b57745f1d..6258c69de 100644 --- a/src/helpers/members/search_members.ts +++ b/src/helpers/members/search_members.ts @@ -2,8 +2,8 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { DiscordenoMember } from "../../structures/member.ts"; import { structures } from "../../structures/mod.ts"; -import { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; -import { SearchGuildMembers } from "../../types/members/search_guild_members.ts"; +import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts"; +import type { SearchGuildMembers } from "../../types/members/search_guild_members.ts"; import { Errors } from "../../types/misc/errors.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/members/send_direct_message.ts b/src/helpers/members/send_direct_message.ts index 4aae8e391..710994a62 100644 --- a/src/helpers/members/send_direct_message.ts +++ b/src/helpers/members/send_direct_message.ts @@ -1,8 +1,8 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Channel } from "../../types/channels/channel.ts"; -import { CreateMessage } from "../../types/messages/create_message.ts"; +import type { Channel } from "../../types/channels/channel.ts"; +import type { CreateMessage } from "../../types/messages/create_message.ts"; import { endpoints } from "../../util/constants.ts"; import { sendMessage } from "../messages/send_message.ts"; diff --git a/src/helpers/messages/edit_message.ts b/src/helpers/messages/edit_message.ts index e45bc4577..b76a55974 100644 --- a/src/helpers/messages/edit_message.ts +++ b/src/helpers/messages/edit_message.ts @@ -3,9 +3,9 @@ import { rest } from "../../rest/rest.ts"; import { DiscordenoMessage } from "../../structures/message.ts"; import { structures } from "../../structures/mod.ts"; import { EditMessage } from "../../types/messages/edit_message.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; +import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/messages/get_message.ts b/src/helpers/messages/get_message.ts index 7779a9d67..863eb07e0 100644 --- a/src/helpers/messages/get_message.ts +++ b/src/helpers/messages/get_message.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/messages/get_messages.ts b/src/helpers/messages/get_messages.ts index f12e4eb0c..79b29d238 100644 --- a/src/helpers/messages/get_messages.ts +++ b/src/helpers/messages/get_messages.ts @@ -6,7 +6,7 @@ import { GetMessagesBefore, GetMessagesLimit, } from "../../types/messages/get_messages.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/messages/get_reactions.ts b/src/helpers/messages/get_reactions.ts index 04ee9806e..b06dd5709 100644 --- a/src/helpers/messages/get_reactions.ts +++ b/src/helpers/messages/get_reactions.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { GetReactions } from "../../types/messages/message_get_reactions.ts"; -import { User } from "../../types/users/user.ts"; +import type { GetReactions } from "../../types/messages/message_get_reactions.ts"; +import type { User } from "../../types/users/user.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; diff --git a/src/helpers/messages/publish_message.ts b/src/helpers/messages/publish_message.ts index 5c60a38bf..877d7c32d 100644 --- a/src/helpers/messages/publish_message.ts +++ b/src/helpers/messages/publish_message.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; /** Crosspost a message in a News Channel to following channels. */ diff --git a/src/helpers/messages/send_message.ts b/src/helpers/messages/send_message.ts index f7eff71d0..ff80dfb53 100644 --- a/src/helpers/messages/send_message.ts +++ b/src/helpers/messages/send_message.ts @@ -4,10 +4,10 @@ import { structures } from "../../structures/mod.ts"; import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; import { ButtonStyles } from "../../types/messages/components/button_styles.ts"; -import { CreateMessage } from "../../types/messages/create_message.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { CreateMessage } from "../../types/messages/create_message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; +import type { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; import { camelKeysToSnakeCase } from "../../util/utils.ts"; diff --git a/src/helpers/misc/get_gateway_bot.ts b/src/helpers/misc/get_gateway_bot.ts index d765780be..ac7594177 100644 --- a/src/helpers/misc/get_gateway_bot.ts +++ b/src/helpers/misc/get_gateway_bot.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { GetGatewayBot } from "../../types/gateway/get_gateway_bot.ts"; +import type { GetGatewayBot } from "../../types/gateway/get_gateway_bot.ts"; import { endpoints } from "../../util/constants.ts"; /** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */ diff --git a/src/helpers/misc/get_user.ts b/src/helpers/misc/get_user.ts index 0c1517c91..f4632beb5 100644 --- a/src/helpers/misc/get_user.ts +++ b/src/helpers/misc/get_user.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { User } from "../../types/users/user.ts"; +import type { User } from "../../types/users/user.ts"; import { endpoints } from "../../util/constants.ts"; /** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */ diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index 44bb6a467..6d0aea748 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -118,7 +118,7 @@ import { deleteWebhookWithToken } from "./webhooks/delete_webhook_with_token.ts" import { editWebhook } from "./webhooks/edit_webhook.ts"; import { editWebhookMessage } from "./webhooks/edit_webhook_message.ts"; import { editWebhookWithToken } from "./webhooks/edit_webhook_with_token.ts"; -import { executeWebhook } from "./webhooks/execute_webhook.ts"; +import { sendWebhook } from "./webhooks/send_webhook.ts"; import { getWebhook } from "./webhooks/get_webhook.ts"; import { getWebhooks } from "./webhooks/get_webhooks.ts"; import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts"; @@ -181,7 +181,6 @@ export { editWelcomeScreen, editWidget, emojiURL, - executeWebhook, fetchMembers, followChannel, getAuditLogs, @@ -247,6 +246,7 @@ export { sendDirectMessage, sendInteractionResponse, sendMessage, + sendWebhook, startTyping, swapChannels, syncGuildTemplate, @@ -392,7 +392,7 @@ export let helpers = { editWebhookMessage, editWebhookWithToken, editWebhook, - executeWebhook, + sendWebhook, getWebhookWithToken, getWebhook, getWebhooks, diff --git a/src/helpers/roles/create_role.ts b/src/helpers/roles/create_role.ts index 363809489..89d4f3bc0 100644 --- a/src/helpers/roles/create_role.ts +++ b/src/helpers/roles/create_role.ts @@ -2,7 +2,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; import { CreateGuildRole } from "../../types/guilds/create_guild_role.ts"; -import { Role } from "../../types/permissions/role.ts"; +import type { Role } from "../../types/permissions/role.ts"; import { endpoints } from "../../util/constants.ts"; import { calculateBits, @@ -31,9 +31,13 @@ export async function createRole( role: result, guildId, }); - const guild = await cacheHandlers.get("guilds", guildId); - guild?.roles.set(role.id, role); - // TODO: ADD TO CACHE? + const guild = await cacheHandlers.get("guilds", guildId); + if (guild) { + guild.roles.set(role.id, role); + + await cacheHandlers.set("guilds", guildId, guild); + } + return role; } diff --git a/src/helpers/roles/edit_role.ts b/src/helpers/roles/edit_role.ts index ad178d063..3b0595913 100644 --- a/src/helpers/roles/edit_role.ts +++ b/src/helpers/roles/edit_role.ts @@ -1,6 +1,7 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { CreateGuildRole, Role } from "../../types/mod.ts"; +import type { CreateGuildRole } from "../../types/guilds/create_guild_role.ts"; +import type { Role } from "../../types/permissions/role.ts"; import { endpoints } from "../../util/constants.ts"; import { calculateBits, diff --git a/src/helpers/roles/get_roles.ts b/src/helpers/roles/get_roles.ts index b65dbf882..a4529e507 100644 --- a/src/helpers/roles/get_roles.ts +++ b/src/helpers/roles/get_roles.ts @@ -1,5 +1,7 @@ +import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Role } from "../../types/permissions/role.ts"; +import { structures } from "../../structures/mod.ts"; +import type { Role } from "../../types/permissions/role.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; @@ -8,7 +10,7 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; * * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your roles will be cached in your guild.** */ -export async function getRoles(guildId: bigint) { +export async function getRoles(guildId: bigint, addToCache = true) { await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]); const result = await rest.runMethod( @@ -16,9 +18,23 @@ export async function getRoles(guildId: bigint) { endpoints.GUILD_ROLES(guildId), ); - // TODO: addToCache - - return new Collection( - result.map((role) => [role.id, role]), + const roleStructures = await Promise.all( + result.map(async (role) => + await structures.createDiscordenoRole({ role, guildId }) + ), ); + + const roles = new Collection( + roleStructures.map((role) => [role.id, role]), + ); + + if (addToCache) { + const guild = await cacheHandlers.get("guilds", guildId); + if (guild) { + guild.roles = roles; + await cacheHandlers.set("guilds", guild.id, guild); + } + } + + return roleStructures; } diff --git a/src/helpers/templates/create_guild_from_template.ts b/src/helpers/templates/create_guild_from_template.ts index 770f71299..9c17dd0aa 100644 --- a/src/helpers/templates/create_guild_from_template.ts +++ b/src/helpers/templates/create_guild_from_template.ts @@ -1,9 +1,11 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { Guild } from "../../types/guilds/guild.ts"; -import { CreateGuildFromTemplate } from "../../types/templates/create_guild_from_template.ts"; +import { structures } from "../../structures/mod.ts"; +import type { Guild } from "../../types/guilds/guild.ts"; +import type { CreateGuildFromTemplate } from "../../types/templates/create_guild_from_template.ts"; import { endpoints } from "../../util/constants.ts"; import { urlToBase64 } from "../../util/utils.ts"; +import { ws } from "../../ws/ws.ts"; /** * Create a new guild based on a template @@ -23,11 +25,17 @@ export async function createGuildFromTemplate( data.icon = await urlToBase64(data.icon); } - // TODO: discordeno guild? - - return await rest.runMethod( + const createdGuild = await rest.runMethod( "post", endpoints.GUILD_TEMPLATE(templateCode), data, ); + + return await structures.createDiscordenoGuild( + createdGuild, + Number( + (BigInt(createdGuild.id) >> 22n % BigInt(ws.botGatewayData.shards)) + .toString(), + ), + ); } diff --git a/src/helpers/templates/create_guild_template.ts b/src/helpers/templates/create_guild_template.ts index b6d54feed..c8f3d5dfb 100644 --- a/src/helpers/templates/create_guild_template.ts +++ b/src/helpers/templates/create_guild_template.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/templates/delete_guild_template.ts b/src/helpers/templates/delete_guild_template.ts index 4cacb22e7..253a39b4e 100644 --- a/src/helpers/templates/delete_guild_template.ts +++ b/src/helpers/templates/delete_guild_template.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/templates/edit_guild_template.ts b/src/helpers/templates/edit_guild_template.ts index d35779cbd..d4aee54df 100644 --- a/src/helpers/templates/edit_guild_template.ts +++ b/src/helpers/templates/edit_guild_template.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyGuildTemplate } from "../../types/templates/modify_guild_template.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { ModifyGuildTemplate } from "../../types/templates/modify_guild_template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/templates/get_guild_templates.ts b/src/helpers/templates/get_guild_templates.ts index 30ba5be5f..c2a3d8521 100644 --- a/src/helpers/templates/get_guild_templates.ts +++ b/src/helpers/templates/get_guild_templates.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/templates/get_template.ts b/src/helpers/templates/get_template.ts index 41213e967..f67d9ffe0 100644 --- a/src/helpers/templates/get_template.ts +++ b/src/helpers/templates/get_template.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the guild template if it exists */ diff --git a/src/helpers/templates/sync_guild_template.ts b/src/helpers/templates/sync_guild_template.ts index 235952321..24fe0fc05 100644 --- a/src/helpers/templates/sync_guild_template.ts +++ b/src/helpers/templates/sync_guild_template.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Template } from "../../types/templates/template.ts"; +import type { Template } from "../../types/templates/template.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/type_guards/is_action_row.ts b/src/helpers/type_guards/is_action_row.ts index c64fc8a6d..2dec9aafe 100644 --- a/src/helpers/type_guards/is_action_row.ts +++ b/src/helpers/type_guards/is_action_row.ts @@ -1,5 +1,5 @@ -import { ActionRow } from "../../types/messages/components/action_row.ts"; -import { MessageComponent } from "../../types/messages/components/message_components.ts"; +import type { ActionRow } from "../../types/messages/components/action_row.ts"; +import type { MessageComponent } from "../../types/messages/components/message_components.ts"; import { MessageComponentTypes } from "../../types/messages/components/message_component_types.ts"; /** A type guard function to tell if it is a action row component */ diff --git a/src/helpers/type_guards/is_button.ts b/src/helpers/type_guards/is_button.ts index dfe2b92cd..acc99645b 100644 --- a/src/helpers/type_guards/is_button.ts +++ b/src/helpers/type_guards/is_button.ts @@ -1,5 +1,5 @@ -import { ButtonComponent } from "../../types/messages/components/button_component.ts"; -import { MessageComponent } from "../../types/messages/components/message_components.ts"; +import type { ButtonComponent } from "../../types/messages/components/button_component.ts"; +import type { MessageComponent } from "../../types/messages/components/message_components.ts"; import { MessageComponentTypes } from "../../types/messages/components/message_component_types.ts"; /** A type guard function to tell if it is a button component */ diff --git a/src/helpers/webhooks/create_webhook.ts b/src/helpers/webhooks/create_webhook.ts index dd169d286..a83c25147 100644 --- a/src/helpers/webhooks/create_webhook.ts +++ b/src/helpers/webhooks/create_webhook.ts @@ -1,7 +1,7 @@ import { rest } from "../../rest/rest.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { CreateWebhook } from "../../types/webhooks/create_webhook.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { CreateWebhook } from "../../types/webhooks/create_webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; import { urlToBase64 } from "../../util/utils.ts"; diff --git a/src/helpers/webhooks/edit_webhook.ts b/src/helpers/webhooks/edit_webhook.ts index 28dc6b11a..244bd129e 100644 --- a/src/helpers/webhooks/edit_webhook.ts +++ b/src/helpers/webhooks/edit_webhook.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/webhooks/edit_webhook_message.ts b/src/helpers/webhooks/edit_webhook_message.ts index d1193a885..d49ca7dfb 100644 --- a/src/helpers/webhooks/edit_webhook_message.ts +++ b/src/helpers/webhooks/edit_webhook_message.ts @@ -1,9 +1,9 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { EditWebhookMessage } from "../../types/webhooks/edit_webhook_message.ts"; +import type { EditWebhookMessage } from "../../types/webhooks/edit_webhook_message.ts"; import { endpoints } from "../../util/constants.ts"; export async function editWebhookMessage( diff --git a/src/helpers/webhooks/edit_webhook_with_token.ts b/src/helpers/webhooks/edit_webhook_with_token.ts index 0d35ead16..3332a1d13 100644 --- a/src/helpers/webhooks/edit_webhook_with_token.ts +++ b/src/helpers/webhooks/edit_webhook_with_token.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; -import { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; /** Edit a webhook. Returns the updated webhook object on success. */ diff --git a/src/helpers/webhooks/get_webhook.ts b/src/helpers/webhooks/get_webhook.ts index 6dd2e655d..86f40ab5e 100644 --- a/src/helpers/webhooks/get_webhook.ts +++ b/src/helpers/webhooks/get_webhook.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the new webhook object for the given id. */ diff --git a/src/helpers/webhooks/get_webhook_with_token.ts b/src/helpers/webhooks/get_webhook_with_token.ts index 665011c84..d4085b1c1 100644 --- a/src/helpers/webhooks/get_webhook_with_token.ts +++ b/src/helpers/webhooks/get_webhook_with_token.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. */ diff --git a/src/helpers/webhooks/get_webhooks.ts b/src/helpers/webhooks/get_webhooks.ts index c05c1a3cb..a9e90873d 100644 --- a/src/helpers/webhooks/get_webhooks.ts +++ b/src/helpers/webhooks/get_webhooks.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import { Webhook } from "../../types/webhooks/webhook.ts"; +import type { Webhook } from "../../types/webhooks/webhook.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; diff --git a/src/helpers/webhooks/execute_webhook.ts b/src/helpers/webhooks/send_webhook.ts similarity index 89% rename from src/helpers/webhooks/execute_webhook.ts rename to src/helpers/webhooks/send_webhook.ts index 2a03e3ebb..e627e485a 100644 --- a/src/helpers/webhooks/execute_webhook.ts +++ b/src/helpers/webhooks/send_webhook.ts @@ -1,13 +1,13 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; -import { Message } from "../../types/messages/message.ts"; +import type { Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; -import { ExecuteWebhook } from "../../types/webhooks/execute_webhook.ts"; +import type { ExecuteWebhook } from "../../types/webhooks/execute_webhook.ts"; import { endpoints } from "../../util/constants.ts"; -/** Execute a webhook with webhook Id and webhook token */ -export async function executeWebhook( +/** Send a webhook with webhook Id and webhook token */ +export async function sendWebhook( webhookId: bigint, webhookToken: string, options: ExecuteWebhook, @@ -75,7 +75,6 @@ export async function executeWebhook( avatar_url: options.avatarUrl, }, ); - // TODO: not sure if (!options.wait) return; return structures.createDiscordenoMessage(result); diff --git a/src/interactions/deps.ts b/src/interactions/deps.ts index 9c4f4dbfd..f6b84df8a 100644 --- a/src/interactions/deps.ts +++ b/src/interactions/deps.ts @@ -1 +1 @@ -export { sign } from "https://unpkg.com/@evan/wasm@0.0.50/target/nacl/deno.js"; +export { verify } from "https://unpkg.com/@evan/wasm@0.0.50/target/ed25519/deno.js"; diff --git a/src/interactions/verify_signature.ts b/src/interactions/verify_signature.ts index 6d73ccf17..eed18557f 100644 --- a/src/interactions/verify_signature.ts +++ b/src/interactions/verify_signature.ts @@ -1,12 +1,12 @@ -import { sign } from "./deps.ts"; +import { verify } from "./deps.ts"; export function verifySignature( { publicKey, signature, timestamp, body }: VerifySignatureOptions, ): { isValid: boolean; body: string } { - const isValid = sign.verify( - new TextEncoder().encode(timestamp + body), - hexToUint8Array(signature), + const isValid = verify( hexToUint8Array(publicKey), + hexToUint8Array(signature), + new TextEncoder().encode(timestamp + body), ); return { isValid, body }; diff --git a/src/rest/create_request_body.ts b/src/rest/create_request_body.ts index 3ab79d995..76f01a7ec 100644 --- a/src/rest/create_request_body.ts +++ b/src/rest/create_request_body.ts @@ -1,4 +1,4 @@ -import { FileContent } from "../types/misc/file_content.ts"; +import type { FileContent } from "../types/misc/file_content.ts"; import { USER_AGENT } from "../util/constants.ts"; import { rest, RestPayload, RestRequest } from "./rest.ts"; diff --git a/src/structures/channel.ts b/src/structures/channel.ts index eb95681ab..d9e81b357 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -8,11 +8,14 @@ import { editChannel } from "../helpers/channels/edit_channel.ts"; import { editChannelOverwrite } from "../helpers/channels/edit_channel_overwrite.ts"; import { sendMessage } from "../helpers/messages/send_message.ts"; import { disconnectMember } from "../helpers/mod.ts"; -import { Channel } from "../types/channels/channel.ts"; -import { ModifyChannel } from "../types/channels/modify_channel.ts"; -import { DiscordOverwrite, Overwrite } from "../types/channels/overwrite.ts"; -import { CreateMessage } from "../types/messages/create_message.ts"; -import { PermissionStrings } from "../types/permissions/permission_strings.ts"; +import type { Channel } from "../types/channels/channel.ts"; +import type { ModifyChannel } from "../types/channels/modify_channel.ts"; +import type { + DiscordOverwrite, + Overwrite, +} from "../types/channels/overwrite.ts"; +import type { CreateMessage } from "../types/messages/create_message.ts"; +import type { PermissionStrings } from "../types/permissions/permission_strings.ts"; import { snowflakeToBigint } from "../util/bigint.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 8e7983909..e90f0f5b2 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -13,18 +13,18 @@ import { getInvites } from "../helpers/invites/get_invites.ts"; import { banMember } from "../helpers/members/ban_member.ts"; import { unbanMember } from "../helpers/members/unban_member.ts"; import { GetGuildAuditLog } from "../types/audit_log/get_guild_audit_log.ts"; -import { Emoji } from "../types/emojis/emoji.ts"; -import { CreateGuildBan } from "../types/guilds/create_guild_ban.ts"; -import { Guild } from "../types/guilds/guild.ts"; +import type { Emoji } from "../types/emojis/emoji.ts"; +import type { CreateGuildBan } from "../types/guilds/create_guild_ban.ts"; +import type { Guild } from "../types/guilds/guild.ts"; import { DiscordGuildFeatures } from "../types/guilds/guild_features.ts"; -import { +import type { GuildMember, GuildMemberWithUser, } from "../types/guilds/guild_member.ts"; -import { ModifyGuild } from "../types/guilds/modify_guild.ts"; -import { DiscordImageFormat } from "../types/misc/image_format.ts"; -import { DiscordImageSize } from "../types/misc/image_size.ts"; -import { PresenceUpdate } from "../types/misc/presence_update.ts"; +import type { ModifyGuild } from "../types/guilds/modify_guild.ts"; +import type { DiscordImageFormat } from "../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../types/misc/image_size.ts"; +import type { PresenceUpdate } from "../types/misc/presence_update.ts"; import { snowflakeToBigint } from "../util/bigint.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; @@ -47,6 +47,19 @@ const GUILD_SNOWFLAKES = [ "publicUpdatesChannelId", ]; +export const guildToggles = { + /** Whether this user is owner of this guild */ + owner: 1n, + /** Whether the guild widget is enabled */ + widgetEnabled: 2n, + /** Whether this is a large guild */ + large: 4n, + /** Whether this guild is unavailable due to an outage */ + unavailable: 8n, + /** Whether this server is an nsfw guild */ + nsfw: 16n, +}; + const baseGuild: Partial = { get members() { return cache.members.filter((member) => member.guilds.has(this.id!)); @@ -120,6 +133,21 @@ const baseGuild: Partial = { leave() { return leaveGuild(this.id!); }, + get isOwner() { + return Boolean(this.bitfield! & guildToggles.owner); + }, + get widgetEnabled() { + return Boolean(this.bitfield! & guildToggles.widgetEnabled); + }, + get large() { + return Boolean(this.bitfield! & guildToggles.large); + }, + get unavailable() { + return Boolean(this.bitfield! & guildToggles.unavailable); + }, + get nsfw() { + return Boolean(this.bitfield! & guildToggles.nsfw); + }, }; export async function createDiscordenoGuild( @@ -138,6 +166,7 @@ export async function createDiscordenoGuild( ...rest } = data; + let bitfield = 0n; const guildId = snowflakeToBigint(rest.id); const roles = await Promise.all( @@ -173,6 +202,12 @@ export async function createDiscordenoGuild( `Running for of loop in createDiscordenoGuild function.`, ); + const toggleBits = guildToggles[key as keyof typeof guildToggles]; + if (toggleBits) { + bitfield |= value ? toggleBits : 0n; + continue; + } + props[key] = createNewProp( GUILD_SNOWFLAKES.includes(key) ? value ? snowflakeToBigint(value) : undefined @@ -203,6 +238,7 @@ export async function createDiscordenoGuild( voiceStates: createNewProp( new Collection(voiceStateStructs.map((vs) => [vs.userId, vs])), ), + bitfield: createNewProp(bitfield), }); // ONLY ADD TO QUEUE WHEN BOT IS NOT FULLY ONLINE @@ -279,6 +315,10 @@ export interface DiscordenoGuild extends voiceStates: Collection; /** Custom guild emojis */ emojis: Collection; + /** Whether the bot is the owner of this guild */ + isOwner: boolean; + /** Holds all the boolean toggles. */ + bitfield: bigint; // GETTERS /** Members in this guild. */ diff --git a/src/structures/member.ts b/src/structures/member.ts index a250cb15f..d592dcabd 100644 --- a/src/structures/member.ts +++ b/src/structures/member.ts @@ -7,27 +7,37 @@ import { kickMember } from "../helpers/members/kick_member.ts"; import { sendDirectMessage } from "../helpers/members/send_direct_message.ts"; import { addRole } from "../helpers/roles/add_role.ts"; import { removeRole } from "../helpers/roles/remove_role.ts"; -import { CreateGuildBan } from "../types/guilds/create_guild_ban.ts"; -import { +import type { CreateGuildBan } from "../types/guilds/create_guild_ban.ts"; +import type { GuildMember, GuildMemberWithUser, } from "../types/guilds/guild_member.ts"; -import { ModifyGuildMember } from "../types/guilds/modify_guild_member.ts"; -import { CreateMessage } from "../types/messages/create_message.ts"; -import { DiscordImageFormat } from "../types/misc/image_format.ts"; -import { DiscordImageSize } from "../types/misc/image_size.ts"; -import { User } from "../types/users/user.ts"; +import type { ModifyGuildMember } from "../types/guilds/modify_guild_member.ts"; +import type { CreateMessage } from "../types/messages/create_message.ts"; +import type { DiscordImageFormat } from "../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../types/misc/image_size.ts"; +import type { User } from "../types/users/user.ts"; import { snowflakeToBigint } from "../util/bigint.ts"; import { Collection } from "../util/collection.ts"; import { createNewProp } from "../util/utils.ts"; import { DiscordenoGuild } from "./guild.ts"; const MEMBER_SNOWFLAKES = [ - "roles", "id", "discriminator", ]; +export const memberToggles = { + /** Whether the user belongs to an OAuth2 application */ + bot: 1n, + /** Whether the user is an Official Discord System user (part of the urgent message system) */ + system: 2n, + /** Whether the user has two factor enabled on their account */ + mfaEnabled: 4n, + /** Whether the email on this account has been verified */ + verified: 8n, +}; + const baseMember: Partial = { get avatarURL() { return avatarURL(this.id!, this.discriminator!, this.avatar!); @@ -76,6 +86,18 @@ const baseMember: Partial = { removeRole(guildId, roleId, reason) { return removeRole(guildId, this.id!, roleId, reason); }, + get bot() { + return Boolean(this.bitfield! & memberToggles.bot); + }, + get system() { + return Boolean(this.bitfield! & memberToggles.system); + }, + get mfaEnabled() { + return Boolean(this.bitfield! & memberToggles.mfaEnabled); + }, + get verified() { + return Boolean(this.bitfield! & memberToggles.verified); + }, }; export async function createDiscordenoMember( @@ -87,35 +109,23 @@ export async function createDiscordenoMember( user, joinedAt, premiumSince, - ...rest } = data; + let bitfield = 0n; const props: Record> = {}; - for (const [key, value] of Object.entries(rest)) { - eventHandlers.debug?.( - "loop", - `Running for of loop for Object.keys(rest) in DiscordenoMember function.`, - ); - - if (key === "roles") { - props[key] = value.map((id: string) => snowflakeToBigint(id)); - continue; - } - - props[key] = createNewProp( - MEMBER_SNOWFLAKES.includes(key) - ? value ? snowflakeToBigint(value) : undefined - : value, - ); - } - for (const [key, value] of Object.entries(user)) { eventHandlers.debug?.( "loop", `Running for of for Object.keys(user) loop in DiscordenoMember function.`, ); + const toggleBits = memberToggles[key as keyof typeof memberToggles]; + if (toggleBits) { + bitfield |= value ? toggleBits : 0n; + continue; + } + props[key] = createNewProp( MEMBER_SNOWFLAKES.includes(key) ? value ? snowflakeToBigint(value) : undefined @@ -127,6 +137,7 @@ export async function createDiscordenoMember( ...props, /** The guild related data mapped by guild id */ guilds: createNewProp(new Collection()), + bitfield: createNewProp(bitfield), }); const cached = await cacheHandlers.get("members", snowflakeToBigint(user.id)); @@ -142,29 +153,23 @@ export async function createDiscordenoMember( // User was never cached before member.guilds.set(guildId, { - nick: rest.nick, - roles: rest.roles.map((id) => snowflakeToBigint(id)), + nick: data.nick, + roles: data.roles.map((id) => snowflakeToBigint(id)), joinedAt: Date.parse(joinedAt), premiumSince: premiumSince ? Date.parse(premiumSince) : undefined, - deaf: rest.deaf, - mute: rest.mute, + deaf: data.deaf, + mute: data.mute, }); return member; } export interface DiscordenoMember extends - Omit< - GuildMember, - "roles" - >, Omit< User, | "discriminator" | "id" > { - /** Array of role object ids */ - roles: bigint[]; /** The user's id */ id: bigint; /** The user's 4-digit discord-tag */ @@ -178,6 +183,8 @@ export interface DiscordenoMember extends roles: bigint[]; } >; + /** Holds all the boolean toggles. */ + bitfield: bigint; // GETTERS /** The avatar url using the default format and size. */ diff --git a/src/structures/message.ts b/src/structures/message.ts index 47a798594..af8832351 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -10,10 +10,10 @@ import { removeAllReactions } from "../helpers/messages/remove_all_reactions.ts" import { removeReaction } from "../helpers/messages/remove_reaction.ts"; import { removeReactionEmoji } from "../helpers/messages/remove_reaction_emoji.ts"; import { sendMessage } from "../helpers/messages/send_message.ts"; -import { GuildMember } from "../types/guilds/guild_member.ts"; -import { CreateMessage } from "../types/messages/create_message.ts"; -import { EditMessage } from "../types/messages/edit_message.ts"; -import { Message } from "../types/messages/message.ts"; +import type { GuildMember } from "../types/guilds/guild_member.ts"; +import type { CreateMessage } from "../types/messages/create_message.ts"; +import type { EditMessage } from "../types/messages/edit_message.ts"; +import type { Message } from "../types/messages/message.ts"; import { bigintToSnowflake, snowflakeToBigint } from "../util/bigint.ts"; import { CHANNEL_MENTION_REGEX } from "../util/constants.ts"; import { createNewProp } from "../util/utils.ts"; @@ -29,6 +29,15 @@ const MESSAGE_SNOWFLAKES = [ "webhookId", ]; +const messageToggles = { + /** Whether this was a TTS message */ + tts: 1n, + /** Whether this message mentions everyone */ + mentionEveryone: 2n, + /** Whether this message is pinned */ + pinned: 4n, +}; + const baseMessage: Partial = { get channel() { if (this.guildId) return cache.channels.get(this.channelId!); @@ -132,6 +141,15 @@ const baseMessage: Partial = { removeReaction(reaction, userId) { return removeReaction(this.channelId!, this.id!, reaction, { userId }); }, + get tts() { + return Boolean(this.bitfield! & messageToggles.tts); + }, + get mentionEveryone() { + return Boolean(this.bitfield! & messageToggles.mentionEveryone); + }, + get pinned() { + return Boolean(this.bitfield! & messageToggles.pinned); + }, }; export async function createDiscordenoMessage(data: Message) { @@ -146,6 +164,8 @@ export async function createDiscordenoMessage(data: Message) { ...rest } = data; + let bitfield = 0n; + const props: Record> = {}; for (const [key, value] of Object.entries(rest)) { eventHandlers.debug?.( @@ -153,6 +173,12 @@ export async function createDiscordenoMessage(data: Message) { `Running for of loop in createDiscordenoMessage function.`, ); + const toggleBits = messageToggles[key as keyof typeof messageToggles]; + if (toggleBits) { + bitfield |= value ? toggleBits : 0n; + continue; + } + props[key] = createNewProp( MESSAGE_SNOWFLAKES.includes(key) ? value ? snowflakeToBigint(value) : undefined @@ -208,6 +234,7 @@ export async function createDiscordenoMessage(data: Message) { } : undefined, ), + bitfield: createNewProp(bitfield), }); return message; @@ -231,7 +258,11 @@ export interface DiscordenoMessage extends isBot: boolean; /** The username#discrimnator for the user who sent this message */ tag: string; + /** Holds all the boolean toggles. */ + bitfield: bigint; + // For better user experience + /** Id of the guild which the massage has been send in. "0n" if it a DM */ guildId: bigint; /** id of the channel the message was sent in */ @@ -252,6 +283,7 @@ export interface DiscordenoMessage extends timestamp: number; /** When this message was edited (or undefined if never) */ editedTimestamp?: number; + // GETTERS /** The channel where this message was sent. Can be undefined if uncached. */ diff --git a/src/structures/role.ts b/src/structures/role.ts index 783c20ce2..58536c499 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -4,7 +4,7 @@ import { deleteRole } from "../helpers/roles/delete_role.ts"; import { editRole } from "../helpers/roles/edit_role.ts"; import { CreateGuildRole } from "../types/guilds/create_guild_role.ts"; import { Errors } from "../types/misc/errors.ts"; -import { Role } from "../types/permissions/role.ts"; +import type { Role } from "../types/permissions/role.ts"; import { snowflakeToBigint } from "../util/bigint.ts"; import { Collection } from "../util/collection.ts"; import { highestRole } from "../util/permissions.ts"; @@ -19,6 +19,17 @@ const ROLE_SNOWFLAKES = [ "guildId", ]; +const roleToggles = { + /** If this role is showed seperately in the user listing */ + hoist: 1n, + /** Whether this role is managed by an integration */ + managed: 2n, + /** Whether this role is mentionable */ + mentionable: 4n, + /** If this role is the nitro boost role. */ + isNitroBoostRole: 8n, +}; + const baseRole: Partial = { get guild() { return cache.guilds.get(this.guildId!); @@ -71,6 +82,18 @@ const baseRole: Partial = { memberHighestRole.position, ); }, + get hoist() { + return Boolean(this.bitfield! & roleToggles.hoist); + }, + get managed() { + return Boolean(this.bitfield! & roleToggles.managed); + }, + get mentionable() { + return Boolean(this.bitfield! & roleToggles.mentionable); + }, + get isNitroBoostRole() { + return Boolean(this.bitfield! & roleToggles.isNitroBoostRole); + }, }; // deno-lint-ignore require-await @@ -84,6 +107,8 @@ export async function createDiscordenoRole( ...rest } = ({ guildId: data.guildId, ...data.role }); + let bitfield = 0n; + const props: Record> = {}; for (const [key, value] of Object.entries(rest)) { eventHandlers.debug?.( @@ -91,6 +116,12 @@ export async function createDiscordenoRole( `Running for of loop in createDiscordenoRole function.`, ); + const toggleBits = roleToggles[key as keyof typeof roleToggles]; + if (toggleBits) { + bitfield |= value ? toggleBits : 0n; + continue; + } + props[key] = createNewProp( ROLE_SNOWFLAKES.includes(key) ? value ? snowflakeToBigint(value) : undefined @@ -107,6 +138,7 @@ export async function createDiscordenoRole( integrationId: createNewProp( tags.integrationId ? snowflakeToBigint(tags.integrationId) : undefined, ), + bitfield: createNewProp(bitfield), }); return role; @@ -123,6 +155,8 @@ export interface DiscordenoRole extends Omit { integrationId: bigint; /** The roles guildId */ guildId: bigint; + /** Holds all the boolean toggles. */ + bitfield: bigint; // GETTERS diff --git a/src/structures/voice_state.ts b/src/structures/voice_state.ts index c5c846562..48a7f906b 100644 --- a/src/structures/voice_state.ts +++ b/src/structures/voice_state.ts @@ -1,7 +1,7 @@ import { eventHandlers } from "../bot.ts"; import { cache } from "../cache.ts"; -import { GuildMember } from "../types/guilds/guild_member.ts"; -import { VoiceState } from "../types/voice/voice_state.ts"; +import type { GuildMember } from "../types/guilds/guild_member.ts"; +import type { VoiceState } from "../types/voice/voice_state.ts"; import { snowflakeToBigint } from "../util/bigint.ts"; import { createNewProp } from "../util/utils.ts"; import { DiscordenoGuild } from "./guild.ts"; @@ -82,7 +82,7 @@ export async function createDiscordenoVoiceState( const toggleBits = voiceStateToggles[key as keyof typeof voiceStateToggles]; if (toggleBits) { - bitfield |= toggleBits; + bitfield |= value ? toggleBits : 0n; continue; } diff --git a/src/types/channels/modify_channel.ts b/src/types/channels/modify_channel.ts index b6defe24b..09db31d89 100644 --- a/src/types/channels/modify_channel.ts +++ b/src/types/channels/modify_channel.ts @@ -35,7 +35,6 @@ export interface DiscordModifyChannel extends SnakeCasedPropertiesDeep< Omit > { + // deno-lint-ignore camelcase permission_overwrites?: DiscordOverwrite[]; } - -//TODO: check this diff --git a/src/types/guilds/create_guild_channel.ts b/src/types/guilds/create_guild_channel.ts index d6fe506d0..38eb79102 100644 --- a/src/types/guilds/create_guild_channel.ts +++ b/src/types/guilds/create_guild_channel.ts @@ -30,6 +30,6 @@ export interface DiscordCreateGuildChannel extends SnakeCasedPropertiesDeep< Omit > { + // deno-lint-ignore camelcase permission_overwrites: DiscordOverwrite[]; } -// TODO: check this diff --git a/src/types/guilds/create_guild_role.ts b/src/types/guilds/create_guild_role.ts index 2183a0f7d..d1be99b30 100644 --- a/src/types/guilds/create_guild_role.ts +++ b/src/types/guilds/create_guild_role.ts @@ -18,4 +18,3 @@ export interface DiscordCreateGuildRole extends Omit { permissions?: string; } -// TODO: check this diff --git a/src/types/guilds/guild.ts b/src/types/guilds/guild.ts index f98e94322..a6b050529 100644 --- a/src/types/guilds/guild.ts +++ b/src/types/guilds/guild.ts @@ -108,7 +108,7 @@ export interface Guild { approximateMemberCount?: number; /** Approximate number of non-offline members in this guild, returned from the GET /guilds/ endpoint when with_counts is true */ approximatePresenceCount?: number; - /** The welcome screen of a Community guild, shown to new members, returned when in the invite object */ + /** The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object */ welcomeScreen?: WelcomeScreen; /** `true` if this guild is designated as NSFW */ nsfw: boolean; diff --git a/src/types/guilds/modify_guild_channel_position.ts b/src/types/guilds/modify_guild_channel_position.ts index 646cce814..734786e9c 100644 --- a/src/types/guilds/modify_guild_channel_position.ts +++ b/src/types/guilds/modify_guild_channel_position.ts @@ -1,4 +1,3 @@ -// TODO: most likely it is but check if lockPositions and parentId really are optional /** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ export interface ModifyGuildChannelPositions { /** Channel id */ diff --git a/src/types/guilds/modify_guild_role.ts b/src/types/guilds/modify_guild_role.ts index cb5e09006..a23d92329 100644 --- a/src/types/guilds/modify_guild_role.ts +++ b/src/types/guilds/modify_guild_role.ts @@ -18,5 +18,3 @@ export interface DiscordModifyGuildRole extends Omit { permissions?: string | null; } - -// TODO: check this diff --git a/src/types/messages/create_message.ts b/src/types/messages/create_message.ts index 836b0040c..fa1704f90 100644 --- a/src/types/messages/create_message.ts +++ b/src/types/messages/create_message.ts @@ -28,5 +28,3 @@ export interface CreateMessage { export type DiscordCreateMessage = SnakeCasedPropertiesDeep< Omit >; - -// TODO: check this diff --git a/src/types/oauth2/application_flags.ts b/src/types/oauth2/application_flags.ts index 5fe9538f2..d2ada528b 100644 --- a/src/types/oauth2/application_flags.ts +++ b/src/types/oauth2/application_flags.ts @@ -1,5 +1,4 @@ -// https://github.com/discord/discord-api-docs/pull/2624 -// TODO: add documentation link +/** https://discord.com/developers/docs/topics/oauth2#application-application-flags */ export enum DiscordApplicationFlags { GatewayPresence = 1 << 12, GatewayPresenceLimited = 1 << 13, diff --git a/src/types/webhooks/execute_webhook.ts b/src/types/webhooks/execute_webhook.ts index f668a0906..9268f21bf 100644 --- a/src/types/webhooks/execute_webhook.ts +++ b/src/types/webhooks/execute_webhook.ts @@ -26,4 +26,3 @@ export interface ExecuteWebhook { export type DiscordExecuteWebhook = SnakeCasedPropertiesDeep< Omit >; -//TODO: check this diff --git a/src/util/permissions.ts b/src/util/permissions.ts index ba58860b0..fec52ffb8 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -7,7 +7,7 @@ import { DiscordenoRole } from "../structures/role.ts"; import { Overwrite } from "../types/channels/overwrite.ts"; import { Errors } from "../types/misc/errors.ts"; import { DiscordBitwisePermissionFlags } from "../types/permissions/bitwise_permission_flags.ts"; -import { PermissionStrings } from "../types/permissions/permission_strings.ts"; +import type { PermissionStrings } from "../types/permissions/permission_strings.ts"; async function getCached( table: "guilds", diff --git a/src/util/utils.ts b/src/util/utils.ts index af2d605b1..c37bcb0fd 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -1,13 +1,13 @@ import { encode } from "../../deps.ts"; import { eventHandlers } from "../bot.ts"; -import { ApplicationCommandOption } from "../types/interactions/application_command_option.ts"; -import { ApplicationCommandOptionChoice } from "../types/interactions/application_command_option_choice.ts"; +import type { ApplicationCommandOption } from "../types/interactions/application_command_option.ts"; +import type { ApplicationCommandOptionChoice } from "../types/interactions/application_command_option_choice.ts"; import { DiscordApplicationCommandOptionTypes } from "../types/interactions/application_command_option_types.ts"; -import { CreateGlobalApplicationCommand } from "../types/interactions/create_global_application_command.ts"; +import type { CreateGlobalApplicationCommand } from "../types/interactions/create_global_application_command.ts"; +import type { EditGlobalApplicationCommand } from "../types/interactions/edit_global_application_command.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 { EditGlobalApplicationCommand } from "../types/mod.ts"; +import type { DiscordImageFormat } from "../types/misc/image_format.ts"; +import type { DiscordImageSize } from "../types/misc/image_size.ts"; import { SLASH_COMMANDS_NAME_REGEX } from "./constants.ts"; import { validateLength } from "./validate_length.ts"; diff --git a/src/ws/events.ts b/src/ws/events.ts index a64d7e474..1a9a03e6d 100644 --- a/src/ws/events.ts +++ b/src/ws/events.ts @@ -1,4 +1,4 @@ -import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; +import type { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; import { DiscordenoShard } from "./ws.ts"; /** The handler for logging different actions happening inside the ws. User can override and put custom handling per event. */ diff --git a/src/ws/handle_discord_payload.ts b/src/ws/handle_discord_payload.ts index a1ba8ddb8..3a21169a1 100644 --- a/src/ws/handle_discord_payload.ts +++ b/src/ws/handle_discord_payload.ts @@ -1,4 +1,4 @@ -import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; +import type { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; import { ws } from "./ws.ts"; /** Handler for processing all dispatch payloads that should be sent/forwarded to another server/vps/process. */ diff --git a/src/ws/handle_on_message.ts b/src/ws/handle_on_message.ts index 055b6e203..2dee79979 100644 --- a/src/ws/handle_on_message.ts +++ b/src/ws/handle_on_message.ts @@ -1,9 +1,9 @@ import { eventHandlers } from "../bot.ts"; import { handlers } from "../handlers/mod.ts"; import { DiscordGatewayOpcodes } from "../types/codes/gateway_opcodes.ts"; -import { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; -import { DiscordHello } from "../types/gateway/hello.ts"; -import { DiscordReady } from "../types/gateway/ready.ts"; +import type { DiscordGatewayPayload } from "../types/gateway/gateway_payload.ts"; +import type { DiscordHello } from "../types/gateway/hello.ts"; +import type { DiscordReady } from "../types/gateway/ready.ts"; import { delay, snakeKeysToCamelCase } from "../util/utils.ts"; import { decompressWith } from "./deps.ts"; import { identify } from "./identify.ts"; diff --git a/src/ws/start_gateway.ts b/src/ws/start_gateway.ts index e057a91d8..11062276f 100644 --- a/src/ws/start_gateway.ts +++ b/src/ws/start_gateway.ts @@ -1,5 +1,5 @@ import { DiscordGatewayIntents } from "../types/gateway/gateway_intents.ts"; -import { GetGatewayBot } from "../types/gateway/get_gateway_bot.ts"; +import type { GetGatewayBot } from "../types/gateway/get_gateway_bot.ts"; import { snakeKeysToCamelCase } from "../util/utils.ts"; import { StartGatewayOptions } from "./start_gateway_options.ts"; import { ws } from "./ws.ts"; diff --git a/tests/channels/channel_overwrite_has_permission.ts b/tests/channels/channel_overwrite_has_permission.ts index bda7a79f2..71d3402b3 100644 --- a/tests/channels/channel_overwrite_has_permission.ts +++ b/tests/channels/channel_overwrite_has_permission.ts @@ -10,8 +10,7 @@ import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; -// TODO: whats save? -async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) { +async function ifItFailsBlameWolf(options: CreateGuildChannel) { const channel = await createChannel(tempData.guildId, options); // Assertions @@ -60,7 +59,6 @@ Deno.test({ }, ], }, - true, ); }, ...defaultTestOptions, diff --git a/tests/channels/clone_channel.ts b/tests/channels/clone_channel.ts index 37dfdaa63..4b526da61 100644 --- a/tests/channels/clone_channel.ts +++ b/tests/channels/clone_channel.ts @@ -10,8 +10,7 @@ import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; -// TODO: whats save -async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) { +async function ifItFailsBlameWolf(options: CreateGuildChannel) { const channel = await createChannel(tempData.guildId, options); const cloned = await cloneChannel(channel.id); @@ -51,7 +50,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) { Deno.test({ name: "[channel] clone a new text channel", async fn() { - await ifItFailsBlameWolf({ name: "Discordeno-clone-test" }, false); + await ifItFailsBlameWolf({ name: "Discordeno-clone-test" }); }, ...defaultTestOptions, }); @@ -64,7 +63,6 @@ Deno.test({ name: "Discordeno-clone-test", type: DiscordChannelTypes.GuildCategory, }, - false, ); }, ...defaultTestOptions, @@ -78,7 +76,6 @@ Deno.test({ name: "Discordeno-clone-test", type: DiscordChannelTypes.GuildVoice, }, - false, ); }, ...defaultTestOptions, @@ -93,7 +90,6 @@ Deno.test({ type: DiscordChannelTypes.GuildVoice, bitrate: 32000, }, - false, ); }, ...defaultTestOptions, @@ -108,7 +104,6 @@ Deno.test({ type: DiscordChannelTypes.GuildVoice, userLimit: 32, }, - false, ); }, ...defaultTestOptions, @@ -122,7 +117,6 @@ Deno.test({ name: "Discordeno-clone-test", rateLimitPerUser: 2423, }, - false, ); }, ...defaultTestOptions, @@ -133,7 +127,6 @@ Deno.test({ async fn() { await ifItFailsBlameWolf( { name: "Discordeno-clone-test", nsfw: true }, - false, ); }, ...defaultTestOptions, @@ -154,7 +147,6 @@ Deno.test({ }, ], }, - false, ); }, ...defaultTestOptions, diff --git a/tests/channels/edit_channel_overwrite.ts b/tests/channels/edit_channel_overwrite.ts index 6eebdaeae..b1482b4f5 100644 --- a/tests/channels/edit_channel_overwrite.ts +++ b/tests/channels/edit_channel_overwrite.ts @@ -11,8 +11,7 @@ import { assertEquals, assertExists } from "../deps.ts"; import { delayUntil } from "../util/delay_until.ts"; import { defaultTestOptions, tempData } from "../ws/start_bot.ts"; -// TODO: whats save -async function ifItFailsBlameWolf(options: CreateGuildChannel, _save = false) { +async function ifItFailsBlameWolf(options: CreateGuildChannel) { const channel = await createChannel(tempData.guildId, options); // Assertions @@ -78,7 +77,6 @@ Deno.test({ }, ], }, - true, ); }, ...defaultTestOptions,