From 03996c5f5816b094891122f2e904d770131aa0fd Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 2 Jul 2022 15:24:43 +0200 Subject: [PATCH] refactor: revert "feat: base plugin lib idea (#2308)" (#2336) * Revert "feat: base plugin lib idea (#2308)" This reverts commit ffe7cdbc6f140c09a429ce1d3334f91ff5c1bea7. * fmt --- plugins/bot/bot.ts => bot.ts | 199 ++++++++++-------- gateway/manager/gatewayManager.ts | 10 +- gateway/manager/stop.ts | 2 +- gateway/shard/createShard.ts | 5 +- gateway/shard/handleMessage.ts | 2 +- gateway/shard/types.ts | 2 + .../channels/CHANNEL_CREATE.ts | 4 +- .../channels/CHANNEL_DELETE.ts | 4 +- .../channels/CHANNEL_PINS_UPDATE.ts | 4 +- .../channels/CHANNEL_UPDATE.ts | 4 +- .../channels/STAGE_INSTANCE_CREATE.ts | 4 +- .../channels/STAGE_INSTANCE_DELETE.ts | 4 +- .../channels/STAGE_INSTANCE_UPDATE.ts | 4 +- .../channels/THREAD_CREATE.ts | 2 +- .../channels/THREAD_DELETE.ts | 2 +- .../channels/THREAD_LIST_SYNC.ts | 2 +- .../channels/THREAD_MEMBERS_UPDATE.ts | 2 +- .../channels/THREAD_MEMBER_UPDATE.ts | 2 +- .../channels/THREAD_UPDATE.ts | 2 +- .../bot/handlers => handlers}/channels/mod.ts | 0 .../emojis/GUILD_EMOJIS_UPDATE.ts | 6 +- .../bot/handlers => handlers}/emojis/mod.ts | 0 .../guilds/GUILD_BAN_ADD.ts | 4 +- .../guilds/GUILD_BAN_REMOVE.ts | 4 +- .../guilds/GUILD_CREATE.ts | 4 +- .../guilds/GUILD_DELETE.ts | 4 +- .../guilds/GUILD_INTEGRATIONS_UPDATE.ts | 4 +- .../guilds/GUILD_LOADED_DD.ts | 4 +- .../guilds/GUILD_UPDATE.ts | 4 +- .../AUTO_MODERATION_ACTION_EXECUTION.ts | 4 +- .../automod/AUTO_MODERATION_RULE_CREATE.ts | 4 +- .../automod/AUTO_MODERATION_RULE_DELETE.ts | 4 +- .../automod/AUTO_MODERATION_RULE_UPDATE.ts | 4 +- .../guilds/automod/mod.ts | 0 .../bot/handlers => handlers}/guilds/mod.ts | 0 .../GUILD_SCHEDULED_EVENT_CREATE.ts | 4 +- .../GUILD_SCHEDULED_EVENT_DELETE.ts | 4 +- .../GUILD_SCHEDULED_EVENT_UPDATE.ts | 4 +- .../GUILD_SCHEDULED_EVENT_USER_ADD.ts | 4 +- .../GUILD_SCHEDULED_EVENT_USER_REMOVE.ts | 4 +- .../guilds/scheduledEvents/mod.ts | 0 .../integrations/INTEGRATION_CREATE.ts | 2 +- .../integrations/INTEGRATION_DELETE.ts | 2 +- .../integrations/INTEGRATION_UPDATE.ts | 2 +- .../handlers => handlers}/integrations/mod.ts | 0 .../interactions/INTERACTION_CREATE.ts | 2 +- .../handlers => handlers}/interactions/mod.ts | 0 .../invites/INVITE_CREATE.ts | 2 +- .../invites/INVITE_DELETE.ts | 2 +- .../bot/handlers => handlers}/invites/mod.ts | 0 .../members/GUILD_MEMBERS_CHUNK.ts | 2 +- .../members/GUILD_MEMBER_ADD.ts | 2 +- .../members/GUILD_MEMBER_REMOVE.ts | 2 +- .../members/GUILD_MEMBER_UPDATE.ts | 2 +- .../bot/handlers => handlers}/members/mod.ts | 0 .../messages/MESSAGE_CREATE.ts | 2 +- .../messages/MESSAGE_DELETE.ts | 2 +- .../messages/MESSAGE_DELETE_BULK.ts | 2 +- .../messages/MESSAGE_REACTION_ADD.ts | 2 +- .../messages/MESSAGE_REACTION_REMOVE.ts | 2 +- .../messages/MESSAGE_REACTION_REMOVE_ALL.ts | 2 +- .../messages/MESSAGE_REACTION_REMOVE_EMOJI.ts | 2 +- .../messages/MESSAGE_UPDATE.ts | 2 +- .../bot/handlers => handlers}/messages/mod.ts | 0 .../misc/PRESENCE_UPDATE.ts | 2 +- .../bot/handlers => handlers}/misc/READY.ts | 2 +- .../misc/TYPING_START.ts | 2 +- .../handlers => handlers}/misc/USER_UPDATE.ts | 2 +- .../bot/handlers => handlers}/misc/mod.ts | 0 {plugins/bot/handlers => handlers}/mod.ts | 0 .../roles/GUILD_ROLE_CREATE.ts | 2 +- .../roles/GUILD_ROLE_DELETE.ts | 2 +- .../roles/GUILD_ROLE_UPDATE.ts | 2 +- .../bot/handlers => handlers}/roles/mod.ts | 0 .../voice/VOICE_SERVER_UPDATE.ts | 2 +- .../voice/VOICE_STATE_UPDATE.ts | 2 +- .../bot/handlers => handlers}/voice/mod.ts | 0 .../webhooks/WEBHOOKS_UPDATE.ts | 2 +- .../bot/handlers => handlers}/webhooks/mod.ts | 0 .../channels/createChannel.ts | 5 +- .../channels/createStageInstance.ts | 4 +- .../channels/deleteChannel.ts | 4 +- .../channels/deleteChannelOverwrite.ts | 2 +- .../channels/deleteStageInstance.ts | 2 +- .../channels/editChannel.ts | 5 +- .../channels/editChannelOverwrite.ts | 4 +- .../channels/followChannel.ts | 4 +- .../channels/forums/createForumPost.ts | 6 +- .../channels/forums/mod.ts | 0 .../channels/getChannel.ts | 4 +- .../channels/getChannelWebhooks.ts | 6 +- .../channels/getChannels.ts | 6 +- .../helpers => helpers}/channels/getPins.ts | 4 +- .../channels/getStageInstance.ts | 4 +- .../bot/helpers => helpers}/channels/mod.ts | 0 .../channels/startTyping.ts | 2 +- .../channels/swapChannels.ts | 2 +- .../channels/threads/addToThread.ts | 2 +- .../channels/threads/getActiveThreads.ts | 6 +- .../channels/threads/getArchivedThreads.ts | 6 +- .../channels/threads/getThreadMember.ts | 4 +- .../channels/threads/getThreadMembers.ts | 6 +- .../channels/threads/joinThread.ts | 2 +- .../channels/threads/leaveThread.ts | 2 +- .../channels/threads/mod.ts | 0 .../channels/threads/removeThreadMember.ts | 2 +- .../threads/startThreadWithMessage.ts | 4 +- .../threads/startThreadWithoutMessage.ts | 5 +- .../channels/updateStageInstance.ts | 5 +- .../channels/updateVoiceState.ts | 2 +- .../discovery/addDiscoverySubcategory.ts | 4 +- .../discovery/editDiscovery.ts | 4 +- .../discovery/getDiscovery.ts | 4 +- .../discovery/getDiscoveryCategories.ts | 6 +- .../bot/helpers => helpers}/discovery/mod.ts | 0 .../discovery/removeDiscoverySubcategory.ts | 2 +- .../discovery/validDiscoveryTerm.ts | 4 +- .../helpers => helpers}/emojis/createEmoji.ts | 4 +- .../helpers => helpers}/emojis/deleteEmoji.ts | 2 +- .../helpers => helpers}/emojis/editEmoji.ts | 4 +- .../helpers => helpers}/emojis/emojiUrl.ts | 0 .../helpers => helpers}/emojis/getEmoji.ts | 4 +- .../helpers => helpers}/emojis/getEmojis.ts | 6 +- .../bot/helpers => helpers}/emojis/mod.ts | 0 .../guilds/automod/createAutomodRule.ts | 2 +- .../guilds/automod/deleteAutomodRule.ts | 0 .../guilds/automod/editAutomodRule.ts | 2 +- .../guilds/automod/getAutomodRule.ts | 4 +- .../guilds/automod/getAutomodRules.ts | 4 +- .../helpers => helpers}/guilds/automod/mod.ts | 0 .../helpers => helpers}/guilds/createGuild.ts | 6 +- .../helpers => helpers}/guilds/deleteGuild.ts | 2 +- .../helpers => helpers}/guilds/editGuild.ts | 6 +- .../guilds/editWelcomeScreen.ts | 4 +- .../helpers => helpers}/guilds/editWidget.ts | 4 +- .../guilds/getAuditLogs.ts | 5 +- .../guilds/getAvailableVoiceRegions.ts | 6 +- .../bot/helpers => helpers}/guilds/getBan.ts | 4 +- .../bot/helpers => helpers}/guilds/getBans.ts | 6 +- .../helpers => helpers}/guilds/getGuild.ts | 4 +- .../guilds/getGuildPreview.ts | 4 +- .../guilds/getPruneCount.ts | 2 +- .../guilds/getVanityUrl.ts | 4 +- .../guilds/getVoiceRegions.ts | 6 +- .../guilds/getWelcomeScreen.ts | 4 +- .../helpers => helpers}/guilds/getWidget.ts | 4 +- .../guilds/getWidgetImageUrl.ts | 2 +- .../guilds/getWidgetSettings.ts | 4 +- .../guilds/guildBannerUrl.ts | 2 +- .../guilds/guildIconUrl.ts | 2 +- .../guilds/guildSplashUrl.ts | 2 +- .../helpers => helpers}/guilds/leaveGuild.ts | 2 +- .../bot/helpers => helpers}/guilds/mod.ts | 0 .../scheduledEvents/createScheduledEvent.ts | 3 +- .../scheduledEvents/deleteScheduledEvent.ts | 0 .../scheduledEvents/editScheduledEvent.ts | 8 +- .../scheduledEvents/getScheduledEvent.ts | 2 +- .../scheduledEvents/getScheduledEventUsers.ts | 4 +- .../scheduledEvents/getScheduledEvents.ts | 4 +- .../guilds/scheduledEvents/mod.ts | 0 .../integrations/deleteIntegration.ts | 2 +- .../integrations/getIntegrations.ts | 6 +- .../helpers => helpers}/integrations/mod.ts | 0 .../commands/createApplicationCommand.ts | 14 +- .../commands/deleteApplicationCommand.ts | 2 +- .../commands/deleteInteractionResponse.ts | 2 +- .../editApplicationCommandPermissions.ts | 5 +- .../commands/editInteractionResponse.ts | 4 +- .../commands/getApplicationCommand.ts | 4 +- .../getApplicationCommandPermission.ts | 4 +- .../getApplicationCommandPermissions.ts | 6 +- .../commands/getApplicationCommands.ts | 6 +- .../interactions/commands/mod.ts | 0 .../commands/upsertApplicationCommand.ts | 5 +- .../commands/upsertApplicationCommands.ts | 7 +- .../followups/deleteFollowupMessage.ts | 0 .../followups/editFollowupMessage.ts | 3 +- .../followups/getFollowupMessage.ts | 2 +- .../interactions/followups/mod.ts | 0 .../getOriginalInteractionResponse.ts | 4 +- .../helpers => helpers}/interactions/mod.ts | 0 .../interactions/sendInteractionResponse.ts | 9 +- .../interactions/verifySignature.ts | 0 .../invites/createInvite.ts | 5 +- .../invites/deleteInvite.ts | 4 +- .../invites/getChannelInvites.ts | 6 +- .../helpers => helpers}/invites/getInvite.ts | 4 +- .../helpers => helpers}/invites/getInvites.ts | 6 +- .../bot/helpers => helpers}/invites/mod.ts | 0 .../helpers => helpers}/members/avatarUrl.ts | 2 +- .../helpers => helpers}/members/banMember.ts | 2 +- .../members/editBotNickname.ts | 2 +- .../helpers => helpers}/members/editMember.ts | 4 +- .../members/fetchMembers.ts | 4 +- .../members/getDmChannel.ts | 4 +- .../helpers => helpers}/members/getMember.ts | 4 +- .../helpers => helpers}/members/getMembers.ts | 6 +- .../helpers => helpers}/members/kickMember.ts | 0 .../bot/helpers => helpers}/members/mod.ts | 0 .../members/pruneMembers.ts | 2 +- .../members/searchMembers.ts | 6 +- .../members/unbanMember.ts | 2 +- .../messages/addReaction.ts | 2 +- .../messages/addReactions.ts | 2 +- .../messages/deleteMessage.ts | 2 +- .../messages/deleteMessages.ts | 2 +- .../messages/editMessage.ts | 7 +- .../messages/getMessage.ts | 4 +- .../messages/getMessages.ts | 6 +- .../messages/getReactions.ts | 6 +- .../bot/helpers => helpers}/messages/mod.ts | 0 .../messages/pinMessage.ts | 2 +- .../messages/publishMessage.ts | 4 +- .../messages/removeAllReactions.ts | 2 +- .../messages/removeReaction.ts | 2 +- .../messages/removeReactionEmoji.ts | 2 +- .../messages/sendMessage.ts | 7 +- .../messages/unpinMessage.ts | 2 +- .../misc/editBotProfile.ts | 4 +- .../helpers => helpers}/misc/editBotStatus.ts | 0 .../misc/editShardStatus.ts | 4 +- .../helpers => helpers}/misc/getGatewayBot.ts | 4 +- .../bot/helpers => helpers}/misc/getUser.ts | 4 +- {plugins/bot/helpers => helpers}/misc/mod.ts | 0 .../misc/nitroStickerPacks.ts | 2 +- {plugins/bot/helpers => helpers}/mod.ts | 0 .../oauth/getApplicationInfo.ts | 4 +- {plugins/bot/helpers => helpers}/oauth/mod.ts | 0 .../bot/helpers => helpers}/roles/addRole.ts | 2 +- .../helpers => helpers}/roles/createRole.ts | 5 +- .../helpers => helpers}/roles/deleteRole.ts | 2 +- .../bot/helpers => helpers}/roles/editRole.ts | 5 +- .../bot/helpers => helpers}/roles/getRoles.ts | 6 +- {plugins/bot/helpers => helpers}/roles/mod.ts | 0 .../roles/modifyRolePositions.ts | 4 +- .../helpers => helpers}/roles/removeRole.ts | 2 +- .../templates/createGuildFromTemplate.ts | 4 +- .../templates/createGuildTemplate.ts | 4 +- .../templates/deleteGuildTemplate.ts | 4 +- .../templates/editGuildTemplate.ts | 4 +- .../templates/getGuildTemplates.ts | 6 +- .../templates/getTemplate.ts | 4 +- .../bot/helpers => helpers}/templates/mod.ts | 0 .../templates/syncGuildTemplate.ts | 4 +- .../voice/connectToVoiceChannel.ts | 4 +- {plugins/bot/helpers => helpers}/voice/mod.ts | 0 .../webhooks/createWebhook.ts | 4 +- .../webhooks/deleteWebhook.ts | 2 +- .../webhooks/deleteWebhookMessage.ts | 2 +- .../webhooks/deleteWebhookWithToken.ts | 2 +- .../webhooks/editWebhook.ts | 4 +- .../webhooks/editWebhookMessage.ts | 7 +- .../webhooks/editWebhookWithToken.ts | 4 +- .../webhooks/getWebhook.ts | 4 +- .../webhooks/getWebhookMessage.ts | 4 +- .../webhooks/getWebhookWithToken.ts | 4 +- .../webhooks/getWebhooks.ts | 6 +- .../bot/helpers => helpers}/webhooks/mod.ts | 0 .../webhooks/sendWebhook.ts | 6 +- mod.ts | 5 + plugins/bot/deps.ts | 1 - plugins/bot/mod.ts | 8 - plugins/bot/util/collection.ts | 149 ------------- plugins/bot/util/mod.ts | 8 - rest/createRequestBody.ts | 2 +- rest/runMethod.ts | 6 +- template/bigbot/src/bot/types/command.ts | 84 ++++---- tests/channels/deleteWithReason.test.ts | 7 +- tests/channels/deleteWithoutReason.test.ts | 7 +- tests/channels/messages/message.test.ts | 20 +- tests/guilds/events/events.test.ts | 7 +- tests/guilds/guild.test.ts | 25 +-- tests/guilds/members/bans.test.ts | 6 +- tests/mod.ts | 2 +- tests/rest.ts | 3 +- tests/utils.test.ts | 13 +- tests/webhook/deleteWebhook.test.ts | 8 +- tests/webhook/deleteWebhookWithToken.test.ts | 8 +- .../transformers => transformers}/activity.ts | 3 +- .../application.ts | 3 +- .../applicationCommand.ts | 3 +- .../applicationCommandOption.ts | 4 +- .../applicationCommandOptionChoice.ts | 3 +- .../applicationCommandPermission.ts | 3 +- .../attachment.ts | 3 +- .../auditLogEntry.ts | 3 +- .../automodActionExecution.ts | 3 +- .../automodRule.ts | 3 +- .../transformers => transformers}/channel.ts | 3 +- .../component.ts | 4 +- .../transformers => transformers}/embed.ts | 3 +- .../transformers => transformers}/emoji.ts | 3 +- .../gatewayBot.ts | 3 +- .../transformers => transformers}/guild.ts | 5 +- .../integration.ts | 3 +- .../interaction.ts | 8 +- .../transformers => transformers}/invite.ts | 3 +- .../transformers => transformers}/member.ts | 5 +- .../transformers => transformers}/message.ts | 4 +- .../bot/transformers => transformers}/mod.ts | 0 .../transformers => transformers}/presence.ts | 3 +- .../reverse/activity.ts | 2 +- .../reverse/allowedMentions.ts | 4 +- .../reverse/application.ts | 2 +- .../reverse/component.ts | 2 +- .../reverse/embed.ts | 2 +- .../reverse/member.ts | 4 +- .../reverse/mod.ts | 0 .../reverse/team.ts | 2 +- .../bot/transformers => transformers}/role.ts | 3 +- .../scheduledEvent.ts | 3 +- .../stageInstance.ts | 3 +- .../transformers => transformers}/sticker.ts | 3 +- .../bot/transformers => transformers}/team.ts | 3 +- .../transformers => transformers}/template.ts | 3 +- .../threadMember.ts | 3 +- .../toggles/ToggleBitfield.ts | 0 .../toggles/emoji.ts | 2 +- .../toggles/guild.ts | 5 +- .../toggles/member.ts | 2 +- .../toggles/mod.ts | 0 .../toggles/role.ts | 2 +- .../toggles/user.ts | 2 +- .../toggles/voice.ts | 2 +- .../voiceRegion.ts | 3 +- .../voiceState.ts | 3 +- .../transformers => transformers}/webhook.ts | 3 +- .../welcomeScreen.ts | 3 +- .../transformers => transformers}/widget.ts | 3 +- .../widgetSettings.ts | 3 +- types/discord.ts | 7 - plugins/bot/typings.ts => types/discordeno.ts | 9 +- types/mod.ts | 1 + types/shared.ts | 35 +-- {plugins/bot/util => util}/bigint.ts | 0 util/bucket.ts | 2 +- {gateway => util}/calculateShardId.ts | 2 +- util/collection.ts | 49 +++++ util/delay.ts | 8 - {plugins/bot/util => util}/hash.ts | 0 util/mod.ts | 8 +- {plugins/bot/util => util}/permissions.ts | 2 +- {plugins/bot/util => util}/routes.ts | 2 +- {plugins/bot/util => util}/urlToBase64.ts | 0 {plugins/bot/util => util}/utils.ts | 9 + {plugins/bot/util => util}/validateLength.ts | 0 346 files changed, 786 insertions(+), 856 deletions(-) rename plugins/bot/bot.ts => bot.ts (90%) rename {plugins/bot/handlers => handlers}/channels/CHANNEL_CREATE.ts (64%) rename {plugins/bot/handlers => handlers}/channels/CHANNEL_DELETE.ts (75%) rename {plugins/bot/handlers => handlers}/channels/CHANNEL_PINS_UPDATE.ts (88%) rename {plugins/bot/handlers => handlers}/channels/CHANNEL_UPDATE.ts (66%) rename {plugins/bot/handlers => handlers}/channels/STAGE_INSTANCE_CREATE.ts (87%) rename {plugins/bot/handlers => handlers}/channels/STAGE_INSTANCE_DELETE.ts (87%) rename {plugins/bot/handlers => handlers}/channels/STAGE_INSTANCE_UPDATE.ts (87%) rename {plugins/bot/handlers => handlers}/channels/THREAD_CREATE.ts (75%) rename {plugins/bot/handlers => handlers}/channels/THREAD_DELETE.ts (75%) rename {plugins/bot/handlers => handlers}/channels/THREAD_LIST_SYNC.ts (97%) rename {plugins/bot/handlers => handlers}/channels/THREAD_MEMBERS_UPDATE.ts (95%) rename {plugins/bot/handlers => handlers}/channels/THREAD_MEMBER_UPDATE.ts (94%) rename {plugins/bot/handlers => handlers}/channels/THREAD_UPDATE.ts (75%) rename {plugins/bot/handlers => handlers}/channels/mod.ts (100%) rename {plugins/bot/handlers => handlers}/emojis/GUILD_EMOJIS_UPDATE.ts (77%) rename {plugins/bot/handlers => handlers}/emojis/mod.ts (100%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_BAN_ADD.ts (82%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_BAN_REMOVE.ts (83%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_CREATE.ts (71%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_DELETE.ts (81%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_INTEGRATIONS_UPDATE.ts (81%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_LOADED_DD.ts (72%) rename {plugins/bot/handlers => handlers}/guilds/GUILD_UPDATE.ts (71%) rename {plugins/bot/handlers => handlers}/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts (81%) rename {plugins/bot/handlers => handlers}/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts (82%) rename {plugins/bot/handlers => handlers}/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts (82%) rename {plugins/bot/handlers => handlers}/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts (82%) rename {plugins/bot/handlers => handlers}/guilds/automod/mod.ts (100%) rename {plugins/bot/handlers => handlers}/guilds/mod.ts (100%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts (81%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts (80%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts (80%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts (86%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts (85%) rename {plugins/bot/handlers => handlers}/guilds/scheduledEvents/mod.ts (100%) rename {plugins/bot/handlers => handlers}/integrations/INTEGRATION_CREATE.ts (90%) rename {plugins/bot/handlers => handlers}/integrations/INTEGRATION_DELETE.ts (95%) rename {plugins/bot/handlers => handlers}/integrations/INTEGRATION_UPDATE.ts (90%) rename {plugins/bot/handlers => handlers}/integrations/mod.ts (100%) rename {plugins/bot/handlers => handlers}/interactions/INTERACTION_CREATE.ts (95%) rename {plugins/bot/handlers => handlers}/interactions/mod.ts (100%) rename {plugins/bot/handlers => handlers}/invites/INVITE_CREATE.ts (92%) rename {plugins/bot/handlers => handlers}/invites/INVITE_DELETE.ts (96%) rename {plugins/bot/handlers => handlers}/invites/mod.ts (100%) rename {plugins/bot/handlers => handlers}/members/GUILD_MEMBERS_CHUNK.ts (98%) rename {plugins/bot/handlers => handlers}/members/GUILD_MEMBER_ADD.ts (95%) rename {plugins/bot/handlers => handlers}/members/GUILD_MEMBER_REMOVE.ts (94%) rename {plugins/bot/handlers => handlers}/members/GUILD_MEMBER_UPDATE.ts (94%) rename {plugins/bot/handlers => handlers}/members/mod.ts (100%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_CREATE.ts (75%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_DELETE.ts (95%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_DELETE_BULK.ts (96%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_REACTION_ADD.ts (96%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_REACTION_REMOVE.ts (95%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_REACTION_REMOVE_ALL.ts (94%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts (94%) rename {plugins/bot/handlers => handlers}/messages/MESSAGE_UPDATE.ts (77%) rename {plugins/bot/handlers => handlers}/messages/mod.ts (100%) rename {plugins/bot/handlers => handlers}/misc/PRESENCE_UPDATE.ts (92%) rename {plugins/bot/handlers => handlers}/misc/READY.ts (90%) rename {plugins/bot/handlers => handlers}/misc/TYPING_START.ts (97%) rename {plugins/bot/handlers => handlers}/misc/USER_UPDATE.ts (74%) rename {plugins/bot/handlers => handlers}/misc/mod.ts (100%) rename {plugins/bot/handlers => handlers}/mod.ts (100%) rename {plugins/bot/handlers => handlers}/roles/GUILD_ROLE_CREATE.ts (94%) rename {plugins/bot/handlers => handlers}/roles/GUILD_ROLE_DELETE.ts (94%) rename {plugins/bot/handlers => handlers}/roles/GUILD_ROLE_UPDATE.ts (94%) rename {plugins/bot/handlers => handlers}/roles/mod.ts (100%) rename {plugins/bot/handlers => handlers}/voice/VOICE_SERVER_UPDATE.ts (94%) rename {plugins/bot/handlers => handlers}/voice/VOICE_STATE_UPDATE.ts (95%) rename {plugins/bot/handlers => handlers}/voice/mod.ts (100%) rename {plugins/bot/handlers => handlers}/webhooks/WEBHOOKS_UPDATE.ts (94%) rename {plugins/bot/handlers => handlers}/webhooks/mod.ts (100%) rename {plugins/bot/helpers => helpers}/channels/createChannel.ts (94%) rename {plugins/bot/helpers => helpers}/channels/createStageInstance.ts (88%) rename {plugins/bot/helpers => helpers}/channels/deleteChannel.ts (80%) rename {plugins/bot/helpers => helpers}/channels/deleteChannelOverwrite.ts (89%) rename {plugins/bot/helpers => helpers}/channels/deleteStageInstance.ts (86%) rename {plugins/bot/helpers => helpers}/channels/editChannel.ts (97%) rename {plugins/bot/helpers => helpers}/channels/editChannelOverwrite.ts (90%) rename {plugins/bot/helpers => helpers}/channels/followChannel.ts (83%) rename {plugins/bot/helpers => helpers}/channels/forums/createForumPost.ts (92%) rename {plugins/bot/helpers => helpers}/channels/forums/mod.ts (100%) rename {plugins/bot/helpers => helpers}/channels/getChannel.ts (83%) rename {plugins/bot/helpers => helpers}/channels/getChannelWebhooks.ts (73%) rename {plugins/bot/helpers => helpers}/channels/getChannels.ts (71%) rename {plugins/bot/helpers => helpers}/channels/getPins.ts (76%) rename {plugins/bot/helpers => helpers}/channels/getStageInstance.ts (77%) rename {plugins/bot/helpers => helpers}/channels/mod.ts (100%) rename {plugins/bot/helpers => helpers}/channels/startTyping.ts (92%) rename {plugins/bot/helpers => helpers}/channels/swapChannels.ts (96%) rename {plugins/bot/helpers => helpers}/channels/threads/addToThread.ts (87%) rename {plugins/bot/helpers => helpers}/channels/threads/getActiveThreads.ts (80%) rename {plugins/bot/helpers => helpers}/channels/threads/getArchivedThreads.ts (88%) rename {plugins/bot/helpers => helpers}/channels/threads/getThreadMember.ts (83%) rename {plugins/bot/helpers => helpers}/channels/threads/getThreadMembers.ts (72%) rename {plugins/bot/helpers => helpers}/channels/threads/joinThread.ts (84%) rename {plugins/bot/helpers => helpers}/channels/threads/leaveThread.ts (84%) rename {plugins/bot/helpers => helpers}/channels/threads/mod.ts (100%) rename {plugins/bot/helpers => helpers}/channels/threads/removeThreadMember.ts (89%) rename {plugins/bot/helpers => helpers}/channels/threads/startThreadWithMessage.ts (90%) rename {plugins/bot/helpers => helpers}/channels/threads/startThreadWithoutMessage.ts (88%) rename {plugins/bot/helpers => helpers}/channels/updateStageInstance.ts (75%) rename {plugins/bot/helpers => helpers}/channels/updateVoiceState.ts (98%) rename {plugins/bot/helpers => helpers}/discovery/addDiscoverySubcategory.ts (74%) rename {plugins/bot/helpers => helpers}/discovery/editDiscovery.ts (93%) rename {plugins/bot/helpers => helpers}/discovery/getDiscovery.ts (88%) rename {plugins/bot/helpers => helpers}/discovery/getDiscoveryCategories.ts (74%) rename {plugins/bot/helpers => helpers}/discovery/mod.ts (100%) rename {plugins/bot/helpers => helpers}/discovery/removeDiscoverySubcategory.ts (90%) rename {plugins/bot/helpers => helpers}/discovery/validDiscoveryTerm.ts (68%) rename {plugins/bot/helpers => helpers}/emojis/createEmoji.ts (92%) rename {plugins/bot/helpers => helpers}/emojis/deleteEmoji.ts (88%) rename {plugins/bot/helpers => helpers}/emojis/editEmoji.ts (88%) rename {plugins/bot/helpers => helpers}/emojis/emojiUrl.ts (100%) rename {plugins/bot/helpers => helpers}/emojis/getEmoji.ts (77%) rename {plugins/bot/helpers => helpers}/emojis/getEmojis.ts (70%) rename {plugins/bot/helpers => helpers}/emojis/mod.ts (100%) rename {plugins/bot/helpers => helpers}/guilds/automod/createAutomodRule.ts (98%) rename {plugins/bot/helpers => helpers}/guilds/automod/deleteAutomodRule.ts (100%) rename {plugins/bot/helpers => helpers}/guilds/automod/editAutomodRule.ts (98%) rename {plugins/bot/helpers => helpers}/guilds/automod/getAutomodRule.ts (73%) rename {plugins/bot/helpers => helpers}/guilds/automod/getAutomodRules.ts (76%) rename {plugins/bot/helpers => helpers}/guilds/automod/mod.ts (100%) rename {plugins/bot/helpers => helpers}/guilds/createGuild.ts (94%) rename {plugins/bot/helpers => helpers}/guilds/deleteGuild.ts (87%) rename {plugins/bot/helpers => helpers}/guilds/editGuild.ts (96%) rename {plugins/bot/helpers => helpers}/guilds/editWelcomeScreen.ts (93%) rename {plugins/bot/helpers => helpers}/guilds/editWidget.ts (80%) rename {plugins/bot/helpers => helpers}/guilds/getAuditLogs.ts (94%) rename {plugins/bot/helpers => helpers}/guilds/getAvailableVoiceRegions.ts (74%) rename {plugins/bot/helpers => helpers}/guilds/getBan.ts (83%) rename {plugins/bot/helpers => helpers}/guilds/getBans.ts (85%) rename {plugins/bot/helpers => helpers}/guilds/getGuild.ts (87%) rename {plugins/bot/helpers => helpers}/guilds/getGuildPreview.ts (90%) rename {plugins/bot/helpers => helpers}/guilds/getPruneCount.ts (95%) rename {plugins/bot/helpers => helpers}/guilds/getVanityUrl.ts (80%) rename {plugins/bot/helpers => helpers}/guilds/getVoiceRegions.ts (76%) rename {plugins/bot/helpers => helpers}/guilds/getWelcomeScreen.ts (78%) rename {plugins/bot/helpers => helpers}/guilds/getWidget.ts (74%) rename {plugins/bot/helpers => helpers}/guilds/getWidgetImageUrl.ts (96%) rename {plugins/bot/helpers => helpers}/guilds/getWidgetSettings.ts (76%) rename {plugins/bot/helpers => helpers}/guilds/guildBannerUrl.ts (93%) rename {plugins/bot/helpers => helpers}/guilds/guildIconUrl.ts (93%) rename {plugins/bot/helpers => helpers}/guilds/guildSplashUrl.ts (93%) rename {plugins/bot/helpers => helpers}/guilds/leaveGuild.ts (82%) rename {plugins/bot/helpers => helpers}/guilds/mod.ts (100%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/createScheduledEvent.ts (94%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/deleteScheduledEvent.ts (100%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/editScheduledEvent.ts (93%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/getScheduledEvent.ts (87%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/getScheduledEventUsers.ts (94%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/getScheduledEvents.ts (85%) rename {plugins/bot/helpers => helpers}/guilds/scheduledEvents/mod.ts (100%) rename {plugins/bot/helpers => helpers}/integrations/deleteIntegration.ts (88%) rename {plugins/bot/helpers => helpers}/integrations/getIntegrations.ts (86%) rename {plugins/bot/helpers => helpers}/integrations/mod.ts (100%) rename {plugins/bot/helpers => helpers}/interactions/commands/createApplicationCommand.ts (93%) rename {plugins/bot/helpers => helpers}/interactions/commands/deleteApplicationCommand.ts (89%) rename {plugins/bot/helpers => helpers}/interactions/commands/deleteInteractionResponse.ts (92%) rename {plugins/bot/helpers => helpers}/interactions/commands/editApplicationCommandPermissions.ts (84%) rename {plugins/bot/helpers => helpers}/interactions/commands/editInteractionResponse.ts (97%) rename {plugins/bot/helpers => helpers}/interactions/commands/getApplicationCommand.ts (91%) rename {plugins/bot/helpers => helpers}/interactions/commands/getApplicationCommandPermission.ts (89%) rename {plugins/bot/helpers => helpers}/interactions/commands/getApplicationCommandPermissions.ts (83%) rename {plugins/bot/helpers => helpers}/interactions/commands/getApplicationCommands.ts (77%) rename {plugins/bot/helpers => helpers}/interactions/commands/mod.ts (100%) rename {plugins/bot/helpers => helpers}/interactions/commands/upsertApplicationCommand.ts (86%) rename {plugins/bot/helpers => helpers}/interactions/commands/upsertApplicationCommands.ts (86%) rename {plugins/bot/helpers => helpers}/interactions/followups/deleteFollowupMessage.ts (100%) rename {plugins/bot/helpers => helpers}/interactions/followups/editFollowupMessage.ts (96%) rename {plugins/bot/helpers => helpers}/interactions/followups/getFollowupMessage.ts (90%) rename {plugins/bot/helpers => helpers}/interactions/followups/mod.ts (100%) rename {plugins/bot/helpers => helpers}/interactions/getOriginalInteractionResponse.ts (80%) rename {plugins/bot/helpers => helpers}/interactions/mod.ts (100%) rename {plugins/bot/helpers => helpers}/interactions/sendInteractionResponse.ts (92%) rename {plugins/bot/helpers => helpers}/interactions/verifySignature.ts (100%) rename {plugins/bot/helpers => helpers}/invites/createInvite.ts (93%) rename {plugins/bot/helpers => helpers}/invites/deleteInvite.ts (72%) rename {plugins/bot/helpers => helpers}/invites/getChannelInvites.ts (77%) rename {plugins/bot/helpers => helpers}/invites/getInvite.ts (93%) rename {plugins/bot/helpers => helpers}/invites/getInvites.ts (77%) rename {plugins/bot/helpers => helpers}/invites/mod.ts (100%) rename {plugins/bot/helpers => helpers}/members/avatarUrl.ts (95%) rename {plugins/bot/helpers => helpers}/members/banMember.ts (94%) rename {plugins/bot/helpers => helpers}/members/editBotNickname.ts (90%) rename {plugins/bot/helpers => helpers}/members/editMember.ts (94%) rename {plugins/bot/helpers => helpers}/members/fetchMembers.ts (95%) rename {plugins/bot/helpers => helpers}/members/getDmChannel.ts (83%) rename {plugins/bot/helpers => helpers}/members/getMember.ts (78%) rename {plugins/bot/helpers => helpers}/members/getMembers.ts (86%) rename {plugins/bot/helpers => helpers}/members/kickMember.ts (100%) rename {plugins/bot/helpers => helpers}/members/mod.ts (100%) rename {plugins/bot/helpers => helpers}/members/pruneMembers.ts (97%) rename {plugins/bot/helpers => helpers}/members/searchMembers.ts (81%) rename {plugins/bot/helpers => helpers}/members/unbanMember.ts (85%) rename {plugins/bot/helpers => helpers}/messages/addReaction.ts (94%) rename {plugins/bot/helpers => helpers}/messages/addReactions.ts (94%) rename {plugins/bot/helpers => helpers}/messages/deleteMessage.ts (91%) rename {plugins/bot/helpers => helpers}/messages/deleteMessages.ts (93%) rename {plugins/bot/helpers => helpers}/messages/editMessage.ts (94%) rename {plugins/bot/helpers => helpers}/messages/getMessage.ts (81%) rename {plugins/bot/helpers => helpers}/messages/getMessages.ts (93%) rename {plugins/bot/helpers => helpers}/messages/getReactions.ts (86%) rename {plugins/bot/helpers => helpers}/messages/mod.ts (100%) rename {plugins/bot/helpers => helpers}/messages/pinMessage.ts (87%) rename {plugins/bot/helpers => helpers}/messages/publishMessage.ts (78%) rename {plugins/bot/helpers => helpers}/messages/removeAllReactions.ts (88%) rename {plugins/bot/helpers => helpers}/messages/removeReaction.ts (95%) rename {plugins/bot/helpers => helpers}/messages/removeReactionEmoji.ts (93%) rename {plugins/bot/helpers => helpers}/messages/sendMessage.ts (94%) rename {plugins/bot/helpers => helpers}/messages/unpinMessage.ts (86%) rename {plugins/bot/helpers => helpers}/misc/editBotProfile.ts (85%) rename {plugins/bot/helpers => helpers}/misc/editBotStatus.ts (100%) rename {plugins/bot/helpers => helpers}/misc/editShardStatus.ts (96%) rename {plugins/bot/helpers => helpers}/misc/getGatewayBot.ts (75%) rename {plugins/bot/helpers => helpers}/misc/getUser.ts (79%) rename {plugins/bot/helpers => helpers}/misc/mod.ts (100%) rename {plugins/bot/helpers => helpers}/misc/nitroStickerPacks.ts (86%) rename {plugins/bot/helpers => helpers}/mod.ts (100%) rename {plugins/bot/helpers => helpers}/oauth/getApplicationInfo.ts (73%) rename {plugins/bot/helpers => helpers}/oauth/mod.ts (100%) rename {plugins/bot/helpers => helpers}/roles/addRole.ts (88%) rename {plugins/bot/helpers => helpers}/roles/createRole.ts (89%) rename {plugins/bot/helpers => helpers}/roles/deleteRole.ts (85%) rename {plugins/bot/helpers => helpers}/roles/editRole.ts (88%) rename {plugins/bot/helpers => helpers}/roles/getRoles.ts (78%) rename {plugins/bot/helpers => helpers}/roles/mod.ts (100%) rename {plugins/bot/helpers => helpers}/roles/modifyRolePositions.ts (87%) rename {plugins/bot/helpers => helpers}/roles/removeRole.ts (88%) rename {plugins/bot/helpers => helpers}/templates/createGuildFromTemplate.ts (90%) rename {plugins/bot/helpers => helpers}/templates/createGuildTemplate.ts (88%) rename {plugins/bot/helpers => helpers}/templates/deleteGuildTemplate.ts (76%) rename {plugins/bot/helpers => helpers}/templates/editGuildTemplate.ts (91%) rename {plugins/bot/helpers => helpers}/templates/getGuildTemplates.ts (72%) rename {plugins/bot/helpers => helpers}/templates/getTemplate.ts (75%) rename {plugins/bot/helpers => helpers}/templates/mod.ts (100%) rename {plugins/bot/helpers => helpers}/templates/syncGuildTemplate.ts (77%) rename {plugins/bot/helpers => helpers}/voice/connectToVoiceChannel.ts (91%) rename {plugins/bot/helpers => helpers}/voice/mod.ts (100%) rename {plugins/bot/helpers => helpers}/webhooks/createWebhook.ts (91%) rename {plugins/bot/helpers => helpers}/webhooks/deleteWebhook.ts (88%) rename {plugins/bot/helpers => helpers}/webhooks/deleteWebhookMessage.ts (91%) rename {plugins/bot/helpers => helpers}/webhooks/deleteWebhookWithToken.ts (87%) rename {plugins/bot/helpers => helpers}/webhooks/editWebhook.ts (89%) rename {plugins/bot/helpers => helpers}/webhooks/editWebhookMessage.ts (94%) rename {plugins/bot/helpers => helpers}/webhooks/editWebhookWithToken.ts (84%) rename {plugins/bot/helpers => helpers}/webhooks/getWebhook.ts (77%) rename {plugins/bot/helpers => helpers}/webhooks/getWebhookMessage.ts (85%) rename {plugins/bot/helpers => helpers}/webhooks/getWebhookWithToken.ts (81%) rename {plugins/bot/helpers => helpers}/webhooks/getWebhooks.ts (73%) rename {plugins/bot/helpers => helpers}/webhooks/mod.ts (100%) rename {plugins/bot/helpers => helpers}/webhooks/sendWebhook.ts (92%) delete mode 100644 plugins/bot/deps.ts delete mode 100644 plugins/bot/mod.ts delete mode 100644 plugins/bot/util/collection.ts delete mode 100644 plugins/bot/util/mod.ts rename {plugins/bot/transformers => transformers}/activity.ts (92%) rename {plugins/bot/transformers => transformers}/application.ts (91%) rename {plugins/bot/transformers => transformers}/applicationCommand.ts (90%) rename {plugins/bot/transformers => transformers}/applicationCommandOption.ts (89%) rename {plugins/bot/transformers => transformers}/applicationCommandOptionChoice.ts (77%) rename {plugins/bot/transformers => transformers}/applicationCommandPermission.ts (85%) rename {plugins/bot/transformers => transformers}/attachment.ts (84%) rename {plugins/bot/transformers => transformers}/auditLogEntry.ts (97%) rename {plugins/bot/transformers => transformers}/automodActionExecution.ts (91%) rename {plugins/bot/transformers => transformers}/automodRule.ts (91%) rename {plugins/bot/transformers => transformers}/channel.ts (97%) rename {plugins/bot/transformers => transformers}/component.ts (94%) rename {plugins/bot/transformers => transformers}/embed.ts (93%) rename {plugins/bot/transformers => transformers}/emoji.ts (85%) rename {plugins/bot/transformers => transformers}/gatewayBot.ts (83%) rename {plugins/bot/transformers => transformers}/guild.ts (96%) rename {plugins/bot/transformers => transformers}/integration.ts (92%) rename {plugins/bot/transformers => transformers}/interaction.ts (96%) rename {plugins/bot/transformers => transformers}/invite.ts (94%) rename {plugins/bot/transformers => transformers}/member.ts (91%) rename {plugins/bot/transformers => transformers}/message.ts (96%) rename {plugins/bot/transformers => transformers}/mod.ts (100%) rename {plugins/bot/transformers => transformers}/presence.ts (92%) rename {plugins/bot/transformers => transformers}/reverse/activity.ts (95%) rename {plugins/bot/transformers => transformers}/reverse/allowedMentions.ts (69%) rename {plugins/bot/transformers => transformers}/reverse/application.ts (94%) rename {plugins/bot/transformers => transformers}/reverse/component.ts (95%) rename {plugins/bot/transformers => transformers}/reverse/embed.ts (96%) rename {plugins/bot/transformers => transformers}/reverse/member.ts (93%) rename {plugins/bot/transformers => transformers}/reverse/mod.ts (100%) rename {plugins/bot/transformers => transformers}/reverse/team.ts (92%) rename {plugins/bot/transformers => transformers}/role.ts (90%) rename {plugins/bot/transformers => transformers}/scheduledEvent.ts (92%) rename {plugins/bot/transformers => transformers}/stageInstance.ts (85%) rename {plugins/bot/transformers => transformers}/sticker.ts (92%) rename {plugins/bot/transformers => transformers}/team.ts (87%) rename {plugins/bot/transformers => transformers}/template.ts (88%) rename {plugins/bot/transformers => transformers}/threadMember.ts (85%) rename {plugins/bot/transformers => transformers}/toggles/ToggleBitfield.ts (100%) rename {plugins/bot/transformers => transformers}/toggles/emoji.ts (96%) rename {plugins/bot/transformers => transformers}/toggles/guild.ts (98%) rename {plugins/bot/transformers => transformers}/toggles/member.ts (95%) rename {plugins/bot/transformers => transformers}/toggles/mod.ts (100%) rename {plugins/bot/transformers => transformers}/toggles/role.ts (97%) rename {plugins/bot/transformers => transformers}/toggles/user.ts (97%) rename {plugins/bot/transformers => transformers}/toggles/voice.ts (97%) rename {plugins/bot/transformers => transformers}/voiceRegion.ts (79%) rename {plugins/bot/transformers => transformers}/voiceState.ts (90%) rename {plugins/bot/transformers => transformers}/webhook.ts (93%) rename {plugins/bot/transformers => transformers}/welcomeScreen.ts (85%) rename {plugins/bot/transformers => transformers}/widget.ts (89%) rename {plugins/bot/transformers => transformers}/widgetSettings.ts (75%) rename plugins/bot/typings.ts => types/discordeno.ts (96%) rename {plugins/bot/util => util}/bigint.ts (100%) rename {gateway => util}/calculateShardId.ts (74%) delete mode 100644 util/delay.ts rename {plugins/bot/util => util}/hash.ts (100%) rename {plugins/bot/util => util}/permissions.ts (91%) rename {plugins/bot/util => util}/routes.ts (99%) rename {plugins/bot/util => util}/urlToBase64.ts (100%) rename {plugins/bot/util => util}/utils.ts (76%) rename {plugins/bot/util => util}/validateLength.ts (100%) diff --git a/plugins/bot/bot.ts b/bot.ts similarity index 90% rename from plugins/bot/bot.ts rename to bot.ts index 0af267aa0..ce19dd5f2 100644 --- a/plugins/bot/bot.ts +++ b/bot.ts @@ -1,32 +1,97 @@ -import * as handlers from "./handlers/mod.ts"; -import * as helpers from "./helpers/mod.ts"; -import { calculateShardId } from "../../gateway/calculateShardId.ts"; +import { createRestManager, CreateRestManagerOptions } from "./rest/mod.ts"; +import { bigintToSnowflake, snowflakeToBigint } from "./util/bigint.ts"; +import { Collection } from "./util/collection.ts"; +import { + Channel, + Guild, + Member, + Message, + Role, + ScheduledEvent, + Template, + transformChannel, + transformGuild, + transformMember, + transformMessage, + transformRole, + transformTemplate, + transformUser, + transformVoiceState, + User, + VoiceState, +} from "./transformers/mod.ts"; import { baseEndpoints, CHANNEL_MENTION_REGEX, CONTEXT_MENU_COMMANDS_NAME_REGEX, - createGatewayManager, - createRestManager, - CreateRestManagerOptions, - CreateShardManager, - delay, DISCORD_SNOWFLAKE_REGEX, - DiscordActivity, + DISCORDENO_VERSION, + SLASH_COMMANDS_NAME_REGEX, + USER_AGENT, +} from "./util/constants.ts"; +import { createGatewayManager, GatewayManager } from "./gateway/manager/gatewayManager.ts"; +import { validateLength } from "./util/validateLength.ts"; +import { delay, formatImageURL } from "./util/utils.ts"; +import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts"; +import { calculateShardId } from "./util/calculateShardId.ts"; +import * as handlers from "./handlers/mod.ts"; +import { + Interaction, + InteractionDataOption, + transformInteraction, + transformInteractionDataOption, +} from "./transformers/interaction.ts"; +import { Integration, transformIntegration } from "./transformers/integration.ts"; +import { transformApplication } from "./transformers/application.ts"; +import { transformTeam } from "./transformers/team.ts"; +import { Invite, transformInvite } from "./transformers/invite.ts"; +import * as helpers from "./helpers/mod.ts"; +import { Emoji, transformEmoji } from "./transformers/emoji.ts"; +import { transformActivity } from "./transformers/activity.ts"; +import { PresenceUpdate, transformPresence } from "./transformers/presence.ts"; +import { urlToBase64 } from "./util/urlToBase64.ts"; +import { transformAttachment } from "./transformers/attachment.ts"; +import { transformEmbed } from "./transformers/embed.ts"; +import { transformComponent } from "./transformers/component.ts"; +import { transformWebhook } from "./transformers/webhook.ts"; +import { transformAuditLogEntry } from "./transformers/auditLogEntry.ts"; +import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts"; +import { calculateBits, calculatePermissions } from "./util/permissions.ts"; +import { transformScheduledEvent } from "./transformers/scheduledEvent.ts"; +import { ThreadMember, transformThreadMember } from "./transformers/threadMember.ts"; +import { transformApplicationCommandOption } from "./transformers/applicationCommandOption.ts"; +import { transformApplicationCommand } from "./transformers/applicationCommand.ts"; +import { transformWelcomeScreen } from "./transformers/welcomeScreen.ts"; +import { transformVoiceRegion } from "./transformers/voiceRegion.ts"; +import { transformWidget } from "./transformers/widget.ts"; +import { transformWidgetSettings } from "./transformers/widgetSettings.ts"; +import { transformStageInstance } from "./transformers/stageInstance.ts"; +import { StickerPack, transformSticker, transformStickerPack } from "./transformers/sticker.ts"; +import { GetGatewayBot, transformGatewayBot } from "./transformers/gatewayBot.ts"; +import { DiscordAllowedMentions, + DiscordApplicationCommandOptionChoice, + DiscordAutoModerationActionExecution, + DiscordAutoModerationRule, + DiscordEmoji, + DiscordGatewayPayload, + DiscordInteractionDataOption, + DiscordReady, + DiscordStickerPack, + DiscordTemplate, +} from "./types/discord.ts"; +import { Errors, GatewayDispatchEventNames, GatewayIntents } from "./types/shared.ts"; + +import { + DiscordActivity, DiscordApplication, DiscordApplicationCommand, DiscordApplicationCommandOption, - DiscordApplicationCommandOptionChoice, DiscordAttachment, DiscordAuditLogEntry, - DiscordAutoModerationActionExecution, - DiscordAutoModerationRule, DiscordChannel, DiscordComponent, DiscordEmbed, - DiscordEmoji, - DISCORDENO_VERSION, - DiscordGatewayPayload, DiscordGetGatewayBot, DiscordGuild, DiscordGuildApplicationCommandPermissions, @@ -34,101 +99,60 @@ import { DiscordGuildWidgetSettings, DiscordIntegrationCreateUpdate, DiscordInteraction, - DiscordInteractionDataOption, DiscordInviteCreate, DiscordMember, DiscordMessage, DiscordPresenceUpdate, - DiscordReady, DiscordRole, DiscordScheduledEvent, DiscordStageInstance, DiscordSticker, - DiscordStickerPack, DiscordTeam, - DiscordTemplate, DiscordThreadMember, DiscordUser, DiscordVoiceRegion, DiscordVoiceState, DiscordWebhook, DiscordWelcomeScreen, - Errors, - GatewayDispatchEventNames, - GatewayIntents, - getBotIdFromToken, - removeTokenPrefix, - SLASH_COMMANDS_NAME_REGEX, - USER_AGENT, -} from "./deps.ts"; -import { Activity, transformActivity } from "./transformers/activity.ts"; -import { Application, transformApplication } from "./transformers/application.ts"; -import { ApplicationCommand, transformApplicationCommand } from "./transformers/applicationCommand.ts"; -import { - ApplicationCommandOption, - transformApplicationCommandOption, -} from "./transformers/applicationCommandOption.ts"; +} from "./types/discord.ts"; + +import { Application } from "./transformers/application.ts"; +import { Team } from "./transformers/team.ts"; +import { Activity } from "./transformers/activity.ts"; +import { Attachment } from "./transformers/attachment.ts"; +import { Embed } from "./transformers/embed.ts"; +import { Webhook } from "./transformers/webhook.ts"; +import { Component } from "./transformers/component.ts"; +import { ApplicationCommand } from "./transformers/applicationCommand.ts"; +import { AuditLogEntry } from "./transformers/auditLogEntry.ts"; +import { ApplicationCommandOption } from "./transformers/applicationCommandOption.ts"; +import { ApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts"; +import { WelcomeScreen } from "./transformers/welcomeScreen.ts"; +import { VoiceRegions } from "./transformers/voiceRegion.ts"; +import { GuildWidget } from "./transformers/widget.ts"; +import { GuildWidgetSettings } from "./transformers/widgetSettings.ts"; +import { StageInstance } from "./transformers/stageInstance.ts"; +import { Sticker } from "./transformers/sticker.ts"; import { ApplicationCommandOptionChoice, transformApplicationCommandOptionChoice, } from "./transformers/applicationCommandOptionChoice.ts"; -import { - ApplicationCommandPermission, - transformApplicationCommandPermission, -} from "./transformers/applicationCommandPermission.ts"; -import { Attachment, transformAttachment } from "./transformers/attachment.ts"; -import { AuditLogEntry, transformAuditLogEntry } from "./transformers/auditLogEntry.ts"; +import { transformEmbedToDiscordEmbed } from "./transformers/reverse/embed.ts"; +import { transformComponentToDiscordComponent } from "./transformers/reverse/component.ts"; +import { transformActivityToDiscordActivity } from "./transformers/reverse/activity.ts"; +import { transformTeamToDiscordTeam } from "./transformers/reverse/team.ts"; +import { transformMemberToDiscordMember, transformUserToDiscordUser } from "./transformers/reverse/member.ts"; +import { transformApplicationToDiscordApplication } from "./transformers/reverse/application.ts"; +import { getBotIdFromToken, removeTokenPrefix } from "./util/token.ts"; +import { CreateShardManager } from "./gateway/manager/shardManager.ts"; +import { AutoModerationRule, transformAutoModerationRule } from "./transformers/automodRule.ts"; import { AutoModerationActionExecution, transformAutoModerationActionExecution, } from "./transformers/automodActionExecution.ts"; -import { AutoModerationRule, transformAutoModerationRule } from "./transformers/automodRule.ts"; -import { Channel, transformChannel } from "./transformers/channel.ts"; -import { Component, transformComponent } from "./transformers/component.ts"; -import { Embed, transformEmbed } from "./transformers/embed.ts"; -import { Emoji, transformEmoji } from "./transformers/emoji.ts"; -import { GetGatewayBot, transformGatewayBot } from "./transformers/gatewayBot.ts"; -import { Guild, transformGuild } from "./transformers/guild.ts"; -import { Integration, transformIntegration } from "./transformers/integration.ts"; -import { - Interaction, - InteractionDataOption, - transformInteraction, - transformInteractionDataOption, -} from "./transformers/interaction.ts"; -import { Invite, transformInvite } from "./transformers/invite.ts"; -import { Member, transformMember, transformUser, User } from "./transformers/member.ts"; -import { Message, transformMessage } from "./transformers/message.ts"; -import { PresenceUpdate, transformPresence } from "./transformers/presence.ts"; -import { transformActivityToDiscordActivity } from "./transformers/reverse/activity.ts"; -import { transformAllowedMentionsToDiscordAllowedMentions } from "./transformers/reverse/allowedMentions.ts"; -import { transformApplicationToDiscordApplication } from "./transformers/reverse/application.ts"; -import { transformComponentToDiscordComponent } from "./transformers/reverse/component.ts"; -import { transformEmbedToDiscordEmbed } from "./transformers/reverse/embed.ts"; -import { transformMemberToDiscordMember, transformUserToDiscordUser } from "./transformers/reverse/member.ts"; -import { transformTeamToDiscordTeam } from "./transformers/reverse/team.ts"; -import { Role, transformRole } from "./transformers/role.ts"; -import { ScheduledEvent, transformScheduledEvent } from "./transformers/scheduledEvent.ts"; -import { StageInstance, transformStageInstance } from "./transformers/stageInstance.ts"; -import { Sticker, StickerPack, transformSticker, transformStickerPack } from "./transformers/sticker.ts"; -import { Team, transformTeam } from "./transformers/team.ts"; -import { Template, transformTemplate } from "./transformers/template.ts"; -import { ThreadMember, transformThreadMember } from "./transformers/threadMember.ts"; -import { transformVoiceRegion, VoiceRegions } from "./transformers/voiceRegion.ts"; -import { transformVoiceState, VoiceState } from "./transformers/voiceState.ts"; -import { transformWebhook, Webhook } from "./transformers/webhook.ts"; -import { transformWelcomeScreen, WelcomeScreen } from "./transformers/welcomeScreen.ts"; -import { GuildWidget, transformWidget } from "./transformers/widget.ts"; -import { GuildWidgetSettings, transformWidgetSettings } from "./transformers/widgetSettings.ts"; -import { AllowedMentions } from "./typings.ts"; -import { bigintToSnowflake, snowflakeToBigint } from "./util/bigint.ts"; -import { BotCollection } from "./util/collection.ts"; -import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts"; -import { calculateBits, calculatePermissions } from "./util/permissions.ts"; import { routes } from "./util/routes.ts"; -import { urlToBase64 } from "./util/urlToBase64.ts"; -import { formatImageURL } from "./util/utils.ts"; -import { validateLength } from "./util/validateLength.ts"; +import { transformAllowedMentionsToDiscordAllowedMentions } from "./transformers/reverse/allowedMentions.ts"; +import { AllowedMentions } from "./mod.ts"; export function createBot(options: CreateBotOptions): Bot { const bot = { @@ -282,6 +306,7 @@ export function createUtils(options: Partial) { export interface HelperUtils { snowflakeToBigint: typeof snowflakeToBigint; bigintToSnowflake: typeof bigintToSnowflake; + calculateShardId: typeof calculateShardId; delay: typeof delay; iconHashToBigInt: typeof iconHashToBigInt; iconBigintToHash: typeof iconBigintToHash; @@ -681,7 +706,7 @@ export interface EventHandlers { bot: Bot, payload: { guildId: bigint; - emojis: BotCollection; + emojis: Collection; }, ) => unknown; guildBanAdd: (bot: Bot, user: User, guildId: bigint) => unknown; diff --git a/gateway/manager/gatewayManager.ts b/gateway/manager/gatewayManager.ts index bcaa8a319..8507b9aa2 100644 --- a/gateway/manager/gatewayManager.ts +++ b/gateway/manager/gatewayManager.ts @@ -1,6 +1,8 @@ +import { GetGatewayBot } from "../../transformers/gatewayBot.ts"; import { DiscordGatewayPayload } from "../../types/discord.ts"; -import { GatewayBot, PickPartial } from "../../types/shared.ts"; +import { GatewayIntents, MakeRequired, OmitFirstFnArg, PickPartial } from "../../types/shared.ts"; import { LeakyBucket } from "../../util/bucket.ts"; +import { Collection } from "../../util/collection.ts"; import { CreateShard, createShard } from "../shard/createShard.ts"; import { Shard, ShardGatewayConfig } from "../shard/types.ts"; import { calculateTotalShards } from "./calculateTotalShards.ts"; @@ -46,7 +48,7 @@ export function createGatewayManager( /** The max concurrency buckets. * Those will be created when the `spawnShards` (which calls `prepareBuckets` under the hood) function gets called. */ - buckets: new Map< + buckets: new Collection< number, { workers: { id: number; queue: number[] }[]; @@ -220,7 +222,7 @@ export interface CreateGatewayManager { lastShardId: number; /** Important data which is used by the manager to connect shards to the gateway. */ - gatewayBot: GatewayBot; + gatewayBot: GetGatewayBot; gatewayConfig: PickPartial; @@ -228,7 +230,7 @@ export interface CreateGatewayManager { createShardOptions?: Omit; /** Stored as bucketId: { workers: [workerId, [ShardIds]], createNextShard: boolean } */ - buckets: Map< + buckets: Collection< number, { workers: { id: number; queue: number[] }[]; diff --git a/gateway/manager/stop.ts b/gateway/manager/stop.ts index e852de265..99508b0da 100644 --- a/gateway/manager/stop.ts +++ b/gateway/manager/stop.ts @@ -1,4 +1,4 @@ -import { delay } from "../../util/delay.ts"; +import { delay } from "../../util/utils.ts"; import { GatewayManager } from "./gatewayManager.ts"; export async function stop(gateway: GatewayManager, code: number, reason: string) { diff --git a/gateway/shard/createShard.ts b/gateway/shard/createShard.ts index 359517431..63752f1a1 100644 --- a/gateway/shard/createShard.ts +++ b/gateway/shard/createShard.ts @@ -12,6 +12,7 @@ import { ShardSocketRequest, ShardState, } from "./types.ts"; +import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts"; import { startHeartbeating } from "./startHeartbeating.ts"; import { stopHeartbeating } from "./stopHeartbeating.ts"; import { resume } from "./resume.ts"; @@ -23,7 +24,7 @@ import { connect } from "./connect.ts"; import { close } from "./close.ts"; import { shutdown } from "./shutdown.ts"; import { isOpen } from "./isOpen.ts"; -import { DiscordGatewayPayload, DiscordStatusUpdate } from "../../types/discord.ts"; +import { DiscordGatewayPayload } from "../../types/discord.ts"; import { GatewayIntents, PickPartial } from "../../types/shared.ts"; import { API_VERSION } from "../../util/constants.ts"; @@ -274,7 +275,7 @@ export interface CreateShard { isOpen?: typeof isOpen; /** Function which can be overwritten in order to get the shards presence. */ - makePresence?(shardId: number): Promise | DiscordStatusUpdate; + makePresence?(shardId: number): Promise | StatusUpdate; /** The maximum of requests which can be send to discord per rate limit tick. * Typically this value should not be changed. diff --git a/gateway/shard/handleMessage.ts b/gateway/shard/handleMessage.ts index f1042d263..a50c9e8db 100644 --- a/gateway/shard/handleMessage.ts +++ b/gateway/shard/handleMessage.ts @@ -1,7 +1,7 @@ import { DiscordGatewayPayload, DiscordHello, DiscordReady } from "../../types/discord.ts"; import { GatewayOpcodes } from "../../types/shared.ts"; import { createLeakyBucket } from "../../util/bucket.ts"; -import { delay } from "../../util/delay.ts"; +import { delay } from "../../util/utils.ts"; import { decompressWith } from "./deps.ts"; import { GATEWAY_RATE_LIMIT_RESET_INTERVAL, Shard, ShardState } from "./types.ts"; diff --git a/gateway/shard/types.ts b/gateway/shard/types.ts index d7dc06ee1..a9e326ded 100644 --- a/gateway/shard/types.ts +++ b/gateway/shard/types.ts @@ -1,5 +1,7 @@ +import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts"; import { DiscordGatewayPayload } from "../../types/discord.ts"; import { GatewayOpcodes } from "../../types/shared.ts"; +import { LeakyBucket } from "../../util/bucket.ts"; import { createShard } from "./createShard.ts"; // TODO: think whether we also need an identifiedShard function diff --git a/plugins/bot/handlers/channels/CHANNEL_CREATE.ts b/handlers/channels/CHANNEL_CREATE.ts similarity index 64% rename from plugins/bot/handlers/channels/CHANNEL_CREATE.ts rename to handlers/channels/CHANNEL_CREATE.ts index ed50c66c2..f7a8c690f 100644 --- a/plugins/bot/handlers/channels/CHANNEL_CREATE.ts +++ b/handlers/channels/CHANNEL_CREATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload) { const channel = bot.transformers.channel(bot, { channel: payload.d as DiscordChannel }); diff --git a/plugins/bot/handlers/channels/CHANNEL_DELETE.ts b/handlers/channels/CHANNEL_DELETE.ts similarity index 75% rename from plugins/bot/handlers/channels/CHANNEL_DELETE.ts rename to handlers/channels/CHANNEL_DELETE.ts index 8f1684f5d..fb6c7be9b 100644 --- a/plugins/bot/handlers/channels/CHANNEL_DELETE.ts +++ b/handlers/channels/CHANNEL_DELETE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannel; diff --git a/plugins/bot/handlers/channels/CHANNEL_PINS_UPDATE.ts b/handlers/channels/CHANNEL_PINS_UPDATE.ts similarity index 88% rename from plugins/bot/handlers/channels/CHANNEL_PINS_UPDATE.ts rename to handlers/channels/CHANNEL_PINS_UPDATE.ts index 208a7f19a..7361a44e5 100644 --- a/plugins/bot/handlers/channels/CHANNEL_PINS_UPDATE.ts +++ b/handlers/channels/CHANNEL_PINS_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannelPinsUpdate, DiscordGatewayPayload } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannelPinsUpdate, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleChannelPinsUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannelPinsUpdate; diff --git a/plugins/bot/handlers/channels/CHANNEL_UPDATE.ts b/handlers/channels/CHANNEL_UPDATE.ts similarity index 66% rename from plugins/bot/handlers/channels/CHANNEL_UPDATE.ts rename to handlers/channels/CHANNEL_UPDATE.ts index 2c97f30cb..6933f0b7a 100644 --- a/plugins/bot/handlers/channels/CHANNEL_UPDATE.ts +++ b/handlers/channels/CHANNEL_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannel; diff --git a/plugins/bot/handlers/channels/STAGE_INSTANCE_CREATE.ts b/handlers/channels/STAGE_INSTANCE_CREATE.ts similarity index 87% rename from plugins/bot/handlers/channels/STAGE_INSTANCE_CREATE.ts rename to handlers/channels/STAGE_INSTANCE_CREATE.ts index 53f49ee0f..e2c2ac58a 100644 --- a/plugins/bot/handlers/channels/STAGE_INSTANCE_CREATE.ts +++ b/handlers/channels/STAGE_INSTANCE_CREATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts"; export function handleStageInstanceCreate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordStageInstance; diff --git a/plugins/bot/handlers/channels/STAGE_INSTANCE_DELETE.ts b/handlers/channels/STAGE_INSTANCE_DELETE.ts similarity index 87% rename from plugins/bot/handlers/channels/STAGE_INSTANCE_DELETE.ts rename to handlers/channels/STAGE_INSTANCE_DELETE.ts index af8d5dacf..b98f27008 100644 --- a/plugins/bot/handlers/channels/STAGE_INSTANCE_DELETE.ts +++ b/handlers/channels/STAGE_INSTANCE_DELETE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts"; export function handleStageInstanceDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordStageInstance; diff --git a/plugins/bot/handlers/channels/STAGE_INSTANCE_UPDATE.ts b/handlers/channels/STAGE_INSTANCE_UPDATE.ts similarity index 87% rename from plugins/bot/handlers/channels/STAGE_INSTANCE_UPDATE.ts rename to handlers/channels/STAGE_INSTANCE_UPDATE.ts index 69c55a45b..0685127fc 100644 --- a/plugins/bot/handlers/channels/STAGE_INSTANCE_UPDATE.ts +++ b/handlers/channels/STAGE_INSTANCE_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts"; export function handleStageInstanceUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordStageInstance; diff --git a/plugins/bot/handlers/channels/THREAD_CREATE.ts b/handlers/channels/THREAD_CREATE.ts similarity index 75% rename from plugins/bot/handlers/channels/THREAD_CREATE.ts rename to handlers/channels/THREAD_CREATE.ts index 823f7c59c..a13d1247b 100644 --- a/plugins/bot/handlers/channels/THREAD_CREATE.ts +++ b/handlers/channels/THREAD_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleThreadCreate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannel; diff --git a/plugins/bot/handlers/channels/THREAD_DELETE.ts b/handlers/channels/THREAD_DELETE.ts similarity index 75% rename from plugins/bot/handlers/channels/THREAD_DELETE.ts rename to handlers/channels/THREAD_DELETE.ts index 60c0906b6..9b9755752 100644 --- a/plugins/bot/handlers/channels/THREAD_DELETE.ts +++ b/handlers/channels/THREAD_DELETE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleThreadDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannel; diff --git a/plugins/bot/handlers/channels/THREAD_LIST_SYNC.ts b/handlers/channels/THREAD_LIST_SYNC.ts similarity index 97% rename from plugins/bot/handlers/channels/THREAD_LIST_SYNC.ts rename to handlers/channels/THREAD_LIST_SYNC.ts index c6d0c2ba4..b476e1385 100644 --- a/plugins/bot/handlers/channels/THREAD_LIST_SYNC.ts +++ b/handlers/channels/THREAD_LIST_SYNC.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordThreadListSync } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordThreadListSync } from "../../types/discord.ts"; export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordThreadListSync; diff --git a/plugins/bot/handlers/channels/THREAD_MEMBERS_UPDATE.ts b/handlers/channels/THREAD_MEMBERS_UPDATE.ts similarity index 95% rename from plugins/bot/handlers/channels/THREAD_MEMBERS_UPDATE.ts rename to handlers/channels/THREAD_MEMBERS_UPDATE.ts index 12ca490a0..be40fe07d 100644 --- a/plugins/bot/handlers/channels/THREAD_MEMBERS_UPDATE.ts +++ b/handlers/channels/THREAD_MEMBERS_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordThreadMembersUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordThreadMembersUpdate } from "../../types/discord.ts"; export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordThreadMembersUpdate; diff --git a/plugins/bot/handlers/channels/THREAD_MEMBER_UPDATE.ts b/handlers/channels/THREAD_MEMBER_UPDATE.ts similarity index 94% rename from plugins/bot/handlers/channels/THREAD_MEMBER_UPDATE.ts rename to handlers/channels/THREAD_MEMBER_UPDATE.ts index b7718c8e1..404c7bc3f 100644 --- a/plugins/bot/handlers/channels/THREAD_MEMBER_UPDATE.ts +++ b/handlers/channels/THREAD_MEMBER_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordThreadMemberUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordThreadMemberUpdate } from "../../types/discord.ts"; export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordThreadMemberUpdate; diff --git a/plugins/bot/handlers/channels/THREAD_UPDATE.ts b/handlers/channels/THREAD_UPDATE.ts similarity index 75% rename from plugins/bot/handlers/channels/THREAD_UPDATE.ts rename to handlers/channels/THREAD_UPDATE.ts index 5bc4d778a..ec839a350 100644 --- a/plugins/bot/handlers/channels/THREAD_UPDATE.ts +++ b/handlers/channels/THREAD_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordChannel, DiscordGatewayPayload } from "../../deps.ts"; +import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts"; export async function handleThreadUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordChannel; diff --git a/plugins/bot/handlers/channels/mod.ts b/handlers/channels/mod.ts similarity index 100% rename from plugins/bot/handlers/channels/mod.ts rename to handlers/channels/mod.ts diff --git a/plugins/bot/handlers/emojis/GUILD_EMOJIS_UPDATE.ts b/handlers/emojis/GUILD_EMOJIS_UPDATE.ts similarity index 77% rename from plugins/bot/handlers/emojis/GUILD_EMOJIS_UPDATE.ts rename to handlers/emojis/GUILD_EMOJIS_UPDATE.ts index dda4449d5..ba7712750 100644 --- a/plugins/bot/handlers/emojis/GUILD_EMOJIS_UPDATE.ts +++ b/handlers/emojis/GUILD_EMOJIS_UPDATE.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildEmojisUpdate } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordGuildEmojisUpdate } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; export async function handleGuildEmojisUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildEmojisUpdate; diff --git a/plugins/bot/handlers/emojis/mod.ts b/handlers/emojis/mod.ts similarity index 100% rename from plugins/bot/handlers/emojis/mod.ts rename to handlers/emojis/mod.ts diff --git a/plugins/bot/handlers/guilds/GUILD_BAN_ADD.ts b/handlers/guilds/GUILD_BAN_ADD.ts similarity index 82% rename from plugins/bot/handlers/guilds/GUILD_BAN_ADD.ts rename to handlers/guilds/GUILD_BAN_ADD.ts index 64fc99002..889cd2133 100644 --- a/plugins/bot/handlers/guilds/GUILD_BAN_ADD.ts +++ b/handlers/guilds/GUILD_BAN_ADD.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../types/discord.ts"; export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildBanAddRemove; diff --git a/plugins/bot/handlers/guilds/GUILD_BAN_REMOVE.ts b/handlers/guilds/GUILD_BAN_REMOVE.ts similarity index 83% rename from plugins/bot/handlers/guilds/GUILD_BAN_REMOVE.ts rename to handlers/guilds/GUILD_BAN_REMOVE.ts index 6bc469dce..993df1c8b 100644 --- a/plugins/bot/handlers/guilds/GUILD_BAN_REMOVE.ts +++ b/handlers/guilds/GUILD_BAN_REMOVE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../types/discord.ts"; export async function handleGuildBanRemove(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildBanAddRemove; diff --git a/plugins/bot/handlers/guilds/GUILD_CREATE.ts b/handlers/guilds/GUILD_CREATE.ts similarity index 71% rename from plugins/bot/handlers/guilds/GUILD_CREATE.ts rename to handlers/guilds/GUILD_CREATE.ts index df7b5eedb..95728e445 100644 --- a/plugins/bot/handlers/guilds/GUILD_CREATE.ts +++ b/handlers/guilds/GUILD_CREATE.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import type { Guild } from "../../transformers/guild.ts"; -import { DiscordGatewayPayload, DiscordGuild } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuild } from "../../types/discord.ts"; export function handleGuildCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordGuild; diff --git a/plugins/bot/handlers/guilds/GUILD_DELETE.ts b/handlers/guilds/GUILD_DELETE.ts similarity index 81% rename from plugins/bot/handlers/guilds/GUILD_DELETE.ts rename to handlers/guilds/GUILD_DELETE.ts index 8eb4d1346..80bddd0e0 100644 --- a/plugins/bot/handlers/guilds/GUILD_DELETE.ts +++ b/handlers/guilds/GUILD_DELETE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordUnavailableGuild } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordUnavailableGuild } from "../../types/discord.ts"; export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordUnavailableGuild; diff --git a/plugins/bot/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts b/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts similarity index 81% rename from plugins/bot/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts rename to handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts index 6f15c917a..ae05e67ca 100644 --- a/plugins/bot/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts +++ b/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildIntegrationsUpdate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGatewayPayload, DiscordGuildIntegrationsUpdate } from "../../types/discord.ts"; export async function handleGuildIntegrationsUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildIntegrationsUpdate; diff --git a/plugins/bot/handlers/guilds/GUILD_LOADED_DD.ts b/handlers/guilds/GUILD_LOADED_DD.ts similarity index 72% rename from plugins/bot/handlers/guilds/GUILD_LOADED_DD.ts rename to handlers/guilds/GUILD_LOADED_DD.ts index 5672b7fef..2ccb44dfb 100644 --- a/plugins/bot/handlers/guilds/GUILD_LOADED_DD.ts +++ b/handlers/guilds/GUILD_LOADED_DD.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import type { Guild } from "../../transformers/guild.ts"; -import { DiscordGatewayPayload, DiscordGuild } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuild } from "../../types/discord.ts"; export function handleGuildLoaded(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordGuild; diff --git a/plugins/bot/handlers/guilds/GUILD_UPDATE.ts b/handlers/guilds/GUILD_UPDATE.ts similarity index 71% rename from plugins/bot/handlers/guilds/GUILD_UPDATE.ts rename to handlers/guilds/GUILD_UPDATE.ts index a877d44f5..d360ae7c7 100644 --- a/plugins/bot/handlers/guilds/GUILD_UPDATE.ts +++ b/handlers/guilds/GUILD_UPDATE.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import type { Guild } from "../../transformers/guild.ts"; -import { DiscordGatewayPayload, DiscordGuild } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuild } from "../../types/discord.ts"; export function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordGuild; diff --git a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts b/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts similarity index 81% rename from plugins/bot/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts rename to handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts index 3dad18258..d44220ba4 100644 --- a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts +++ b/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from "../../../types/discord.ts"; /** Requires the MANAGE_GUILD permission. */ export function handleAutoModerationActionExecution(bot: Bot, data: DiscordGatewayPayload, shardId: number) { diff --git a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts similarity index 82% rename from plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts rename to handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts index a8f8399c4..a41d27b36 100644 --- a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts +++ b/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts"; /** Requires the MANAGE_GUILD permission. */ export function handleAutoModerationRuleCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { diff --git a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts similarity index 82% rename from plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts rename to handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts index 6bd4d7184..28ec5f3c1 100644 --- a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts +++ b/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts"; /** Requires the MANAGE_GUILD permission. */ export function handleAutoModerationRuleDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number) { diff --git a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts similarity index 82% rename from plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts rename to handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts index e5cefdab5..4e717fc5c 100644 --- a/plugins/bot/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts +++ b/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts"; /** Requires the MANAGE_GUILD permission. */ export function handleAutoModerationRuleUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { diff --git a/plugins/bot/handlers/guilds/automod/mod.ts b/handlers/guilds/automod/mod.ts similarity index 100% rename from plugins/bot/handlers/guilds/automod/mod.ts rename to handlers/guilds/automod/mod.ts diff --git a/plugins/bot/handlers/guilds/mod.ts b/handlers/guilds/mod.ts similarity index 100% rename from plugins/bot/handlers/guilds/mod.ts rename to handlers/guilds/mod.ts diff --git a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts similarity index 81% rename from plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts rename to handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts index 901ed4ec3..91841b958 100644 --- a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts +++ b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts"; export function handleGuildScheduledEventCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordScheduledEvent; diff --git a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts similarity index 80% rename from plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts rename to handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts index 9fe06b70c..704df9697 100644 --- a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts +++ b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts"; export function handleGuildScheduledEventDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordScheduledEvent; diff --git a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts similarity index 80% rename from plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts rename to handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts index 3a0c2792e..a08f89f94 100644 --- a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts +++ b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts"; export function handleGuildScheduledEventUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordScheduledEvent; diff --git a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts similarity index 86% rename from plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts rename to handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts index dec4e4092..144fd672a 100644 --- a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts +++ b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGatewayPayload, DiscordScheduledEventUserAdd } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGatewayPayload, DiscordScheduledEventUserAdd } from "../../../types/discord.ts"; export function handleGuildScheduledEventUserAdd(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordScheduledEventUserAdd; diff --git a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts similarity index 85% rename from plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts rename to handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts index f71314b02..7a53e9b26 100644 --- a/plugins/bot/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +++ b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGatewayPayload, DiscordScheduledEventUserRemove } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGatewayPayload, DiscordScheduledEventUserRemove } from "../../../types/discord.ts"; export function handleGuildScheduledEventUserRemove(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordScheduledEventUserRemove; diff --git a/plugins/bot/handlers/guilds/scheduledEvents/mod.ts b/handlers/guilds/scheduledEvents/mod.ts similarity index 100% rename from plugins/bot/handlers/guilds/scheduledEvents/mod.ts rename to handlers/guilds/scheduledEvents/mod.ts diff --git a/plugins/bot/handlers/integrations/INTEGRATION_CREATE.ts b/handlers/integrations/INTEGRATION_CREATE.ts similarity index 90% rename from plugins/bot/handlers/integrations/INTEGRATION_CREATE.ts rename to handlers/integrations/INTEGRATION_CREATE.ts index 5f6147bd1..87a10ab58 100644 --- a/plugins/bot/handlers/integrations/INTEGRATION_CREATE.ts +++ b/handlers/integrations/INTEGRATION_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../types/discord.ts"; export function handleIntegrationCreate(bot: Bot, data: DiscordGatewayPayload) { bot.events.integrationCreate( diff --git a/plugins/bot/handlers/integrations/INTEGRATION_DELETE.ts b/handlers/integrations/INTEGRATION_DELETE.ts similarity index 95% rename from plugins/bot/handlers/integrations/INTEGRATION_DELETE.ts rename to handlers/integrations/INTEGRATION_DELETE.ts index da9abfcbb..a9f19e1b1 100644 --- a/plugins/bot/handlers/integrations/INTEGRATION_DELETE.ts +++ b/handlers/integrations/INTEGRATION_DELETE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordIntegrationDelete } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordIntegrationDelete } from "../../types/discord.ts"; export function handleIntegrationDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordIntegrationDelete; diff --git a/plugins/bot/handlers/integrations/INTEGRATION_UPDATE.ts b/handlers/integrations/INTEGRATION_UPDATE.ts similarity index 90% rename from plugins/bot/handlers/integrations/INTEGRATION_UPDATE.ts rename to handlers/integrations/INTEGRATION_UPDATE.ts index 103918dfe..40cc920f3 100644 --- a/plugins/bot/handlers/integrations/INTEGRATION_UPDATE.ts +++ b/handlers/integrations/INTEGRATION_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../types/discord.ts"; export function handleIntegrationUpdate(bot: Bot, data: DiscordGatewayPayload) { bot.events.integrationUpdate( diff --git a/plugins/bot/handlers/integrations/mod.ts b/handlers/integrations/mod.ts similarity index 100% rename from plugins/bot/handlers/integrations/mod.ts rename to handlers/integrations/mod.ts diff --git a/plugins/bot/handlers/interactions/INTERACTION_CREATE.ts b/handlers/interactions/INTERACTION_CREATE.ts similarity index 95% rename from plugins/bot/handlers/interactions/INTERACTION_CREATE.ts rename to handlers/interactions/INTERACTION_CREATE.ts index 634bb8a2a..9c9d4cfb2 100644 --- a/plugins/bot/handlers/interactions/INTERACTION_CREATE.ts +++ b/handlers/interactions/INTERACTION_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordInteraction } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordInteraction } from "../../types/discord.ts"; export async function handleInteractionCreate(bot: Bot, data: DiscordGatewayPayload) { bot.cache.unrepliedInteractions.add(bot.transformers.snowflake((data.d as DiscordInteraction).id)); diff --git a/plugins/bot/handlers/interactions/mod.ts b/handlers/interactions/mod.ts similarity index 100% rename from plugins/bot/handlers/interactions/mod.ts rename to handlers/interactions/mod.ts diff --git a/plugins/bot/handlers/invites/INVITE_CREATE.ts b/handlers/invites/INVITE_CREATE.ts similarity index 92% rename from plugins/bot/handlers/invites/INVITE_CREATE.ts rename to handlers/invites/INVITE_CREATE.ts index e0e344fe4..624a694ec 100644 --- a/plugins/bot/handlers/invites/INVITE_CREATE.ts +++ b/handlers/invites/INVITE_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordInviteCreate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordInviteCreate } from "../../types/discord.ts"; export function handleInviteCreate(bot: Bot, data: DiscordGatewayPayload) { bot.events.inviteCreate(bot, bot.transformers.invite(bot, data.d as DiscordInviteCreate)); diff --git a/plugins/bot/handlers/invites/INVITE_DELETE.ts b/handlers/invites/INVITE_DELETE.ts similarity index 96% rename from plugins/bot/handlers/invites/INVITE_DELETE.ts rename to handlers/invites/INVITE_DELETE.ts index c3b932b45..db4e54d44 100644 --- a/plugins/bot/handlers/invites/INVITE_DELETE.ts +++ b/handlers/invites/INVITE_DELETE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordInviteDelete } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordInviteDelete } from "../../types/discord.ts"; export function handleInviteDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordInviteDelete; diff --git a/plugins/bot/handlers/invites/mod.ts b/handlers/invites/mod.ts similarity index 100% rename from plugins/bot/handlers/invites/mod.ts rename to handlers/invites/mod.ts diff --git a/plugins/bot/handlers/members/GUILD_MEMBERS_CHUNK.ts b/handlers/members/GUILD_MEMBERS_CHUNK.ts similarity index 98% rename from plugins/bot/handlers/members/GUILD_MEMBERS_CHUNK.ts rename to handlers/members/GUILD_MEMBERS_CHUNK.ts index cb5352b10..4e0fba27a 100644 --- a/plugins/bot/handlers/members/GUILD_MEMBERS_CHUNK.ts +++ b/handlers/members/GUILD_MEMBERS_CHUNK.ts @@ -1,6 +1,6 @@ import { Bot } from "../../bot.ts"; import { statusTypes } from "../../transformers/presence.ts"; -import { DiscordGatewayPayload, DiscordGuildMembersChunk } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildMembersChunk } from "../../types/discord.ts"; export async function handleGuildMembersChunk(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildMembersChunk; diff --git a/plugins/bot/handlers/members/GUILD_MEMBER_ADD.ts b/handlers/members/GUILD_MEMBER_ADD.ts similarity index 95% rename from plugins/bot/handlers/members/GUILD_MEMBER_ADD.ts rename to handlers/members/GUILD_MEMBER_ADD.ts index 81a76367a..0c87836a0 100644 --- a/plugins/bot/handlers/members/GUILD_MEMBER_ADD.ts +++ b/handlers/members/GUILD_MEMBER_ADD.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildMemberAdd } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildMemberAdd } from "../../types/discord.ts"; export async function handleGuildMemberAdd(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildMemberAdd; diff --git a/plugins/bot/handlers/members/GUILD_MEMBER_REMOVE.ts b/handlers/members/GUILD_MEMBER_REMOVE.ts similarity index 94% rename from plugins/bot/handlers/members/GUILD_MEMBER_REMOVE.ts rename to handlers/members/GUILD_MEMBER_REMOVE.ts index e733755a3..383a32be4 100644 --- a/plugins/bot/handlers/members/GUILD_MEMBER_REMOVE.ts +++ b/handlers/members/GUILD_MEMBER_REMOVE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildMemberRemove } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildMemberRemove } from "../../types/discord.ts"; export async function handleGuildMemberRemove(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildMemberRemove; diff --git a/plugins/bot/handlers/members/GUILD_MEMBER_UPDATE.ts b/handlers/members/GUILD_MEMBER_UPDATE.ts similarity index 94% rename from plugins/bot/handlers/members/GUILD_MEMBER_UPDATE.ts rename to handlers/members/GUILD_MEMBER_UPDATE.ts index 2eecdc0b5..ba413141b 100644 --- a/plugins/bot/handlers/members/GUILD_MEMBER_UPDATE.ts +++ b/handlers/members/GUILD_MEMBER_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildMemberUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildMemberUpdate } from "../../types/discord.ts"; export async function handleGuildMemberUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildMemberUpdate; diff --git a/plugins/bot/handlers/members/mod.ts b/handlers/members/mod.ts similarity index 100% rename from plugins/bot/handlers/members/mod.ts rename to handlers/members/mod.ts diff --git a/plugins/bot/handlers/messages/MESSAGE_CREATE.ts b/handlers/messages/MESSAGE_CREATE.ts similarity index 75% rename from plugins/bot/handlers/messages/MESSAGE_CREATE.ts rename to handlers/messages/MESSAGE_CREATE.ts index 2ac08bca7..012bd4104 100644 --- a/plugins/bot/handlers/messages/MESSAGE_CREATE.ts +++ b/handlers/messages/MESSAGE_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessage } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessage } from "../../types/discord.ts"; export async function handleMessageCreate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessage; diff --git a/plugins/bot/handlers/messages/MESSAGE_DELETE.ts b/handlers/messages/MESSAGE_DELETE.ts similarity index 95% rename from plugins/bot/handlers/messages/MESSAGE_DELETE.ts rename to handlers/messages/MESSAGE_DELETE.ts index 60c8f8a6c..a20f6c5e2 100644 --- a/plugins/bot/handlers/messages/MESSAGE_DELETE.ts +++ b/handlers/messages/MESSAGE_DELETE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageDelete } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageDelete } from "../../types/discord.ts"; export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageDelete; diff --git a/plugins/bot/handlers/messages/MESSAGE_DELETE_BULK.ts b/handlers/messages/MESSAGE_DELETE_BULK.ts similarity index 96% rename from plugins/bot/handlers/messages/MESSAGE_DELETE_BULK.ts rename to handlers/messages/MESSAGE_DELETE_BULK.ts index a63134e36..6fd856e64 100644 --- a/plugins/bot/handlers/messages/MESSAGE_DELETE_BULK.ts +++ b/handlers/messages/MESSAGE_DELETE_BULK.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageDeleteBulk } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageDeleteBulk } from "../../types/discord.ts"; export async function handleMessageDeleteBulk(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageDeleteBulk; diff --git a/plugins/bot/handlers/messages/MESSAGE_REACTION_ADD.ts b/handlers/messages/MESSAGE_REACTION_ADD.ts similarity index 96% rename from plugins/bot/handlers/messages/MESSAGE_REACTION_ADD.ts rename to handlers/messages/MESSAGE_REACTION_ADD.ts index 2949dd373..9d14b2a1a 100644 --- a/plugins/bot/handlers/messages/MESSAGE_REACTION_ADD.ts +++ b/handlers/messages/MESSAGE_REACTION_ADD.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageReactionAdd } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageReactionAdd } from "../../types/discord.ts"; export async function handleMessageReactionAdd(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageReactionAdd; diff --git a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE.ts b/handlers/messages/MESSAGE_REACTION_REMOVE.ts similarity index 95% rename from plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE.ts rename to handlers/messages/MESSAGE_REACTION_REMOVE.ts index d78b2027e..b33341863 100644 --- a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE.ts +++ b/handlers/messages/MESSAGE_REACTION_REMOVE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageReactionRemove } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageReactionRemove } from "../../types/discord.ts"; export async function handleMessageReactionRemove(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageReactionRemove; diff --git a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts b/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts similarity index 94% rename from plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts rename to handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts index 2e85ad83e..f2a384925 100644 --- a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts +++ b/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageReactionRemoveAll } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageReactionRemoveAll } from "../../types/discord.ts"; export async function handleMessageReactionRemoveAll(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageReactionRemoveAll; diff --git a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts b/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts similarity index 94% rename from plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts rename to handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts index bbda9a1d7..3f102a110 100644 --- a/plugins/bot/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts +++ b/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessageReactionRemoveEmoji } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessageReactionRemoveEmoji } from "../../types/discord.ts"; export async function handleMessageReactionRemoveEmoji(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessageReactionRemoveEmoji; diff --git a/plugins/bot/handlers/messages/MESSAGE_UPDATE.ts b/handlers/messages/MESSAGE_UPDATE.ts similarity index 77% rename from plugins/bot/handlers/messages/MESSAGE_UPDATE.ts rename to handlers/messages/MESSAGE_UPDATE.ts index a3fb63a72..d26b8ed54 100644 --- a/plugins/bot/handlers/messages/MESSAGE_UPDATE.ts +++ b/handlers/messages/MESSAGE_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordMessage } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordMessage } from "../../types/discord.ts"; export async function handleMessageUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordMessage; diff --git a/plugins/bot/handlers/messages/mod.ts b/handlers/messages/mod.ts similarity index 100% rename from plugins/bot/handlers/messages/mod.ts rename to handlers/messages/mod.ts diff --git a/plugins/bot/handlers/misc/PRESENCE_UPDATE.ts b/handlers/misc/PRESENCE_UPDATE.ts similarity index 92% rename from plugins/bot/handlers/misc/PRESENCE_UPDATE.ts rename to handlers/misc/PRESENCE_UPDATE.ts index e6f56613b..2071f8da1 100644 --- a/plugins/bot/handlers/misc/PRESENCE_UPDATE.ts +++ b/handlers/misc/PRESENCE_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordPresenceUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordPresenceUpdate } from "../../types/discord.ts"; export async function handlePresenceUpdate(bot: Bot, data: DiscordGatewayPayload) { bot.events.presenceUpdate(bot, bot.transformers.presence(bot, data.d as DiscordPresenceUpdate)); diff --git a/plugins/bot/handlers/misc/READY.ts b/handlers/misc/READY.ts similarity index 90% rename from plugins/bot/handlers/misc/READY.ts rename to handlers/misc/READY.ts index 176405af9..b438bff9d 100644 --- a/plugins/bot/handlers/misc/READY.ts +++ b/handlers/misc/READY.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordReady } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordReady } from "../../types/discord.ts"; export function handleReady(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as DiscordReady; diff --git a/plugins/bot/handlers/misc/TYPING_START.ts b/handlers/misc/TYPING_START.ts similarity index 97% rename from plugins/bot/handlers/misc/TYPING_START.ts rename to handlers/misc/TYPING_START.ts index 31107d16f..6bb6e06fd 100644 --- a/plugins/bot/handlers/misc/TYPING_START.ts +++ b/handlers/misc/TYPING_START.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordTypingStart } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordTypingStart } from "../../types/discord.ts"; export function handleTypingStart(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordTypingStart; diff --git a/plugins/bot/handlers/misc/USER_UPDATE.ts b/handlers/misc/USER_UPDATE.ts similarity index 74% rename from plugins/bot/handlers/misc/USER_UPDATE.ts rename to handlers/misc/USER_UPDATE.ts index aeaca15c2..c02f2bdf8 100644 --- a/plugins/bot/handlers/misc/USER_UPDATE.ts +++ b/handlers/misc/USER_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordUser } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordUser } from "../../types/discord.ts"; export async function handleUserUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordUser; diff --git a/plugins/bot/handlers/misc/mod.ts b/handlers/misc/mod.ts similarity index 100% rename from plugins/bot/handlers/misc/mod.ts rename to handlers/misc/mod.ts diff --git a/plugins/bot/handlers/mod.ts b/handlers/mod.ts similarity index 100% rename from plugins/bot/handlers/mod.ts rename to handlers/mod.ts diff --git a/plugins/bot/handlers/roles/GUILD_ROLE_CREATE.ts b/handlers/roles/GUILD_ROLE_CREATE.ts similarity index 94% rename from plugins/bot/handlers/roles/GUILD_ROLE_CREATE.ts rename to handlers/roles/GUILD_ROLE_CREATE.ts index 6a476d4a8..d1fc1e9d4 100644 --- a/plugins/bot/handlers/roles/GUILD_ROLE_CREATE.ts +++ b/handlers/roles/GUILD_ROLE_CREATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildRoleCreate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildRoleCreate } from "../../types/discord.ts"; export async function handleGuildRoleCreate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildRoleCreate; diff --git a/plugins/bot/handlers/roles/GUILD_ROLE_DELETE.ts b/handlers/roles/GUILD_ROLE_DELETE.ts similarity index 94% rename from plugins/bot/handlers/roles/GUILD_ROLE_DELETE.ts rename to handlers/roles/GUILD_ROLE_DELETE.ts index 8b386933f..e0e13fa22 100644 --- a/plugins/bot/handlers/roles/GUILD_ROLE_DELETE.ts +++ b/handlers/roles/GUILD_ROLE_DELETE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildRoleDelete } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildRoleDelete } from "../../types/discord.ts"; export async function handleGuildRoleDelete(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildRoleDelete; diff --git a/plugins/bot/handlers/roles/GUILD_ROLE_UPDATE.ts b/handlers/roles/GUILD_ROLE_UPDATE.ts similarity index 94% rename from plugins/bot/handlers/roles/GUILD_ROLE_UPDATE.ts rename to handlers/roles/GUILD_ROLE_UPDATE.ts index 99610d906..7d4ce211d 100644 --- a/plugins/bot/handlers/roles/GUILD_ROLE_UPDATE.ts +++ b/handlers/roles/GUILD_ROLE_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordGuildRoleUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordGuildRoleUpdate } from "../../types/discord.ts"; export async function handleGuildRoleUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildRoleUpdate; diff --git a/plugins/bot/handlers/roles/mod.ts b/handlers/roles/mod.ts similarity index 100% rename from plugins/bot/handlers/roles/mod.ts rename to handlers/roles/mod.ts diff --git a/plugins/bot/handlers/voice/VOICE_SERVER_UPDATE.ts b/handlers/voice/VOICE_SERVER_UPDATE.ts similarity index 94% rename from plugins/bot/handlers/voice/VOICE_SERVER_UPDATE.ts rename to handlers/voice/VOICE_SERVER_UPDATE.ts index 0f41ddb3b..73b5dd250 100644 --- a/plugins/bot/handlers/voice/VOICE_SERVER_UPDATE.ts +++ b/handlers/voice/VOICE_SERVER_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordVoiceServerUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordVoiceServerUpdate } from "../../types/discord.ts"; export async function handleVoiceServerUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordVoiceServerUpdate; diff --git a/plugins/bot/handlers/voice/VOICE_STATE_UPDATE.ts b/handlers/voice/VOICE_STATE_UPDATE.ts similarity index 95% rename from plugins/bot/handlers/voice/VOICE_STATE_UPDATE.ts rename to handlers/voice/VOICE_STATE_UPDATE.ts index 229a5598f..9c3767812 100644 --- a/plugins/bot/handlers/voice/VOICE_STATE_UPDATE.ts +++ b/handlers/voice/VOICE_STATE_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordVoiceState } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordVoiceState } from "../../types/discord.ts"; export async function handleVoiceStateUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordVoiceState; diff --git a/plugins/bot/handlers/voice/mod.ts b/handlers/voice/mod.ts similarity index 100% rename from plugins/bot/handlers/voice/mod.ts rename to handlers/voice/mod.ts diff --git a/plugins/bot/handlers/webhooks/WEBHOOKS_UPDATE.ts b/handlers/webhooks/WEBHOOKS_UPDATE.ts similarity index 94% rename from plugins/bot/handlers/webhooks/WEBHOOKS_UPDATE.ts rename to handlers/webhooks/WEBHOOKS_UPDATE.ts index c262ae114..3271649e8 100644 --- a/plugins/bot/handlers/webhooks/WEBHOOKS_UPDATE.ts +++ b/handlers/webhooks/WEBHOOKS_UPDATE.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordGatewayPayload, DiscordWebhookUpdate } from "../../deps.ts"; +import { DiscordGatewayPayload, DiscordWebhookUpdate } from "../../types/discord.ts"; export function handleWebhooksUpdate(bot: Bot, data: DiscordGatewayPayload) { const payload = data.d as DiscordWebhookUpdate; diff --git a/plugins/bot/handlers/webhooks/mod.ts b/handlers/webhooks/mod.ts similarity index 100% rename from plugins/bot/handlers/webhooks/mod.ts rename to handlers/webhooks/mod.ts diff --git a/plugins/bot/helpers/channels/createChannel.ts b/helpers/channels/createChannel.ts similarity index 94% rename from plugins/bot/helpers/channels/createChannel.ts rename to helpers/channels/createChannel.ts index 0873dabe6..7d9473fb9 100644 --- a/plugins/bot/helpers/channels/createChannel.ts +++ b/helpers/channels/createChannel.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { ChannelTypes, DiscordChannel } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { ChannelTypes } from "../../types/shared.ts"; +import { DiscordChannel } from "../../types/discord.ts"; import { OverwriteReadable } from "./editChannelOverwrite.ts"; /** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */ diff --git a/plugins/bot/helpers/channels/createStageInstance.ts b/helpers/channels/createStageInstance.ts similarity index 88% rename from plugins/bot/helpers/channels/createStageInstance.ts rename to helpers/channels/createStageInstance.ts index 49928379a..45a284461 100644 --- a/plugins/bot/helpers/channels/createStageInstance.ts +++ b/helpers/channels/createStageInstance.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordStageInstance } from "../../types/discord.ts"; /** Creates a new Stage instance associated to a Stage channel. Requires the user to be a moderator of the Stage channel. */ export async function createStageInstance(bot: Bot, options: CreateStageInstance) { diff --git a/plugins/bot/helpers/channels/deleteChannel.ts b/helpers/channels/deleteChannel.ts similarity index 80% rename from plugins/bot/helpers/channels/deleteChannel.ts rename to helpers/channels/deleteChannel.ts index bc2bce24a..e10bf6acc 100644 --- a/plugins/bot/helpers/channels/deleteChannel.ts +++ b/helpers/channels/deleteChannel.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel } from "../../types/discord.ts"; /** Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. Bot needs MANAGE_THREADS permissions in the server if deleting thread. */ export async function deleteChannel(bot: Bot, channelId: bigint, reason?: string) { diff --git a/plugins/bot/helpers/channels/deleteChannelOverwrite.ts b/helpers/channels/deleteChannelOverwrite.ts similarity index 89% rename from plugins/bot/helpers/channels/deleteChannelOverwrite.ts rename to helpers/channels/deleteChannelOverwrite.ts index cd0467a9f..2d475b61f 100644 --- a/plugins/bot/helpers/channels/deleteChannelOverwrite.ts +++ b/helpers/channels/deleteChannelOverwrite.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function deleteChannelOverwrite(bot: Bot, channelId: bigint, overwriteId: bigint) { diff --git a/plugins/bot/helpers/channels/deleteStageInstance.ts b/helpers/channels/deleteStageInstance.ts similarity index 86% rename from plugins/bot/helpers/channels/deleteStageInstance.ts rename to helpers/channels/deleteStageInstance.ts index a88fb041a..8ba1e502a 100644 --- a/plugins/bot/helpers/channels/deleteStageInstance.ts +++ b/helpers/channels/deleteStageInstance.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Deletes the Stage instance. Requires the user to be a moderator of the Stage channel. */ export async function deleteStageInstance(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/channels/editChannel.ts b/helpers/channels/editChannel.ts similarity index 97% rename from plugins/bot/helpers/channels/editChannel.ts rename to helpers/channels/editChannel.ts index fb4ea914f..f70f780a6 100644 --- a/plugins/bot/helpers/channels/editChannel.ts +++ b/helpers/channels/editChannel.ts @@ -1,6 +1,7 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { Channel } from "../../transformers/channel.ts"; -import { ChannelTypes, DiscordChannel, VideoQualityModes } from "../../deps.ts"; +import { DiscordChannel } from "../../types/discord.ts"; +import { ChannelTypes, VideoQualityModes } from "../../types/shared.ts"; import { OverwriteReadable } from "./editChannelOverwrite.ts"; /** Update a channel's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */ diff --git a/plugins/bot/helpers/channels/editChannelOverwrite.ts b/helpers/channels/editChannelOverwrite.ts similarity index 90% rename from plugins/bot/helpers/channels/editChannelOverwrite.ts rename to helpers/channels/editChannelOverwrite.ts index 97385b265..c5cd60190 100644 --- a/plugins/bot/helpers/channels/editChannelOverwrite.ts +++ b/helpers/channels/editChannelOverwrite.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { OverwriteTypes, PermissionStrings } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { OverwriteTypes, PermissionStrings } from "../../types/shared.ts"; /** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function editChannelOverwrite( diff --git a/plugins/bot/helpers/channels/followChannel.ts b/helpers/channels/followChannel.ts similarity index 83% rename from plugins/bot/helpers/channels/followChannel.ts rename to helpers/channels/followChannel.ts index 5eb30a3be..d469a89f7 100644 --- a/plugins/bot/helpers/channels/followChannel.ts +++ b/helpers/channels/followChannel.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordFollowedChannel } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordFollowedChannel } from "../../types/discord.ts"; /** Follow a News Channel to send messages to a target channel. Requires the `MANAGE_WEBHOOKS` permission in the target channel. Returns the webhook id. */ export async function followChannel(bot: Bot, sourceChannelId: bigint, targetChannelId: bigint) { diff --git a/plugins/bot/helpers/channels/forums/createForumPost.ts b/helpers/channels/forums/createForumPost.ts similarity index 92% rename from plugins/bot/helpers/channels/forums/createForumPost.ts rename to helpers/channels/forums/createForumPost.ts index 948043741..0bafd8110 100644 --- a/plugins/bot/helpers/channels/forums/createForumPost.ts +++ b/helpers/channels/forums/createForumPost.ts @@ -1,7 +1,7 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordChannel, FileContent } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordChannel } from "../../../types/discord.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../../types/mod.ts"; import { Embed } from "../../../transformers/embed.ts"; -import { AllowedMentions, MessageComponents } from "../../../typings.ts"; /** Creates a new public thread from an existing message. Returns a thread channel. */ export async function createForumPost( diff --git a/plugins/bot/helpers/channels/forums/mod.ts b/helpers/channels/forums/mod.ts similarity index 100% rename from plugins/bot/helpers/channels/forums/mod.ts rename to helpers/channels/forums/mod.ts diff --git a/plugins/bot/helpers/channels/getChannel.ts b/helpers/channels/getChannel.ts similarity index 83% rename from plugins/bot/helpers/channels/getChannel.ts rename to helpers/channels/getChannel.ts index d07619d21..905f53f0f 100644 --- a/plugins/bot/helpers/channels/getChannel.ts +++ b/helpers/channels/getChannel.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel } from "../../types/discord.ts"; /** Fetches a single channel object from the api. */ export async function getChannel(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/channels/getChannelWebhooks.ts b/helpers/channels/getChannelWebhooks.ts similarity index 73% rename from plugins/bot/helpers/channels/getChannelWebhooks.ts rename to helpers/channels/getChannelWebhooks.ts index 85e98b5f7..961c40f8a 100644 --- a/plugins/bot/helpers/channels/getChannelWebhooks.ts +++ b/helpers/channels/getChannelWebhooks.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; /** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */ export async function getChannelWebhooks(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/channels/getChannels.ts b/helpers/channels/getChannels.ts similarity index 71% rename from plugins/bot/helpers/channels/getChannels.ts rename to helpers/channels/getChannels.ts index cffe8ce21..c75419631 100644 --- a/plugins/bot/helpers/channels/getChannels.ts +++ b/helpers/channels/getChannels.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordChannel } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel } from "../../types/discord.ts"; /** Returns a list of guild channel objects. */ export async function getChannels(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/channels/getPins.ts b/helpers/channels/getPins.ts similarity index 76% rename from plugins/bot/helpers/channels/getPins.ts rename to helpers/channels/getPins.ts index 7b07422ef..3da7a30cb 100644 --- a/plugins/bot/helpers/channels/getPins.ts +++ b/helpers/channels/getPins.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; /** Get pinned messages in this channel. */ export async function getPins(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/channels/getStageInstance.ts b/helpers/channels/getStageInstance.ts similarity index 77% rename from plugins/bot/helpers/channels/getStageInstance.ts rename to helpers/channels/getStageInstance.ts index e2d8b86b2..d2f6ae5af 100644 --- a/plugins/bot/helpers/channels/getStageInstance.ts +++ b/helpers/channels/getStageInstance.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordStageInstance } from "../../types/discord.ts"; /** Gets the stage instance associated with the Stage channel, if it exists. */ export async function getStageInstance(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/channels/mod.ts b/helpers/channels/mod.ts similarity index 100% rename from plugins/bot/helpers/channels/mod.ts rename to helpers/channels/mod.ts diff --git a/plugins/bot/helpers/channels/startTyping.ts b/helpers/channels/startTyping.ts similarity index 92% rename from plugins/bot/helpers/channels/startTyping.ts rename to helpers/channels/startTyping.ts index 4cc968a3c..75bc313e1 100644 --- a/plugins/bot/helpers/channels/startTyping.ts +++ b/helpers/channels/startTyping.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** * Trigger a typing indicator for the specified channel. Generally bots should **NOT** implement this route. diff --git a/plugins/bot/helpers/channels/swapChannels.ts b/helpers/channels/swapChannels.ts similarity index 96% rename from plugins/bot/helpers/channels/swapChannels.ts rename to helpers/channels/swapChannels.ts index f1c2a98c2..a9feef7d8 100644 --- a/plugins/bot/helpers/channels/swapChannels.ts +++ b/helpers/channels/swapChannels.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permission. Only channels to be modified are required. */ export async function swapChannels(bot: Bot, guildId: bigint, channelPositions: ModifyGuildChannelPositions[]) { diff --git a/plugins/bot/helpers/channels/threads/addToThread.ts b/helpers/channels/threads/addToThread.ts similarity index 87% rename from plugins/bot/helpers/channels/threads/addToThread.ts rename to helpers/channels/threads/addToThread.ts index 7dba82850..068159fdd 100644 --- a/plugins/bot/helpers/channels/threads/addToThread.ts +++ b/helpers/channels/threads/addToThread.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** Adds a user to a thread. Requires the ability to send messages in the thread. Requires the thread is not archived. */ export async function addToThread(bot: Bot, threadId: bigint, userId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/getActiveThreads.ts b/helpers/channels/threads/getActiveThreads.ts similarity index 80% rename from plugins/bot/helpers/channels/threads/getActiveThreads.ts rename to helpers/channels/threads/getActiveThreads.ts index 94621c298..aa4a9dd20 100644 --- a/plugins/bot/helpers/channels/threads/getActiveThreads.ts +++ b/helpers/channels/threads/getActiveThreads.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordListActiveThreads } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordListActiveThreads } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Returns all active threads in the guild, including public and private threads. Threads are ordered by their `id`, in descending order. */ export async function getActiveThreads(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/getArchivedThreads.ts b/helpers/channels/threads/getArchivedThreads.ts similarity index 88% rename from plugins/bot/helpers/channels/threads/getArchivedThreads.ts rename to helpers/channels/threads/getArchivedThreads.ts index d5f1285ae..1c542a71b 100644 --- a/plugins/bot/helpers/channels/threads/getArchivedThreads.ts +++ b/helpers/channels/threads/getArchivedThreads.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../../util/collection.ts"; -import { Bot } from "../../../bot.ts"; -import { DiscordListArchivedThreads } from "../../../deps.ts"; +import { Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordListArchivedThreads } from "../../../types/discord.ts"; /** Get the archived threads for this channel, defaults to public */ export async function getArchivedThreads( diff --git a/plugins/bot/helpers/channels/threads/getThreadMember.ts b/helpers/channels/threads/getThreadMember.ts similarity index 83% rename from plugins/bot/helpers/channels/threads/getThreadMember.ts rename to helpers/channels/threads/getThreadMember.ts index 7feac1588..091b8db9d 100644 --- a/plugins/bot/helpers/channels/threads/getThreadMember.ts +++ b/helpers/channels/threads/getThreadMember.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordThreadMember } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordThreadMember } from "../../../types/discord.ts"; /** Returns thread members objects that are members of the thread. */ export async function getThreadMember(bot: Bot, threadId: bigint, userId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/getThreadMembers.ts b/helpers/channels/threads/getThreadMembers.ts similarity index 72% rename from plugins/bot/helpers/channels/threads/getThreadMembers.ts rename to helpers/channels/threads/getThreadMembers.ts index 1950dcc63..efd84fbb8 100644 --- a/plugins/bot/helpers/channels/threads/getThreadMembers.ts +++ b/helpers/channels/threads/getThreadMembers.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordThreadMember } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordThreadMember } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Returns thread members objects that are members of the thread. */ export async function getThreadMembers(bot: Bot, threadId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/joinThread.ts b/helpers/channels/threads/joinThread.ts similarity index 84% rename from plugins/bot/helpers/channels/threads/joinThread.ts rename to helpers/channels/threads/joinThread.ts index 9cfb89744..785444196 100644 --- a/plugins/bot/helpers/channels/threads/joinThread.ts +++ b/helpers/channels/threads/joinThread.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** Adds the bot to the thread. Cannot join an archived thread. */ export async function joinThread(bot: Bot, threadId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/leaveThread.ts b/helpers/channels/threads/leaveThread.ts similarity index 84% rename from plugins/bot/helpers/channels/threads/leaveThread.ts rename to helpers/channels/threads/leaveThread.ts index a2ff845bb..f4ed15f6a 100644 --- a/plugins/bot/helpers/channels/threads/leaveThread.ts +++ b/helpers/channels/threads/leaveThread.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** Removes the bot from a thread. Requires the thread is not archived. */ export async function leaveThread(bot: Bot, threadId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/mod.ts b/helpers/channels/threads/mod.ts similarity index 100% rename from plugins/bot/helpers/channels/threads/mod.ts rename to helpers/channels/threads/mod.ts diff --git a/plugins/bot/helpers/channels/threads/removeThreadMember.ts b/helpers/channels/threads/removeThreadMember.ts similarity index 89% rename from plugins/bot/helpers/channels/threads/removeThreadMember.ts rename to helpers/channels/threads/removeThreadMember.ts index c7a608530..7359a9cb9 100644 --- a/plugins/bot/helpers/channels/threads/removeThreadMember.ts +++ b/helpers/channels/threads/removeThreadMember.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** Removes a user from a thread. Requires the MANAGE_THREADS permission or that you are the creator of the thread. Also requires the thread is not archived. */ export async function removeThreadMember(bot: Bot, threadId: bigint, userId: bigint) { diff --git a/plugins/bot/helpers/channels/threads/startThreadWithMessage.ts b/helpers/channels/threads/startThreadWithMessage.ts similarity index 90% rename from plugins/bot/helpers/channels/threads/startThreadWithMessage.ts rename to helpers/channels/threads/startThreadWithMessage.ts index 9d464fc98..7dcaf52e2 100644 --- a/plugins/bot/helpers/channels/threads/startThreadWithMessage.ts +++ b/helpers/channels/threads/startThreadWithMessage.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordChannel } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordChannel } from "../../../types/discord.ts"; /** Creates a new public thread from an existing message. Returns a thread channel. */ export async function startThreadWithMessage( diff --git a/plugins/bot/helpers/channels/threads/startThreadWithoutMessage.ts b/helpers/channels/threads/startThreadWithoutMessage.ts similarity index 88% rename from plugins/bot/helpers/channels/threads/startThreadWithoutMessage.ts rename to helpers/channels/threads/startThreadWithoutMessage.ts index 3bf45cd6c..4b54a6888 100644 --- a/plugins/bot/helpers/channels/threads/startThreadWithoutMessage.ts +++ b/helpers/channels/threads/startThreadWithoutMessage.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../../bot.ts"; -import { ChannelTypes, DiscordChannel } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordChannel } from "../../../types/discord.ts"; +import { ChannelTypes } from "../../../types/shared.ts"; /** Creates a new private thread. Returns a thread channel. */ export async function startThreadWithoutMessage(bot: Bot, channelId: bigint, options: StartThreadWithoutMessage) { diff --git a/plugins/bot/helpers/channels/updateStageInstance.ts b/helpers/channels/updateStageInstance.ts similarity index 75% rename from plugins/bot/helpers/channels/updateStageInstance.ts rename to helpers/channels/updateStageInstance.ts index 0723c4818..e283ef192 100644 --- a/plugins/bot/helpers/channels/updateStageInstance.ts +++ b/helpers/channels/updateStageInstance.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { AtLeastOne, DiscordStageInstance } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordStageInstance } from "../../types/discord.ts"; +import { AtLeastOne } from "../../types/shared.ts"; /** Updates fields of an existing Stage instance. Requires the user to be a moderator of the Stage channel. */ export async function updateStageInstance( diff --git a/plugins/bot/helpers/channels/updateVoiceState.ts b/helpers/channels/updateVoiceState.ts similarity index 98% rename from plugins/bot/helpers/channels/updateVoiceState.ts rename to helpers/channels/updateVoiceState.ts index 1252d53fb..01f952473 100644 --- a/plugins/bot/helpers/channels/updateVoiceState.ts +++ b/helpers/channels/updateVoiceState.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** * Updates the bot's voice state diff --git a/plugins/bot/helpers/discovery/addDiscoverySubcategory.ts b/helpers/discovery/addDiscoverySubcategory.ts similarity index 74% rename from plugins/bot/helpers/discovery/addDiscoverySubcategory.ts rename to helpers/discovery/addDiscoverySubcategory.ts index 65d734002..858ac2cab 100644 --- a/plugins/bot/helpers/discovery/addDiscoverySubcategory.ts +++ b/helpers/discovery/addDiscoverySubcategory.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordAddGuildDiscoverySubcategory } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordAddGuildDiscoverySubcategory } from "../../types/discord.ts"; /** Add a discovery subcategory to the guild. Requires the `MANAGE_GUILD` permission. */ export async function addDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) { diff --git a/plugins/bot/helpers/discovery/editDiscovery.ts b/helpers/discovery/editDiscovery.ts similarity index 93% rename from plugins/bot/helpers/discovery/editDiscovery.ts rename to helpers/discovery/editDiscovery.ts index 828bfbcc3..65d679546 100644 --- a/plugins/bot/helpers/discovery/editDiscovery.ts +++ b/helpers/discovery/editDiscovery.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordDiscoveryMetadata } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordDiscoveryMetadata } from "../../types/discord.ts"; /** Modify the discovery metadata for the guild. Requires the MANAGE_GUILD permission. Returns the updated discovery metadata object on success. */ export async function editDiscovery(bot: Bot, guildId: bigint, data: ModifyGuildDiscoveryMetadata) { diff --git a/plugins/bot/helpers/discovery/getDiscovery.ts b/helpers/discovery/getDiscovery.ts similarity index 88% rename from plugins/bot/helpers/discovery/getDiscovery.ts rename to helpers/discovery/getDiscovery.ts index 091452f65..38d2c8fa1 100644 --- a/plugins/bot/helpers/discovery/getDiscovery.ts +++ b/helpers/discovery/getDiscovery.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordDiscoveryMetadata } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordDiscoveryMetadata } from "../../types/discord.ts"; /** Returns the discovery metadata object for the guild. Requires the `MANAGE_GUILD` permission. */ export async function getDiscovery(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/discovery/getDiscoveryCategories.ts b/helpers/discovery/getDiscoveryCategories.ts similarity index 74% rename from plugins/bot/helpers/discovery/getDiscoveryCategories.ts rename to helpers/discovery/getDiscoveryCategories.ts index dbffb323a..8bc2ac5e3 100644 --- a/plugins/bot/helpers/discovery/getDiscoveryCategories.ts +++ b/helpers/discovery/getDiscoveryCategories.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordDiscoveryCategory } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordDiscoveryCategory } from "../../types/discord.ts"; /** Returns a Collection (mapped by Id of the discovery category object) of discovery category objects that can be used when editing guilds */ export async function getDiscoveryCategories(bot: Bot) { diff --git a/plugins/bot/helpers/discovery/mod.ts b/helpers/discovery/mod.ts similarity index 100% rename from plugins/bot/helpers/discovery/mod.ts rename to helpers/discovery/mod.ts diff --git a/plugins/bot/helpers/discovery/removeDiscoverySubcategory.ts b/helpers/discovery/removeDiscoverySubcategory.ts similarity index 90% rename from plugins/bot/helpers/discovery/removeDiscoverySubcategory.ts rename to helpers/discovery/removeDiscoverySubcategory.ts index 2b2db0cdd..6837ed79e 100644 --- a/plugins/bot/helpers/discovery/removeDiscoverySubcategory.ts +++ b/helpers/discovery/removeDiscoverySubcategory.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Removes a discovery subcategory from the guild. Requires the MANAGE_GUILD permission. Returns a 204 No Content on success. */ export async function removeDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) { diff --git a/plugins/bot/helpers/discovery/validDiscoveryTerm.ts b/helpers/discovery/validDiscoveryTerm.ts similarity index 68% rename from plugins/bot/helpers/discovery/validDiscoveryTerm.ts rename to helpers/discovery/validDiscoveryTerm.ts index 24b783bc4..f34833809 100644 --- a/plugins/bot/helpers/discovery/validDiscoveryTerm.ts +++ b/helpers/discovery/validDiscoveryTerm.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordValidateDiscoverySearchTerm } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordValidateDiscoverySearchTerm } from "../../types/discord.ts"; export async function validDiscoveryTerm(bot: Bot, term: string) { const result = await bot.rest.runMethod( diff --git a/plugins/bot/helpers/emojis/createEmoji.ts b/helpers/emojis/createEmoji.ts similarity index 92% rename from plugins/bot/helpers/emojis/createEmoji.ts rename to helpers/emojis/createEmoji.ts index b5ea32af8..a94d56d5f 100644 --- a/plugins/bot/helpers/emojis/createEmoji.ts +++ b/helpers/emojis/createEmoji.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordEmoji } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordEmoji } from "../../types/discord.ts"; /** Create an emoji in the server */ export async function createEmoji(bot: Bot, guildId: bigint, options: CreateGuildEmoji) { diff --git a/plugins/bot/helpers/emojis/deleteEmoji.ts b/helpers/emojis/deleteEmoji.ts similarity index 88% rename from plugins/bot/helpers/emojis/deleteEmoji.ts rename to helpers/emojis/deleteEmoji.ts index 67e9f23de..c03982adc 100644 --- a/plugins/bot/helpers/emojis/deleteEmoji.ts +++ b/helpers/emojis/deleteEmoji.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. */ export async function deleteEmoji(bot: Bot, guildId: bigint, id: bigint, reason?: string) { diff --git a/plugins/bot/helpers/emojis/editEmoji.ts b/helpers/emojis/editEmoji.ts similarity index 88% rename from plugins/bot/helpers/emojis/editEmoji.ts rename to helpers/emojis/editEmoji.ts index 599036b8a..6bee65478 100644 --- a/plugins/bot/helpers/emojis/editEmoji.ts +++ b/helpers/emojis/editEmoji.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordEmoji } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordEmoji } from "../../types/discord.ts"; /** Modify the given emoji. Requires the MANAGE_EMOJIS permission. */ export async function editEmoji(bot: Bot, guildId: bigint, id: bigint, options: ModifyGuildEmoji) { diff --git a/plugins/bot/helpers/emojis/emojiUrl.ts b/helpers/emojis/emojiUrl.ts similarity index 100% rename from plugins/bot/helpers/emojis/emojiUrl.ts rename to helpers/emojis/emojiUrl.ts diff --git a/plugins/bot/helpers/emojis/getEmoji.ts b/helpers/emojis/getEmoji.ts similarity index 77% rename from plugins/bot/helpers/emojis/getEmoji.ts rename to helpers/emojis/getEmoji.ts index b005e1bb5..f96c1cecc 100644 --- a/plugins/bot/helpers/emojis/getEmoji.ts +++ b/helpers/emojis/getEmoji.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordEmoji } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordEmoji } from "../../types/discord.ts"; /** * Returns an emoji for the given guild and emoji Id. diff --git a/plugins/bot/helpers/emojis/getEmojis.ts b/helpers/emojis/getEmojis.ts similarity index 70% rename from plugins/bot/helpers/emojis/getEmojis.ts rename to helpers/emojis/getEmojis.ts index 2caa39529..c51529cc1 100644 --- a/plugins/bot/helpers/emojis/getEmojis.ts +++ b/helpers/emojis/getEmojis.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordEmoji } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordEmoji } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; /** * Returns a list of emojis for the given guild. diff --git a/plugins/bot/helpers/emojis/mod.ts b/helpers/emojis/mod.ts similarity index 100% rename from plugins/bot/helpers/emojis/mod.ts rename to helpers/emojis/mod.ts diff --git a/plugins/bot/helpers/guilds/automod/createAutomodRule.ts b/helpers/guilds/automod/createAutomodRule.ts similarity index 98% rename from plugins/bot/helpers/guilds/automod/createAutomodRule.ts rename to helpers/guilds/automod/createAutomodRule.ts index 72bf9d3ea..bc6b3d06d 100644 --- a/plugins/bot/helpers/guilds/automod/createAutomodRule.ts +++ b/helpers/guilds/automod/createAutomodRule.ts @@ -5,7 +5,7 @@ import { AutoModerationTriggerTypes, DiscordAutoModerationRule, DiscordAutoModerationRuleTriggerMetadataPresets, -} from "../../../deps.ts"; +} from "../../../types/discord.ts"; /** Get a rule currently configured for guild. */ export async function createAutomodRule(bot: Bot, guildId: bigint, options: CreateAutoModerationRuleOptions) { diff --git a/plugins/bot/helpers/guilds/automod/deleteAutomodRule.ts b/helpers/guilds/automod/deleteAutomodRule.ts similarity index 100% rename from plugins/bot/helpers/guilds/automod/deleteAutomodRule.ts rename to helpers/guilds/automod/deleteAutomodRule.ts diff --git a/plugins/bot/helpers/guilds/automod/editAutomodRule.ts b/helpers/guilds/automod/editAutomodRule.ts similarity index 98% rename from plugins/bot/helpers/guilds/automod/editAutomodRule.ts rename to helpers/guilds/automod/editAutomodRule.ts index d962f41d6..04b522498 100644 --- a/plugins/bot/helpers/guilds/automod/editAutomodRule.ts +++ b/helpers/guilds/automod/editAutomodRule.ts @@ -4,7 +4,7 @@ import { AutoModerationEventTypes, DiscordAutoModerationRule, DiscordAutoModerationRuleTriggerMetadataPresets, -} from "../../../deps.ts"; +} from "../../../types/discord.ts"; /** Edit a rule currently configured for guild. */ export async function editAutomodRule(bot: Bot, guildId: bigint, options: Partial) { diff --git a/plugins/bot/helpers/guilds/automod/getAutomodRule.ts b/helpers/guilds/automod/getAutomodRule.ts similarity index 73% rename from plugins/bot/helpers/guilds/automod/getAutomodRule.ts rename to helpers/guilds/automod/getAutomodRule.ts index d10a40a87..51aecf9a6 100644 --- a/plugins/bot/helpers/guilds/automod/getAutomodRule.ts +++ b/helpers/guilds/automod/getAutomodRule.ts @@ -1,6 +1,6 @@ import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationRule } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import { DiscordAutoModerationRule } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Get a rule currently configured for guild. */ export async function getAutomodRule(bot: Bot, guildId: bigint, ruleId: bigint) { diff --git a/plugins/bot/helpers/guilds/automod/getAutomodRules.ts b/helpers/guilds/automod/getAutomodRules.ts similarity index 76% rename from plugins/bot/helpers/guilds/automod/getAutomodRules.ts rename to helpers/guilds/automod/getAutomodRules.ts index a6605e2d8..882d504e3 100644 --- a/plugins/bot/helpers/guilds/automod/getAutomodRules.ts +++ b/helpers/guilds/automod/getAutomodRules.ts @@ -1,6 +1,6 @@ import { Bot } from "../../../bot.ts"; -import { DiscordAutoModerationRule } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import { DiscordAutoModerationRule } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Get a list of all rules currently configured for guild. */ export async function getAutomodRules(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/automod/mod.ts b/helpers/guilds/automod/mod.ts similarity index 100% rename from plugins/bot/helpers/guilds/automod/mod.ts rename to helpers/guilds/automod/mod.ts diff --git a/plugins/bot/helpers/guilds/createGuild.ts b/helpers/guilds/createGuild.ts similarity index 94% rename from plugins/bot/helpers/guilds/createGuild.ts rename to helpers/guilds/createGuild.ts index f169786dc..39084574c 100644 --- a/plugins/bot/helpers/guilds/createGuild.ts +++ b/helpers/guilds/createGuild.ts @@ -1,13 +1,13 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { Channel } from "../../transformers/channel.ts"; import { Role } from "../../transformers/role.ts"; +import { DiscordGuild } from "../../types/discord.ts"; import { DefaultMessageNotificationLevels, - DiscordGuild, ExplicitContentFilterLevels, SystemChannelFlags, VerificationLevels, -} from "../../deps.ts"; +} from "../../types/shared.ts"; /** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */ export async function createGuild(bot: Bot, options: CreateGuild) { diff --git a/plugins/bot/helpers/guilds/deleteGuild.ts b/helpers/guilds/deleteGuild.ts similarity index 87% rename from plugins/bot/helpers/guilds/deleteGuild.ts rename to helpers/guilds/deleteGuild.ts index e49a4026d..98b083815 100644 --- a/plugins/bot/helpers/guilds/deleteGuild.ts +++ b/helpers/guilds/deleteGuild.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ export async function deleteGuild(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/editGuild.ts b/helpers/guilds/editGuild.ts similarity index 96% rename from plugins/bot/helpers/guilds/editGuild.ts rename to helpers/guilds/editGuild.ts index 45207871d..8017b6c0e 100644 --- a/plugins/bot/helpers/guilds/editGuild.ts +++ b/helpers/guilds/editGuild.ts @@ -1,12 +1,12 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuild } from "../../types/discord.ts"; import { DefaultMessageNotificationLevels, - DiscordGuild, ExplicitContentFilterLevels, GuildFeatures, SystemChannelFlags, VerificationLevels, -} from "../../deps.ts"; +} from "../../types/shared.ts"; /** Modify a guilds settings. Requires the MANAGE_GUILD permission. */ export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild, shardId: number) { diff --git a/plugins/bot/helpers/guilds/editWelcomeScreen.ts b/helpers/guilds/editWelcomeScreen.ts similarity index 93% rename from plugins/bot/helpers/guilds/editWelcomeScreen.ts rename to helpers/guilds/editWelcomeScreen.ts index 735af6887..aabb30645 100644 --- a/plugins/bot/helpers/guilds/editWelcomeScreen.ts +++ b/helpers/guilds/editWelcomeScreen.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWelcomeScreen } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWelcomeScreen } from "../../types/discord.ts"; export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: ModifyGuildWelcomeScreen) { const result = await bot.rest.runMethod( diff --git a/plugins/bot/helpers/guilds/editWidget.ts b/helpers/guilds/editWidget.ts similarity index 80% rename from plugins/bot/helpers/guilds/editWidget.ts rename to helpers/guilds/editWidget.ts index 91ba54eb7..dea1df89b 100644 --- a/plugins/bot/helpers/guilds/editWidget.ts +++ b/helpers/guilds/editWidget.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuildWidgetSettings } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuildWidgetSettings } from "../../types/discord.ts"; /** Modify a guild widget object for the guild. Requires the MANAGE_GUILD permission. */ export async function editWidget(bot: Bot, guildId: bigint, enabled: boolean, channelId?: string | null) { diff --git a/plugins/bot/helpers/guilds/getAuditLogs.ts b/helpers/guilds/getAuditLogs.ts similarity index 94% rename from plugins/bot/helpers/guilds/getAuditLogs.ts rename to helpers/guilds/getAuditLogs.ts index d7ae954c4..157b69271 100644 --- a/plugins/bot/helpers/guilds/getAuditLogs.ts +++ b/helpers/guilds/getAuditLogs.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { AuditLogEvents, DiscordAuditLog } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordAuditLog } from "../../types/discord.ts"; +import { AuditLogEvents } from "../../types/shared.ts"; /** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */ export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) { diff --git a/plugins/bot/helpers/guilds/getAvailableVoiceRegions.ts b/helpers/guilds/getAvailableVoiceRegions.ts similarity index 74% rename from plugins/bot/helpers/guilds/getAvailableVoiceRegions.ts rename to helpers/guilds/getAvailableVoiceRegions.ts index a52f6e01b..91a6a1cf2 100644 --- a/plugins/bot/helpers/guilds/getAvailableVoiceRegions.ts +++ b/helpers/guilds/getAvailableVoiceRegions.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordVoiceRegion } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordVoiceRegion } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; /** Returns an array of voice regions that can be used when creating servers. */ export async function getAvailableVoiceRegions(bot: Bot) { diff --git a/plugins/bot/helpers/guilds/getBan.ts b/helpers/guilds/getBan.ts similarity index 83% rename from plugins/bot/helpers/guilds/getBan.ts rename to helpers/guilds/getBan.ts index 89b6f811b..0a53886a8 100644 --- a/plugins/bot/helpers/guilds/getBan.ts +++ b/helpers/guilds/getBan.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordBan } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordBan } from "../../types/discord.ts"; /** Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission. */ export async function getBan(bot: Bot, guildId: bigint, memberId: bigint) { diff --git a/plugins/bot/helpers/guilds/getBans.ts b/helpers/guilds/getBans.ts similarity index 85% rename from plugins/bot/helpers/guilds/getBans.ts rename to helpers/guilds/getBans.ts index af87b43a8..9c3268e8f 100644 --- a/plugins/bot/helpers/guilds/getBans.ts +++ b/helpers/guilds/getBans.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; -import { DiscordBan } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { Collection } from "../../util/collection.ts"; +import { DiscordBan } from "../../types/discord.ts"; import { User } from "../../transformers/member.ts"; /** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */ diff --git a/plugins/bot/helpers/guilds/getGuild.ts b/helpers/guilds/getGuild.ts similarity index 87% rename from plugins/bot/helpers/guilds/getGuild.ts rename to helpers/guilds/getGuild.ts index 6cd906d7a..3f4ca137e 100644 --- a/plugins/bot/helpers/guilds/getGuild.ts +++ b/helpers/guilds/getGuild.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuild } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuild } from "../../types/discord.ts"; /** * This function fetches a guild's data. This is not the same data as a GUILD_CREATE. diff --git a/plugins/bot/helpers/guilds/getGuildPreview.ts b/helpers/guilds/getGuildPreview.ts similarity index 90% rename from plugins/bot/helpers/guilds/getGuildPreview.ts rename to helpers/guilds/getGuildPreview.ts index 54e4c2844..3d84abce9 100644 --- a/plugins/bot/helpers/guilds/getGuildPreview.ts +++ b/helpers/guilds/getGuildPreview.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuildPreview } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuildPreview } from "../../types/discord.ts"; /** Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. */ export async function getGuildPreview(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/getPruneCount.ts b/helpers/guilds/getPruneCount.ts similarity index 95% rename from plugins/bot/helpers/guilds/getPruneCount.ts rename to helpers/guilds/getPruneCount.ts index 1f9ee3097..e22901124 100644 --- a/plugins/bot/helpers/guilds/getPruneCount.ts +++ b/helpers/guilds/getPruneCount.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission */ export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuildPruneCountQuery) { diff --git a/plugins/bot/helpers/guilds/getVanityUrl.ts b/helpers/guilds/getVanityUrl.ts similarity index 80% rename from plugins/bot/helpers/guilds/getVanityUrl.ts rename to helpers/guilds/getVanityUrl.ts index 66cccf012..faeb02bed 100644 --- a/plugins/bot/helpers/guilds/getVanityUrl.ts +++ b/helpers/guilds/getVanityUrl.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordInviteMetadata } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInviteMetadata } from "../../types/discord.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. */ export async function getVanityUrl(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/getVoiceRegions.ts b/helpers/guilds/getVoiceRegions.ts similarity index 76% rename from plugins/bot/helpers/guilds/getVoiceRegions.ts rename to helpers/guilds/getVoiceRegions.ts index b889e97a7..490cb91af 100644 --- a/plugins/bot/helpers/guilds/getVoiceRegions.ts +++ b/helpers/guilds/getVoiceRegions.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordVoiceRegion } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordVoiceRegion } from "../../types/discord.ts"; /** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */ export async function getVoiceRegions(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/getWelcomeScreen.ts b/helpers/guilds/getWelcomeScreen.ts similarity index 78% rename from plugins/bot/helpers/guilds/getWelcomeScreen.ts rename to helpers/guilds/getWelcomeScreen.ts index e7a984b89..d6c7aecd7 100644 --- a/plugins/bot/helpers/guilds/getWelcomeScreen.ts +++ b/helpers/guilds/getWelcomeScreen.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWelcomeScreen } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWelcomeScreen } from "../../types/discord.ts"; /** Returns the Welcome Screen object for the guild. Requires the `MANAGE_GUILD` permission. */ export async function getWelcomeScreen(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/getWidget.ts b/helpers/guilds/getWidget.ts similarity index 74% rename from plugins/bot/helpers/guilds/getWidget.ts rename to helpers/guilds/getWidget.ts index 611852ee0..e96bc7fad 100644 --- a/plugins/bot/helpers/guilds/getWidget.ts +++ b/helpers/guilds/getWidget.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuildWidget } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuildWidget } from "../../types/discord.ts"; /** Returns the widget for the guild. */ export async function getWidget(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/getWidgetImageUrl.ts b/helpers/guilds/getWidgetImageUrl.ts similarity index 96% rename from plugins/bot/helpers/guilds/getWidgetImageUrl.ts rename to helpers/guilds/getWidgetImageUrl.ts index 64c4b0d56..75dd6e385 100644 --- a/plugins/bot/helpers/guilds/getWidgetImageUrl.ts +++ b/helpers/guilds/getWidgetImageUrl.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Returns the widget image URL for the guild. */ export async function getWidgetImageURL(bot: Bot, guildId: bigint, options?: GetGuildWidgetImageQuery) { diff --git a/plugins/bot/helpers/guilds/getWidgetSettings.ts b/helpers/guilds/getWidgetSettings.ts similarity index 76% rename from plugins/bot/helpers/guilds/getWidgetSettings.ts rename to helpers/guilds/getWidgetSettings.ts index 93b868293..caacdadb2 100644 --- a/plugins/bot/helpers/guilds/getWidgetSettings.ts +++ b/helpers/guilds/getWidgetSettings.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuildWidgetSettings } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuildWidgetSettings } from "../../types/discord.ts"; /** Returns a guild widget settings object. Requires the MANAGE_GUILD permission. */ export async function getWidgetSettings(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/guildBannerUrl.ts b/helpers/guilds/guildBannerUrl.ts similarity index 93% rename from plugins/bot/helpers/guilds/guildBannerUrl.ts rename to helpers/guilds/guildBannerUrl.ts index 1d9418f2d..b00340dd3 100644 --- a/plugins/bot/helpers/guilds/guildBannerUrl.ts +++ b/helpers/guilds/guildBannerUrl.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { ImageFormat, ImageSize } from "../members/avatarUrl.ts"; /** The full URL of the banner from Discords CDN. Undefined if no banner is set. */ diff --git a/plugins/bot/helpers/guilds/guildIconUrl.ts b/helpers/guilds/guildIconUrl.ts similarity index 93% rename from plugins/bot/helpers/guilds/guildIconUrl.ts rename to helpers/guilds/guildIconUrl.ts index 5f97329b4..16d7686ad 100644 --- a/plugins/bot/helpers/guilds/guildIconUrl.ts +++ b/helpers/guilds/guildIconUrl.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { ImageFormat, ImageSize } from "../members/avatarUrl.ts"; /** The full URL of the icon from Discords CDN. Undefined when no icon is set. */ diff --git a/plugins/bot/helpers/guilds/guildSplashUrl.ts b/helpers/guilds/guildSplashUrl.ts similarity index 93% rename from plugins/bot/helpers/guilds/guildSplashUrl.ts rename to helpers/guilds/guildSplashUrl.ts index 82f6e01d4..aaa9114be 100644 --- a/plugins/bot/helpers/guilds/guildSplashUrl.ts +++ b/helpers/guilds/guildSplashUrl.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { ImageFormat, ImageSize } from "../members/avatarUrl.ts"; /** The full URL of the splash from Discords CDN. Undefined if no splash is set. */ diff --git a/plugins/bot/helpers/guilds/leaveGuild.ts b/helpers/guilds/leaveGuild.ts similarity index 82% rename from plugins/bot/helpers/guilds/leaveGuild.ts rename to helpers/guilds/leaveGuild.ts index 008117420..1d998af1b 100644 --- a/plugins/bot/helpers/guilds/leaveGuild.ts +++ b/helpers/guilds/leaveGuild.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Leave a guild */ export async function leaveGuild(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/guilds/mod.ts b/helpers/guilds/mod.ts similarity index 100% rename from plugins/bot/helpers/guilds/mod.ts rename to helpers/guilds/mod.ts diff --git a/plugins/bot/helpers/guilds/scheduledEvents/createScheduledEvent.ts b/helpers/guilds/scheduledEvents/createScheduledEvent.ts similarity index 94% rename from plugins/bot/helpers/guilds/scheduledEvents/createScheduledEvent.ts rename to helpers/guilds/scheduledEvents/createScheduledEvent.ts index 73b42dcc5..2407f6a0c 100644 --- a/plugins/bot/helpers/guilds/scheduledEvents/createScheduledEvent.ts +++ b/helpers/guilds/scheduledEvents/createScheduledEvent.ts @@ -1,5 +1,6 @@ import { Bot } from "../../../bot.ts"; -import { DiscordScheduledEvent, ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../deps.ts"; +import { DiscordScheduledEvent } from "../../../types/discord.ts"; +import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../types/shared.ts"; /** Create a guild scheduled event in the guild. A guild can have a maximum of 100 events with `SCHEDULED` or `ACTIVE` status at any time. */ export async function createScheduledEvent(bot: Bot, guildId: bigint, options: CreateScheduledEvent) { diff --git a/plugins/bot/helpers/guilds/scheduledEvents/deleteScheduledEvent.ts b/helpers/guilds/scheduledEvents/deleteScheduledEvent.ts similarity index 100% rename from plugins/bot/helpers/guilds/scheduledEvents/deleteScheduledEvent.ts rename to helpers/guilds/scheduledEvents/deleteScheduledEvent.ts diff --git a/plugins/bot/helpers/guilds/scheduledEvents/editScheduledEvent.ts b/helpers/guilds/scheduledEvents/editScheduledEvent.ts similarity index 93% rename from plugins/bot/helpers/guilds/scheduledEvents/editScheduledEvent.ts rename to helpers/guilds/scheduledEvents/editScheduledEvent.ts index 19e36b08d..405d6034c 100644 --- a/plugins/bot/helpers/guilds/scheduledEvents/editScheduledEvent.ts +++ b/helpers/guilds/scheduledEvents/editScheduledEvent.ts @@ -1,10 +1,6 @@ import { Bot } from "../../../bot.ts"; -import { - DiscordScheduledEvent, - ScheduledEventEntityType, - ScheduledEventPrivacyLevel, - ScheduledEventStatus, -} from "../../../deps.ts"; +import { DiscordScheduledEvent } from "../../../types/discord.ts"; +import { ScheduledEventEntityType, ScheduledEventPrivacyLevel, ScheduledEventStatus } from "../../../types/shared.ts"; /** Modify a guild scheduled event. To start or end an event, use this endpoint to modify the event's status. */ export async function editScheduledEvent( diff --git a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvent.ts b/helpers/guilds/scheduledEvents/getScheduledEvent.ts similarity index 87% rename from plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvent.ts rename to helpers/guilds/scheduledEvents/getScheduledEvent.ts index c01fbd331..ba43b6b89 100644 --- a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvent.ts +++ b/helpers/guilds/scheduledEvents/getScheduledEvent.ts @@ -1,5 +1,5 @@ import { Bot } from "../../../bot.ts"; -import { DiscordScheduledEvent } from "../../../deps.ts"; +import { DiscordScheduledEvent } from "../../../types/discord.ts"; /** Get a guild scheduled event. */ export async function getScheduledEvent( diff --git a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEventUsers.ts b/helpers/guilds/scheduledEvents/getScheduledEventUsers.ts similarity index 94% rename from plugins/bot/helpers/guilds/scheduledEvents/getScheduledEventUsers.ts rename to helpers/guilds/scheduledEvents/getScheduledEventUsers.ts index 32f287d64..6fdb1c202 100644 --- a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEventUsers.ts +++ b/helpers/guilds/scheduledEvents/getScheduledEventUsers.ts @@ -1,7 +1,7 @@ import { Bot } from "../../../bot.ts"; import { Member, User } from "../../../transformers/member.ts"; -import { DiscordMember, DiscordUser } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import { DiscordMember, DiscordUser } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; export async function getScheduledEventUsers( bot: Bot, diff --git a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvents.ts b/helpers/guilds/scheduledEvents/getScheduledEvents.ts similarity index 85% rename from plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvents.ts rename to helpers/guilds/scheduledEvents/getScheduledEvents.ts index f02c63cd6..69d35bc47 100644 --- a/plugins/bot/helpers/guilds/scheduledEvents/getScheduledEvents.ts +++ b/helpers/guilds/scheduledEvents/getScheduledEvents.ts @@ -1,7 +1,7 @@ import { Bot } from "../../../bot.ts"; import { ScheduledEvent } from "../../../transformers/scheduledEvent.ts"; -import { DiscordScheduledEvent } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import { DiscordScheduledEvent } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Get a list of guild scheduled event for the given guild. */ export async function getScheduledEvents(bot: Bot, guildId: bigint, options?: GetScheduledEvents) { diff --git a/plugins/bot/helpers/guilds/scheduledEvents/mod.ts b/helpers/guilds/scheduledEvents/mod.ts similarity index 100% rename from plugins/bot/helpers/guilds/scheduledEvents/mod.ts rename to helpers/guilds/scheduledEvents/mod.ts diff --git a/plugins/bot/helpers/integrations/deleteIntegration.ts b/helpers/integrations/deleteIntegration.ts similarity index 88% rename from plugins/bot/helpers/integrations/deleteIntegration.ts rename to helpers/integrations/deleteIntegration.ts index 07647114a..19d0cb431 100644 --- a/plugins/bot/helpers/integrations/deleteIntegration.ts +++ b/helpers/integrations/deleteIntegration.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) { diff --git a/plugins/bot/helpers/integrations/getIntegrations.ts b/helpers/integrations/getIntegrations.ts similarity index 86% rename from plugins/bot/helpers/integrations/getIntegrations.ts rename to helpers/integrations/getIntegrations.ts index e20e126f9..b244a347a 100644 --- a/plugins/bot/helpers/integrations/getIntegrations.ts +++ b/helpers/integrations/getIntegrations.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; -import { DiscordIntegration } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { Collection } from "../../util/collection.ts"; +import { DiscordIntegration } from "../../types/discord.ts"; /** Returns a list of integrations for the guild. Requires the MANAGE_GUILD permission. */ export async function getIntegrations(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/integrations/mod.ts b/helpers/integrations/mod.ts similarity index 100% rename from plugins/bot/helpers/integrations/mod.ts rename to helpers/integrations/mod.ts diff --git a/plugins/bot/helpers/interactions/commands/createApplicationCommand.ts b/helpers/interactions/commands/createApplicationCommand.ts similarity index 93% rename from plugins/bot/helpers/interactions/commands/createApplicationCommand.ts rename to helpers/interactions/commands/createApplicationCommand.ts index 81610c048..e8109238e 100644 --- a/plugins/bot/helpers/interactions/commands/createApplicationCommand.ts +++ b/helpers/interactions/commands/createApplicationCommand.ts @@ -1,13 +1,7 @@ -import { Bot } from "../../../bot.ts"; -import { - ApplicationCommandTypes, - AtLeastOne, - DiscordApplicationCommand, - DiscordApplicationCommandOption, - Localization, - PermissionStrings, -} from "../../../deps.ts"; -import { ApplicationCommandOption } from "../../../transformers/applicationCommandOption.ts"; +import type { Bot } from "../../../bot.ts"; +import { ApplicationCommandOption, ApplicationCommandTypes, Localization } from "../../../mod.ts"; +import { DiscordApplicationCommand, DiscordApplicationCommandOption } from "../../../types/discord.ts"; +import { AtLeastOne, PermissionStrings } from "../../../types/shared.ts"; /** * There are two kinds of Application Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means: diff --git a/plugins/bot/helpers/interactions/commands/deleteApplicationCommand.ts b/helpers/interactions/commands/deleteApplicationCommand.ts similarity index 89% rename from plugins/bot/helpers/interactions/commands/deleteApplicationCommand.ts rename to helpers/interactions/commands/deleteApplicationCommand.ts index d40e3714c..ea4fe49c4 100644 --- a/plugins/bot/helpers/interactions/commands/deleteApplicationCommand.ts +++ b/helpers/interactions/commands/deleteApplicationCommand.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** Deletes a application command. */ export async function deleteApplicationCommand(bot: Bot, id: bigint, guildId?: bigint) { diff --git a/plugins/bot/helpers/interactions/commands/deleteInteractionResponse.ts b/helpers/interactions/commands/deleteInteractionResponse.ts similarity index 92% rename from plugins/bot/helpers/interactions/commands/deleteInteractionResponse.ts rename to helpers/interactions/commands/deleteInteractionResponse.ts index 6b60a78f9..7bdcb5808 100644 --- a/plugins/bot/helpers/interactions/commands/deleteInteractionResponse.ts +++ b/helpers/interactions/commands/deleteInteractionResponse.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; /** To delete your response to a application command. If a message id is not provided, it will default to deleting the original response. */ export async function deleteInteractionResponse(bot: Bot, token: string, messageId?: bigint) { diff --git a/plugins/bot/helpers/interactions/commands/editApplicationCommandPermissions.ts b/helpers/interactions/commands/editApplicationCommandPermissions.ts similarity index 84% rename from plugins/bot/helpers/interactions/commands/editApplicationCommandPermissions.ts rename to helpers/interactions/commands/editApplicationCommandPermissions.ts index d74b2a6ab..598327e78 100644 --- a/plugins/bot/helpers/interactions/commands/editApplicationCommandPermissions.ts +++ b/helpers/interactions/commands/editApplicationCommandPermissions.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../../bot.ts"; -import { ApplicationCommandPermissionTypes, DiscordGuildApplicationCommandPermissions } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts"; +import { ApplicationCommandPermissionTypes } from "../../../types/shared.ts"; /** Edits command permissions for a specific command for your application in a guild. */ export async function editApplicationCommandPermissions( diff --git a/plugins/bot/helpers/interactions/commands/editInteractionResponse.ts b/helpers/interactions/commands/editInteractionResponse.ts similarity index 97% rename from plugins/bot/helpers/interactions/commands/editInteractionResponse.ts rename to helpers/interactions/commands/editInteractionResponse.ts index f634c3c71..8a287cef2 100644 --- a/plugins/bot/helpers/interactions/commands/editInteractionResponse.ts +++ b/helpers/interactions/commands/editInteractionResponse.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { MessageComponentTypes } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { MessageComponentTypes } from "../../../types/shared.ts"; import { EditWebhookMessage } from "../../webhooks/editWebhookMessage.ts"; /** To edit your response to a application command. If a messageId is not provided it will default to editing the original response. */ diff --git a/plugins/bot/helpers/interactions/commands/getApplicationCommand.ts b/helpers/interactions/commands/getApplicationCommand.ts similarity index 91% rename from plugins/bot/helpers/interactions/commands/getApplicationCommand.ts rename to helpers/interactions/commands/getApplicationCommand.ts index 103c0c674..8f4f4d10c 100644 --- a/plugins/bot/helpers/interactions/commands/getApplicationCommand.ts +++ b/helpers/interactions/commands/getApplicationCommand.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordApplicationCommand } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordApplicationCommand } from "../../../types/discord.ts"; /** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */ export async function getApplicationCommand(bot: Bot, commandId: bigint, options?: GetApplicationCommand) { diff --git a/plugins/bot/helpers/interactions/commands/getApplicationCommandPermission.ts b/helpers/interactions/commands/getApplicationCommandPermission.ts similarity index 89% rename from plugins/bot/helpers/interactions/commands/getApplicationCommandPermission.ts rename to helpers/interactions/commands/getApplicationCommandPermission.ts index 62fdd7771..db51ecb53 100644 --- a/plugins/bot/helpers/interactions/commands/getApplicationCommandPermission.ts +++ b/helpers/interactions/commands/getApplicationCommandPermission.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGuildApplicationCommandPermissions } from "../../../deps.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts"; /** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */ export async function getApplicationCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) { diff --git a/plugins/bot/helpers/interactions/commands/getApplicationCommandPermissions.ts b/helpers/interactions/commands/getApplicationCommandPermissions.ts similarity index 83% rename from plugins/bot/helpers/interactions/commands/getApplicationCommandPermissions.ts rename to helpers/interactions/commands/getApplicationCommandPermissions.ts index a412729b7..b3e1d81af 100644 --- a/plugins/bot/helpers/interactions/commands/getApplicationCommandPermissions.ts +++ b/helpers/interactions/commands/getApplicationCommandPermissions.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../../bot.ts"; -import { DiscordGuildApplicationCommandPermissions } from "../../../deps.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts"; +import { Collection } from "../../../util/collection.ts"; /** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */ export async function getApplicationCommandPermissions(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/interactions/commands/getApplicationCommands.ts b/helpers/interactions/commands/getApplicationCommands.ts similarity index 77% rename from plugins/bot/helpers/interactions/commands/getApplicationCommands.ts rename to helpers/interactions/commands/getApplicationCommands.ts index 8f65af105..65022d09b 100644 --- a/plugins/bot/helpers/interactions/commands/getApplicationCommands.ts +++ b/helpers/interactions/commands/getApplicationCommands.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../../util/collection.ts"; -import { Bot } from "../../../bot.ts"; -import { DiscordApplicationCommand } from "../../../deps.ts"; +import { Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { DiscordApplicationCommand } from "../../../types/discord.ts"; /** Fetch all the commands for your application. If a guild id is not provided, it will fetch global commands. */ export async function getApplicationCommands(bot: Bot, guildId?: bigint) { diff --git a/plugins/bot/helpers/interactions/commands/mod.ts b/helpers/interactions/commands/mod.ts similarity index 100% rename from plugins/bot/helpers/interactions/commands/mod.ts rename to helpers/interactions/commands/mod.ts diff --git a/plugins/bot/helpers/interactions/commands/upsertApplicationCommand.ts b/helpers/interactions/commands/upsertApplicationCommand.ts similarity index 86% rename from plugins/bot/helpers/interactions/commands/upsertApplicationCommand.ts rename to helpers/interactions/commands/upsertApplicationCommand.ts index 6b2680967..c04f6cad5 100644 --- a/plugins/bot/helpers/interactions/commands/upsertApplicationCommand.ts +++ b/helpers/interactions/commands/upsertApplicationCommand.ts @@ -1,11 +1,12 @@ -import { Bot } from "../../../bot.ts"; +import type { Bot } from "../../../bot.ts"; import { CreateApplicationCommand, CreateContextApplicationCommand, isContextApplicationCommand, makeOptionsForCommand, } from "./createApplicationCommand.ts"; -import { AtLeastOne, DiscordApplicationCommand } from "../../../deps.ts"; +import { DiscordApplicationCommand } from "../../../types/discord.ts"; +import { AtLeastOne } from "../../../types/shared.ts"; /** * Edit an existing application command. If this command did not exist, it will create it. diff --git a/plugins/bot/helpers/interactions/commands/upsertApplicationCommands.ts b/helpers/interactions/commands/upsertApplicationCommands.ts similarity index 86% rename from plugins/bot/helpers/interactions/commands/upsertApplicationCommands.ts rename to helpers/interactions/commands/upsertApplicationCommands.ts index 7a2e3fedd..c8976b991 100644 --- a/plugins/bot/helpers/interactions/commands/upsertApplicationCommands.ts +++ b/helpers/interactions/commands/upsertApplicationCommands.ts @@ -1,12 +1,13 @@ -import { Bot } from "../../../bot.ts"; -import { BotCollection as Collection } from "../../../util/collection.ts"; +import type { Bot } from "../../../bot.ts"; +import { Collection } from "../../../util/collection.ts"; import { CreateApplicationCommand, CreateContextApplicationCommand, isContextApplicationCommand, makeOptionsForCommand, } from "./createApplicationCommand.ts"; -import { DiscordApplicationCommand, MakeRequired } from "../../../deps.ts"; +import { DiscordApplicationCommand } from "../../../types/discord.ts"; +import { MakeRequired } from "../../../types/shared.ts"; /** * Bulk edit existing application commands. If a command does not exist, it will create it. diff --git a/plugins/bot/helpers/interactions/followups/deleteFollowupMessage.ts b/helpers/interactions/followups/deleteFollowupMessage.ts similarity index 100% rename from plugins/bot/helpers/interactions/followups/deleteFollowupMessage.ts rename to helpers/interactions/followups/deleteFollowupMessage.ts diff --git a/plugins/bot/helpers/interactions/followups/editFollowupMessage.ts b/helpers/interactions/followups/editFollowupMessage.ts similarity index 96% rename from plugins/bot/helpers/interactions/followups/editFollowupMessage.ts rename to helpers/interactions/followups/editFollowupMessage.ts index ce2abe4c4..ce1361808 100644 --- a/plugins/bot/helpers/interactions/followups/editFollowupMessage.ts +++ b/helpers/interactions/followups/editFollowupMessage.ts @@ -1,5 +1,6 @@ import { Bot } from "../../../bot.ts"; -import { DiscordMessage, MessageComponentTypes } from "../../../deps.ts"; +import { DiscordMessage } from "../../../types/discord.ts"; +import { MessageComponentTypes } from "../../../types/shared.ts"; import { EditWebhookMessage } from "../../webhooks/editWebhookMessage.ts"; /** Edits a followup message for an Interaction. Functions the same as edit webhook message, however this uses your interaction token instead of bot token. Does not support ephemeral followups. */ diff --git a/plugins/bot/helpers/interactions/followups/getFollowupMessage.ts b/helpers/interactions/followups/getFollowupMessage.ts similarity index 90% rename from plugins/bot/helpers/interactions/followups/getFollowupMessage.ts rename to helpers/interactions/followups/getFollowupMessage.ts index 2e741cf9d..0cc79d125 100644 --- a/plugins/bot/helpers/interactions/followups/getFollowupMessage.ts +++ b/helpers/interactions/followups/getFollowupMessage.ts @@ -1,5 +1,5 @@ import { Bot } from "../../../bot.ts"; -import { DiscordMessage } from "../../../deps.ts"; +import { DiscordMessage } from "../../../types/discord.ts"; /** Returns a followup message for an Interaction. Functions the same as get webhook message, however this uses your interaction token instead of bot token. Does not support ephemeral followups. */ export async function getFollowupMessage(bot: Bot, interactionToken: string, messageId: bigint) { diff --git a/plugins/bot/helpers/interactions/followups/mod.ts b/helpers/interactions/followups/mod.ts similarity index 100% rename from plugins/bot/helpers/interactions/followups/mod.ts rename to helpers/interactions/followups/mod.ts diff --git a/plugins/bot/helpers/interactions/getOriginalInteractionResponse.ts b/helpers/interactions/getOriginalInteractionResponse.ts similarity index 80% rename from plugins/bot/helpers/interactions/getOriginalInteractionResponse.ts rename to helpers/interactions/getOriginalInteractionResponse.ts index 2f9196825..e6f5ca1e2 100644 --- a/plugins/bot/helpers/interactions/getOriginalInteractionResponse.ts +++ b/helpers/interactions/getOriginalInteractionResponse.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; /** Returns the initial Interaction response. Functions the same as Get Webhook Message */ export async function getOriginalInteractionResponse(bot: Bot, token: string) { diff --git a/plugins/bot/helpers/interactions/mod.ts b/helpers/interactions/mod.ts similarity index 100% rename from plugins/bot/helpers/interactions/mod.ts rename to helpers/interactions/mod.ts diff --git a/plugins/bot/helpers/interactions/sendInteractionResponse.ts b/helpers/interactions/sendInteractionResponse.ts similarity index 92% rename from plugins/bot/helpers/interactions/sendInteractionResponse.ts rename to helpers/interactions/sendInteractionResponse.ts index 6ad70f3c9..8ae1665c3 100644 --- a/plugins/bot/helpers/interactions/sendInteractionResponse.ts +++ b/helpers/interactions/sendInteractionResponse.ts @@ -1,7 +1,8 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage, FileContent, InteractionResponseTypes } from "../../deps.ts"; -import { Embed } from "../../transformers/embed.ts"; -import { AllowedMentions, MessageComponents } from "../../typings.ts"; +import type { Bot } from "../../bot.ts"; +import { Embed } from "../../mod.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../types/discordeno.ts"; +import { InteractionResponseTypes, MessageComponentTypes } from "../../types/shared.ts"; /** * Send a response to a users application command. The command data will have the id and token necessary to respond. diff --git a/plugins/bot/helpers/interactions/verifySignature.ts b/helpers/interactions/verifySignature.ts similarity index 100% rename from plugins/bot/helpers/interactions/verifySignature.ts rename to helpers/interactions/verifySignature.ts diff --git a/plugins/bot/helpers/invites/createInvite.ts b/helpers/invites/createInvite.ts similarity index 93% rename from plugins/bot/helpers/invites/createInvite.ts rename to helpers/invites/createInvite.ts index 494f90660..498baa216 100644 --- a/plugins/bot/helpers/invites/createInvite.ts +++ b/helpers/invites/createInvite.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordInvite, InviteTargetTypes } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInvite } from "../../types/discord.ts"; +import { InviteTargetTypes } from "../../types/shared.ts"; /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) { diff --git a/plugins/bot/helpers/invites/deleteInvite.ts b/helpers/invites/deleteInvite.ts similarity index 72% rename from plugins/bot/helpers/invites/deleteInvite.ts rename to helpers/invites/deleteInvite.ts index f0a2f1b95..21f7ee839 100644 --- a/plugins/bot/helpers/invites/deleteInvite.ts +++ b/helpers/invites/deleteInvite.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordInviteMetadata } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInviteMetadata } from "../../types/discord.ts"; /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ export async function deleteInvite(bot: Bot, inviteCode: string) { diff --git a/plugins/bot/helpers/invites/getChannelInvites.ts b/helpers/invites/getChannelInvites.ts similarity index 77% rename from plugins/bot/helpers/invites/getChannelInvites.ts rename to helpers/invites/getChannelInvites.ts index 5e57f51e4..becc88e58 100644 --- a/plugins/bot/helpers/invites/getChannelInvites.ts +++ b/helpers/invites/getChannelInvites.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordInviteMetadata } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInviteMetadata } from "../../types/discord.ts"; /** Gets the invites for this channel. Requires MANAGE_CHANNEL */ export async function getChannelInvites(bot: Bot, channelId: bigint) { diff --git a/plugins/bot/helpers/invites/getInvite.ts b/helpers/invites/getInvite.ts similarity index 93% rename from plugins/bot/helpers/invites/getInvite.ts rename to helpers/invites/getInvite.ts index 7d6fdb0af..034eee463 100644 --- a/plugins/bot/helpers/invites/getInvite.ts +++ b/helpers/invites/getInvite.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordInviteMetadata } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInviteMetadata } from "../../types/discord.ts"; /** Returns an invite for the given code or throws an error if the invite doesn't exists. */ export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) { diff --git a/plugins/bot/helpers/invites/getInvites.ts b/helpers/invites/getInvites.ts similarity index 77% rename from plugins/bot/helpers/invites/getInvites.ts rename to helpers/invites/getInvites.ts index d188fa79b..d7509a7a5 100644 --- a/plugins/bot/helpers/invites/getInvites.ts +++ b/helpers/invites/getInvites.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordInviteMetadata } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordInviteMetadata } from "../../types/discord.ts"; /** Get all the invites for this guild. Requires MANAGE_GUILD permission */ export async function getInvites(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/invites/mod.ts b/helpers/invites/mod.ts similarity index 100% rename from plugins/bot/helpers/invites/mod.ts rename to helpers/invites/mod.ts diff --git a/plugins/bot/helpers/members/avatarUrl.ts b/helpers/members/avatarUrl.ts similarity index 95% rename from plugins/bot/helpers/members/avatarUrl.ts rename to helpers/members/avatarUrl.ts index 684d9c636..fcdc89b47 100644 --- a/plugins/bot/helpers/members/avatarUrl.ts +++ b/helpers/members/avatarUrl.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** The users custom avatar or the default avatar if you don't have a member object. */ export function avatarURL( diff --git a/plugins/bot/helpers/members/banMember.ts b/helpers/members/banMember.ts similarity index 94% rename from plugins/bot/helpers/members/banMember.ts rename to helpers/members/banMember.ts index 6be6b790a..168d4769b 100644 --- a/plugins/bot/helpers/members/banMember.ts +++ b/helpers/members/banMember.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */ export async function banMember(bot: Bot, guildId: bigint, id: bigint, options?: CreateGuildBan) { diff --git a/plugins/bot/helpers/members/editBotNickname.ts b/helpers/members/editBotNickname.ts similarity index 90% rename from plugins/bot/helpers/members/editBotNickname.ts rename to helpers/members/editBotNickname.ts index a1c7f1801..57fd5a562 100644 --- a/plugins/bot/helpers/members/editBotNickname.ts +++ b/helpers/members/editBotNickname.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Edit the nickname of the bot in this guild */ export async function editBotNickname(bot: Bot, guildId: bigint, options: { nick: string | null; reason?: string }) { diff --git a/plugins/bot/helpers/members/editMember.ts b/helpers/members/editMember.ts similarity index 94% rename from plugins/bot/helpers/members/editMember.ts rename to helpers/members/editMember.ts index 2c2a3cd3f..83eb254ec 100644 --- a/plugins/bot/helpers/members/editMember.ts +++ b/helpers/members/editMember.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMemberWithUser } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMemberWithUser } from "../../types/discord.ts"; /** Edit the member */ export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, options: ModifyGuildMember) { diff --git a/plugins/bot/helpers/members/fetchMembers.ts b/helpers/members/fetchMembers.ts similarity index 95% rename from plugins/bot/helpers/members/fetchMembers.ts rename to helpers/members/fetchMembers.ts index aa28500f4..ee7dc3a5b 100644 --- a/plugins/bot/helpers/members/fetchMembers.ts +++ b/helpers/members/fetchMembers.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { GatewayIntents, GatewayOpcodes } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { GatewayIntents, GatewayOpcodes } from "../../types/shared.ts"; /** * Highly recommended to use this function to fetch members instead of getMember from REST. diff --git a/plugins/bot/helpers/members/getDmChannel.ts b/helpers/members/getDmChannel.ts similarity index 83% rename from plugins/bot/helpers/members/getDmChannel.ts rename to helpers/members/getDmChannel.ts index 18842c6d9..fdc228aeb 100644 --- a/plugins/bot/helpers/members/getDmChannel.ts +++ b/helpers/members/getDmChannel.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordChannel } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordChannel } from "../../types/discord.ts"; /** Get a user's dm channel. This is required in order to send a DM. */ export async function getDmChannel(bot: Bot, userId: bigint) { diff --git a/plugins/bot/helpers/members/getMember.ts b/helpers/members/getMember.ts similarity index 78% rename from plugins/bot/helpers/members/getMember.ts rename to helpers/members/getMember.ts index bde694b4c..3263e3e88 100644 --- a/plugins/bot/helpers/members/getMember.ts +++ b/helpers/members/getMember.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMemberWithUser } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMemberWithUser } from "../../types/discord.ts"; /** Returns a guild member object for the specified user. */ export async function getMember(bot: Bot, guildId: bigint, id: bigint) { diff --git a/plugins/bot/helpers/members/getMembers.ts b/helpers/members/getMembers.ts similarity index 86% rename from plugins/bot/helpers/members/getMembers.ts rename to helpers/members/getMembers.ts index 02b486331..f35923448 100644 --- a/plugins/bot/helpers/members/getMembers.ts +++ b/helpers/members/getMembers.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMemberWithUser } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMemberWithUser } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; // TODO: make options optional /** diff --git a/plugins/bot/helpers/members/kickMember.ts b/helpers/members/kickMember.ts similarity index 100% rename from plugins/bot/helpers/members/kickMember.ts rename to helpers/members/kickMember.ts diff --git a/plugins/bot/helpers/members/mod.ts b/helpers/members/mod.ts similarity index 100% rename from plugins/bot/helpers/members/mod.ts rename to helpers/members/mod.ts diff --git a/plugins/bot/helpers/members/pruneMembers.ts b/helpers/members/pruneMembers.ts similarity index 97% rename from plugins/bot/helpers/members/pruneMembers.ts rename to helpers/members/pruneMembers.ts index f6c037bb0..c214ddf02 100644 --- a/plugins/bot/helpers/members/pruneMembers.ts +++ b/helpers/members/pruneMembers.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** * Begin a prune operation. Requires the KICK_MEMBERS permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. For large guilds it's recommended to set the computePruneCount option to false, forcing 'pruned' to null. Fires multiple Guild Member Remove Gateway events. diff --git a/plugins/bot/helpers/members/searchMembers.ts b/helpers/members/searchMembers.ts similarity index 81% rename from plugins/bot/helpers/members/searchMembers.ts rename to helpers/members/searchMembers.ts index 9d47d7ddd..457652f12 100644 --- a/plugins/bot/helpers/members/searchMembers.ts +++ b/helpers/members/searchMembers.ts @@ -1,8 +1,8 @@ -import type { DiscordMemberWithUser } from "../../deps.ts"; +import type { SearchMembers } from "../../types/discordeno.ts"; +import type { DiscordMemberWithUser } from "../../types/discord.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import { Collection } from "../../util/collection.ts"; import { Bot } from "../../bot.ts"; -import { SearchMembers } from "../../typings.ts"; /** * Query string to match username(s) and nickname(s) against diff --git a/plugins/bot/helpers/members/unbanMember.ts b/helpers/members/unbanMember.ts similarity index 85% rename from plugins/bot/helpers/members/unbanMember.ts rename to helpers/members/unbanMember.ts index 99148cf31..81027d125 100644 --- a/plugins/bot/helpers/members/unbanMember.ts +++ b/helpers/members/unbanMember.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Remove the ban for a user. Requires BAN_MEMBERS permission */ export async function unbanMember(bot: Bot, guildId: bigint, id: bigint) { diff --git a/plugins/bot/helpers/messages/addReaction.ts b/helpers/messages/addReaction.ts similarity index 94% rename from plugins/bot/helpers/messages/addReaction.ts rename to helpers/messages/addReaction.ts index 90ee655ee..2937cf55a 100644 --- a/plugins/bot/helpers/messages/addReaction.ts +++ b/helpers/messages/addReaction.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Create a reaction for the message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */ export async function addReaction(bot: Bot, channelId: bigint, messageId: bigint, reaction: string) { diff --git a/plugins/bot/helpers/messages/addReactions.ts b/helpers/messages/addReactions.ts similarity index 94% rename from plugins/bot/helpers/messages/addReactions.ts rename to helpers/messages/addReactions.ts index f6dffbaf7..faffb1d11 100644 --- a/plugins/bot/helpers/messages/addReactions.ts +++ b/helpers/messages/addReactions.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Adds multiple reactions to a message. If `ordered` is true(default is false), it will add the reactions one at a time in the order provided. Note: Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */ export async function addReactions( diff --git a/plugins/bot/helpers/messages/deleteMessage.ts b/helpers/messages/deleteMessage.ts similarity index 91% rename from plugins/bot/helpers/messages/deleteMessage.ts rename to helpers/messages/deleteMessage.ts index 89a60b198..a52895fc0 100644 --- a/plugins/bot/helpers/messages/deleteMessage.ts +++ b/helpers/messages/deleteMessage.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a message with the channel id and message id only. */ export async function deleteMessage( diff --git a/plugins/bot/helpers/messages/deleteMessages.ts b/helpers/messages/deleteMessages.ts similarity index 93% rename from plugins/bot/helpers/messages/deleteMessages.ts rename to helpers/messages/deleteMessages.ts index 0023cd3e5..9f05d3852 100644 --- a/plugins/bot/helpers/messages/deleteMessages.ts +++ b/helpers/messages/deleteMessages.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete messages from the channel. 2-100. Requires the MANAGE_MESSAGES permission */ export async function deleteMessages(bot: Bot, channelId: bigint, ids: bigint[], reason?: string) { diff --git a/plugins/bot/helpers/messages/editMessage.ts b/helpers/messages/editMessage.ts similarity index 94% rename from plugins/bot/helpers/messages/editMessage.ts rename to helpers/messages/editMessage.ts index f388c579b..e870d9ee6 100644 --- a/plugins/bot/helpers/messages/editMessage.ts +++ b/helpers/messages/editMessage.ts @@ -1,8 +1,9 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { Attachment } from "../../transformers/attachment.ts"; import { Embed } from "../../transformers/embed.ts"; -import { DiscordMessage, FileContent, MessageComponentTypes } from "../../deps.ts"; -import { AllowedMentions, MessageComponents } from "../../typings.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../types/discordeno.ts"; +import { MessageComponentTypes } from "../../types/shared.ts"; /** Edit the message. */ export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint, content: EditMessage) { diff --git a/plugins/bot/helpers/messages/getMessage.ts b/helpers/messages/getMessage.ts similarity index 81% rename from plugins/bot/helpers/messages/getMessage.ts rename to helpers/messages/getMessage.ts index ec660dd13..e8e736cc9 100644 --- a/plugins/bot/helpers/messages/getMessage.ts +++ b/helpers/messages/getMessage.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; /** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */ export async function getMessage(bot: Bot, channelId: bigint, id: bigint) { diff --git a/plugins/bot/helpers/messages/getMessages.ts b/helpers/messages/getMessages.ts similarity index 93% rename from plugins/bot/helpers/messages/getMessages.ts rename to helpers/messages/getMessages.ts index 55044eab7..93968914e 100644 --- a/plugins/bot/helpers/messages/getMessages.ts +++ b/helpers/messages/getMessages.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; import { hasProperty } from "../../util/utils.ts"; /** Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */ diff --git a/plugins/bot/helpers/messages/getReactions.ts b/helpers/messages/getReactions.ts similarity index 86% rename from plugins/bot/helpers/messages/getReactions.ts rename to helpers/messages/getReactions.ts index 100cc2a21..2969940de 100644 --- a/plugins/bot/helpers/messages/getReactions.ts +++ b/helpers/messages/getReactions.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordUser } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordUser } from "../../types/discord.ts"; /** Get a list of users that reacted with this emoji. */ export async function getReactions( diff --git a/plugins/bot/helpers/messages/mod.ts b/helpers/messages/mod.ts similarity index 100% rename from plugins/bot/helpers/messages/mod.ts rename to helpers/messages/mod.ts diff --git a/plugins/bot/helpers/messages/pinMessage.ts b/helpers/messages/pinMessage.ts similarity index 87% rename from plugins/bot/helpers/messages/pinMessage.ts rename to helpers/messages/pinMessage.ts index 571b892c1..8665eeec8 100644 --- a/plugins/bot/helpers/messages/pinMessage.ts +++ b/helpers/messages/pinMessage.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Pin a message in a channel. Requires MANAGE_MESSAGES. Max pins allowed in a channel = 50. */ export async function pinMessage(bot: Bot, channelId: bigint, messageId: bigint) { diff --git a/plugins/bot/helpers/messages/publishMessage.ts b/helpers/messages/publishMessage.ts similarity index 78% rename from plugins/bot/helpers/messages/publishMessage.ts rename to helpers/messages/publishMessage.ts index eb8d52bac..803c339a8 100644 --- a/plugins/bot/helpers/messages/publishMessage.ts +++ b/helpers/messages/publishMessage.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; /** Crosspost a message in a News Channel to following channels. */ export async function publishMessage(bot: Bot, channelId: bigint, messageId: bigint) { diff --git a/plugins/bot/helpers/messages/removeAllReactions.ts b/helpers/messages/removeAllReactions.ts similarity index 88% rename from plugins/bot/helpers/messages/removeAllReactions.ts rename to helpers/messages/removeAllReactions.ts index f946a0e5e..9c2f6a89d 100644 --- a/plugins/bot/helpers/messages/removeAllReactions.ts +++ b/helpers/messages/removeAllReactions.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Removes all reactions for all emojis on this message. */ export async function removeAllReactions(bot: Bot, channelId: bigint, messageId: bigint) { diff --git a/plugins/bot/helpers/messages/removeReaction.ts b/helpers/messages/removeReaction.ts similarity index 95% rename from plugins/bot/helpers/messages/removeReaction.ts rename to helpers/messages/removeReaction.ts index 06e762794..c656c44d3 100644 --- a/plugins/bot/helpers/messages/removeReaction.ts +++ b/helpers/messages/removeReaction.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Removes a reaction from the given user on this message, defaults to bot. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export async function removeReaction( diff --git a/plugins/bot/helpers/messages/removeReactionEmoji.ts b/helpers/messages/removeReactionEmoji.ts similarity index 93% rename from plugins/bot/helpers/messages/removeReactionEmoji.ts rename to helpers/messages/removeReactionEmoji.ts index b0cb753a1..a7be2349c 100644 --- a/plugins/bot/helpers/messages/removeReactionEmoji.ts +++ b/helpers/messages/removeReactionEmoji.ts @@ -1,5 +1,5 @@ /** Removes all reactions for a single emoji on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; export async function removeReactionEmoji(bot: Bot, channelId: bigint, messageId: bigint, reaction: string) { if (reaction.startsWith("<:")) { diff --git a/plugins/bot/helpers/messages/sendMessage.ts b/helpers/messages/sendMessage.ts similarity index 94% rename from plugins/bot/helpers/messages/sendMessage.ts rename to helpers/messages/sendMessage.ts index da9e962c8..169603d85 100644 --- a/plugins/bot/helpers/messages/sendMessage.ts +++ b/helpers/messages/sendMessage.ts @@ -1,7 +1,8 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage, FileContent, MessageComponentTypes } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../types/mod.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { MessageComponentTypes } from "../../types/shared.ts"; import { Embed } from "../../transformers/embed.ts"; -import { AllowedMentions, MessageComponents } from "../../typings.ts"; /** Send a message to the channel. Requires SEND_MESSAGES permission. */ export async function sendMessage(bot: Bot, channelId: bigint, content: CreateMessage) { diff --git a/plugins/bot/helpers/messages/unpinMessage.ts b/helpers/messages/unpinMessage.ts similarity index 86% rename from plugins/bot/helpers/messages/unpinMessage.ts rename to helpers/messages/unpinMessage.ts index 5ac6623f5..1577d00b9 100644 --- a/plugins/bot/helpers/messages/unpinMessage.ts +++ b/helpers/messages/unpinMessage.ts @@ -1,5 +1,5 @@ /** Unpin a message in a channel. Requires MANAGE_MESSAGES. */ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; export async function unpinMessage(bot: Bot, channelId: bigint, messageId: bigint) { await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.CHANNEL_PIN(channelId, messageId)); diff --git a/plugins/bot/helpers/misc/editBotProfile.ts b/helpers/misc/editBotProfile.ts similarity index 85% rename from plugins/bot/helpers/misc/editBotProfile.ts rename to helpers/misc/editBotProfile.ts index 57eb1ba2a..8d1c1a0ad 100644 --- a/plugins/bot/helpers/misc/editBotProfile.ts +++ b/helpers/misc/editBotProfile.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordUser } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordUser } from "../../types/discord.ts"; /** Modifies the bot's username or avatar. * NOTE: username: if changed may cause the bot's discriminator to be randomized. diff --git a/plugins/bot/helpers/misc/editBotStatus.ts b/helpers/misc/editBotStatus.ts similarity index 100% rename from plugins/bot/helpers/misc/editBotStatus.ts rename to helpers/misc/editBotStatus.ts diff --git a/plugins/bot/helpers/misc/editShardStatus.ts b/helpers/misc/editShardStatus.ts similarity index 96% rename from plugins/bot/helpers/misc/editShardStatus.ts rename to helpers/misc/editShardStatus.ts index 3c31262db..3daa23f8e 100644 --- a/plugins/bot/helpers/misc/editShardStatus.ts +++ b/helpers/misc/editShardStatus.ts @@ -1,7 +1,7 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; import { Activity } from "../../transformers/activity.ts"; import { StatusTypes } from "../../transformers/presence.ts"; -import { GatewayOpcodes } from "../../deps.ts"; +import { GatewayOpcodes } from "../../types/shared.ts"; export function editShardStatus(bot: Bot, shardId: number, data: StatusUpdate) { const shard = bot.gateway.manager.shards.get(shardId); diff --git a/plugins/bot/helpers/misc/getGatewayBot.ts b/helpers/misc/getGatewayBot.ts similarity index 75% rename from plugins/bot/helpers/misc/getGatewayBot.ts rename to helpers/misc/getGatewayBot.ts index 183946847..3cd5ee1c8 100644 --- a/plugins/bot/helpers/misc/getGatewayBot.ts +++ b/helpers/misc/getGatewayBot.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGetGatewayBot } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGetGatewayBot } from "../../types/discord.ts"; /** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */ export async function getGatewayBot(bot: Bot) { diff --git a/plugins/bot/helpers/misc/getUser.ts b/helpers/misc/getUser.ts similarity index 79% rename from plugins/bot/helpers/misc/getUser.ts rename to helpers/misc/getUser.ts index ac50bf4a4..5e57051ff 100644 --- a/plugins/bot/helpers/misc/getUser.ts +++ b/helpers/misc/getUser.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordUser } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordUser } from "../../types/discord.ts"; /** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */ export async function getUser(bot: Bot, userId: bigint) { diff --git a/plugins/bot/helpers/misc/mod.ts b/helpers/misc/mod.ts similarity index 100% rename from plugins/bot/helpers/misc/mod.ts rename to helpers/misc/mod.ts diff --git a/plugins/bot/helpers/misc/nitroStickerPacks.ts b/helpers/misc/nitroStickerPacks.ts similarity index 86% rename from plugins/bot/helpers/misc/nitroStickerPacks.ts rename to helpers/misc/nitroStickerPacks.ts index 4c515a9e0..9fa147329 100644 --- a/plugins/bot/helpers/misc/nitroStickerPacks.ts +++ b/helpers/misc/nitroStickerPacks.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordStickerPack } from "../../deps.ts"; +import { DiscordStickerPack } from "../../types/discord.ts"; /** Returns the list of sticker packs available to Nitro subscribers. */ export async function nitroStickerPacks(bot: Bot) { diff --git a/plugins/bot/helpers/mod.ts b/helpers/mod.ts similarity index 100% rename from plugins/bot/helpers/mod.ts rename to helpers/mod.ts diff --git a/plugins/bot/helpers/oauth/getApplicationInfo.ts b/helpers/oauth/getApplicationInfo.ts similarity index 73% rename from plugins/bot/helpers/oauth/getApplicationInfo.ts rename to helpers/oauth/getApplicationInfo.ts index c7c5aa242..5c0c31eb4 100644 --- a/plugins/bot/helpers/oauth/getApplicationInfo.ts +++ b/helpers/oauth/getApplicationInfo.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordApplication } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordApplication } from "../../types/discord.ts"; /** Get the applications info */ export async function getApplicationInfo(bot: Bot) { diff --git a/plugins/bot/helpers/oauth/mod.ts b/helpers/oauth/mod.ts similarity index 100% rename from plugins/bot/helpers/oauth/mod.ts rename to helpers/oauth/mod.ts diff --git a/plugins/bot/helpers/roles/addRole.ts b/helpers/roles/addRole.ts similarity index 88% rename from plugins/bot/helpers/roles/addRole.ts rename to helpers/roles/addRole.ts index 52a4c9434..dad10f017 100644 --- a/plugins/bot/helpers/roles/addRole.ts +++ b/helpers/roles/addRole.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Add a role to the member */ export async function addRole(bot: Bot, guildId: bigint, memberId: bigint, roleId: bigint, reason?: string) { diff --git a/plugins/bot/helpers/roles/createRole.ts b/helpers/roles/createRole.ts similarity index 89% rename from plugins/bot/helpers/roles/createRole.ts rename to helpers/roles/createRole.ts index ee4a40c4f..4b342b6f0 100644 --- a/plugins/bot/helpers/roles/createRole.ts +++ b/helpers/roles/createRole.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordRole, PermissionStrings } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordRole } from "../../types/discord.ts"; +import { PermissionStrings } from "../../types/shared.ts"; /** Create a new role for the guild. Requires the MANAGE_ROLES permission. */ export async function createRole(bot: Bot, guildId: bigint, options: CreateGuildRole, reason?: string) { diff --git a/plugins/bot/helpers/roles/deleteRole.ts b/helpers/roles/deleteRole.ts similarity index 85% rename from plugins/bot/helpers/roles/deleteRole.ts rename to helpers/roles/deleteRole.ts index 99ba29f9c..d680b576e 100644 --- a/plugins/bot/helpers/roles/deleteRole.ts +++ b/helpers/roles/deleteRole.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a guild role. Requires the MANAGE_ROLES permission. */ export async function deleteRole(bot: Bot, guildId: bigint, id: bigint) { diff --git a/plugins/bot/helpers/roles/editRole.ts b/helpers/roles/editRole.ts similarity index 88% rename from plugins/bot/helpers/roles/editRole.ts rename to helpers/roles/editRole.ts index dc7364a4e..cd4f18753 100644 --- a/plugins/bot/helpers/roles/editRole.ts +++ b/helpers/roles/editRole.ts @@ -1,5 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordRole, PermissionStrings } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordRole } from "../../types/discord.ts"; +import { PermissionStrings } from "../../types/shared.ts"; /** Edit a guild role. Requires the MANAGE_ROLES permission. */ export async function editRole(bot: Bot, guildId: bigint, id: bigint, options: EditGuildRole) { diff --git a/plugins/bot/helpers/roles/getRoles.ts b/helpers/roles/getRoles.ts similarity index 78% rename from plugins/bot/helpers/roles/getRoles.ts rename to helpers/roles/getRoles.ts index cdaa5c36a..a622de83e 100644 --- a/plugins/bot/helpers/roles/getRoles.ts +++ b/helpers/roles/getRoles.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; -import { DiscordRole } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { Collection } from "../../util/collection.ts"; +import { DiscordRole } from "../../types/discord.ts"; /** Returns a list of role objects for the guild. * diff --git a/plugins/bot/helpers/roles/mod.ts b/helpers/roles/mod.ts similarity index 100% rename from plugins/bot/helpers/roles/mod.ts rename to helpers/roles/mod.ts diff --git a/plugins/bot/helpers/roles/modifyRolePositions.ts b/helpers/roles/modifyRolePositions.ts similarity index 87% rename from plugins/bot/helpers/roles/modifyRolePositions.ts rename to helpers/roles/modifyRolePositions.ts index d0cd8d150..00bedd164 100644 --- a/plugins/bot/helpers/roles/modifyRolePositions.ts +++ b/helpers/roles/modifyRolePositions.ts @@ -1,6 +1,6 @@ import { Bot } from "../../bot.ts"; -import { DiscordRole } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import { DiscordRole } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; /** Modify the positions of a set of role objects for the guild. Requires the MANAGE_ROLES permission. Returns a list of all of the guild's role objects on success. Fires multiple Guild Role Update Gateway events. */ export async function modifyRolePositions(bot: Bot, guildId: bigint, options: ModifyRolePositions[]) { diff --git a/plugins/bot/helpers/roles/removeRole.ts b/helpers/roles/removeRole.ts similarity index 88% rename from plugins/bot/helpers/roles/removeRole.ts rename to helpers/roles/removeRole.ts index a16a0d61a..cc929267e 100644 --- a/plugins/bot/helpers/roles/removeRole.ts +++ b/helpers/roles/removeRole.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Remove a role from the member */ export async function removeRole(bot: Bot, guildId: bigint, memberId: bigint, roleId: bigint, reason?: string) { diff --git a/plugins/bot/helpers/templates/createGuildFromTemplate.ts b/helpers/templates/createGuildFromTemplate.ts similarity index 90% rename from plugins/bot/helpers/templates/createGuildFromTemplate.ts rename to helpers/templates/createGuildFromTemplate.ts index 2ca933d06..7c9ba4ef8 100644 --- a/plugins/bot/helpers/templates/createGuildFromTemplate.ts +++ b/helpers/templates/createGuildFromTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordGuild } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordGuild } from "../../types/discord.ts"; /** * Create a new guild based on a template diff --git a/plugins/bot/helpers/templates/createGuildTemplate.ts b/helpers/templates/createGuildTemplate.ts similarity index 88% rename from plugins/bot/helpers/templates/createGuildTemplate.ts rename to helpers/templates/createGuildTemplate.ts index 3abc285e5..6bbcfee76 100644 --- a/plugins/bot/helpers/templates/createGuildTemplate.ts +++ b/helpers/templates/createGuildTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** Creates a template for the guild. Requires the `MANAGE_GUILD` permission. */ export async function createGuildTemplate(bot: Bot, guildId: bigint, data: CreateTemplate) { diff --git a/plugins/bot/helpers/templates/deleteGuildTemplate.ts b/helpers/templates/deleteGuildTemplate.ts similarity index 76% rename from plugins/bot/helpers/templates/deleteGuildTemplate.ts rename to helpers/templates/deleteGuildTemplate.ts index b5c97ddf6..a57c6686b 100644 --- a/plugins/bot/helpers/templates/deleteGuildTemplate.ts +++ b/helpers/templates/deleteGuildTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** * Deletes a template from a guild. diff --git a/plugins/bot/helpers/templates/editGuildTemplate.ts b/helpers/templates/editGuildTemplate.ts similarity index 91% rename from plugins/bot/helpers/templates/editGuildTemplate.ts rename to helpers/templates/editGuildTemplate.ts index 1a72b0df3..260626ce7 100644 --- a/plugins/bot/helpers/templates/editGuildTemplate.ts +++ b/helpers/templates/editGuildTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** * Edit a template's metadata. diff --git a/plugins/bot/helpers/templates/getGuildTemplates.ts b/helpers/templates/getGuildTemplates.ts similarity index 72% rename from plugins/bot/helpers/templates/getGuildTemplates.ts rename to helpers/templates/getGuildTemplates.ts index 034470179..2830e1789 100644 --- a/plugins/bot/helpers/templates/getGuildTemplates.ts +++ b/helpers/templates/getGuildTemplates.ts @@ -1,6 +1,6 @@ -import { BotCollection as Collection } from "../../util/collection.ts"; -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import { Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** Returns an array of templates. Requires the `MANAGE_GUILD` permission. */ export async function getGuildTemplates(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/templates/getTemplate.ts b/helpers/templates/getTemplate.ts similarity index 75% rename from plugins/bot/helpers/templates/getTemplate.ts rename to helpers/templates/getTemplate.ts index 9fec4dd29..7ce0bb0ea 100644 --- a/plugins/bot/helpers/templates/getTemplate.ts +++ b/helpers/templates/getTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** Returns the guild template if it exists */ export async function getTemplate(bot: Bot, templateCode: string) { diff --git a/plugins/bot/helpers/templates/mod.ts b/helpers/templates/mod.ts similarity index 100% rename from plugins/bot/helpers/templates/mod.ts rename to helpers/templates/mod.ts diff --git a/plugins/bot/helpers/templates/syncGuildTemplate.ts b/helpers/templates/syncGuildTemplate.ts similarity index 77% rename from plugins/bot/helpers/templates/syncGuildTemplate.ts rename to helpers/templates/syncGuildTemplate.ts index 18951bf8a..b9fc7c893 100644 --- a/plugins/bot/helpers/templates/syncGuildTemplate.ts +++ b/helpers/templates/syncGuildTemplate.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordTemplate } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordTemplate } from "../../types/discord.ts"; /** * Syncs the template to the guild's current state. diff --git a/plugins/bot/helpers/voice/connectToVoiceChannel.ts b/helpers/voice/connectToVoiceChannel.ts similarity index 91% rename from plugins/bot/helpers/voice/connectToVoiceChannel.ts rename to helpers/voice/connectToVoiceChannel.ts index e1f40c05c..f96d0e1fe 100644 --- a/plugins/bot/helpers/voice/connectToVoiceChannel.ts +++ b/helpers/voice/connectToVoiceChannel.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { AtLeastOne, GatewayOpcodes } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { AtLeastOne, GatewayOpcodes } from "../../types/shared.ts"; /** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */ export async function connectToVoiceChannel( diff --git a/plugins/bot/helpers/voice/mod.ts b/helpers/voice/mod.ts similarity index 100% rename from plugins/bot/helpers/voice/mod.ts rename to helpers/voice/mod.ts diff --git a/plugins/bot/helpers/webhooks/createWebhook.ts b/helpers/webhooks/createWebhook.ts similarity index 91% rename from plugins/bot/helpers/webhooks/createWebhook.ts rename to helpers/webhooks/createWebhook.ts index 70633b0c1..bd3b1601e 100644 --- a/plugins/bot/helpers/webhooks/createWebhook.ts +++ b/helpers/webhooks/createWebhook.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; /** * Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations: diff --git a/plugins/bot/helpers/webhooks/deleteWebhook.ts b/helpers/webhooks/deleteWebhook.ts similarity index 88% rename from plugins/bot/helpers/webhooks/deleteWebhook.ts rename to helpers/webhooks/deleteWebhook.ts index 09e0ba63d..10b2946fd 100644 --- a/plugins/bot/helpers/webhooks/deleteWebhook.ts +++ b/helpers/webhooks/deleteWebhook.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a webhook permanently. Requires the `MANAGE_WEBHOOKS` permission. Returns a undefined on success */ export async function deleteWebhook(bot: Bot, webhookId: bigint, reason?: string) { diff --git a/plugins/bot/helpers/webhooks/deleteWebhookMessage.ts b/helpers/webhooks/deleteWebhookMessage.ts similarity index 91% rename from plugins/bot/helpers/webhooks/deleteWebhookMessage.ts rename to helpers/webhooks/deleteWebhookMessage.ts index d36c31115..2cbfcec28 100644 --- a/plugins/bot/helpers/webhooks/deleteWebhookMessage.ts +++ b/helpers/webhooks/deleteWebhookMessage.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; export interface DeleteWebhookMessageOptions { /** id of the thread the message is in */ diff --git a/plugins/bot/helpers/webhooks/deleteWebhookWithToken.ts b/helpers/webhooks/deleteWebhookWithToken.ts similarity index 87% rename from plugins/bot/helpers/webhooks/deleteWebhookWithToken.ts rename to helpers/webhooks/deleteWebhookWithToken.ts index 604e997b2..dcfe27453 100644 --- a/plugins/bot/helpers/webhooks/deleteWebhookWithToken.ts +++ b/helpers/webhooks/deleteWebhookWithToken.ts @@ -1,4 +1,4 @@ -import { Bot } from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a webhook permanently. Returns a undefined on success */ export async function deleteWebhookWithToken(bot: Bot, webhookId: bigint, webhookToken: string) { diff --git a/plugins/bot/helpers/webhooks/editWebhook.ts b/helpers/webhooks/editWebhook.ts similarity index 89% rename from plugins/bot/helpers/webhooks/editWebhook.ts rename to helpers/webhooks/editWebhook.ts index 9700d00ed..696cf60ef 100644 --- a/plugins/bot/helpers/webhooks/editWebhook.ts +++ b/helpers/webhooks/editWebhook.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; /** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */ export async function editWebhook(bot: Bot, webhookId: bigint, options: ModifyWebhook) { diff --git a/plugins/bot/helpers/webhooks/editWebhookMessage.ts b/helpers/webhooks/editWebhookMessage.ts similarity index 94% rename from plugins/bot/helpers/webhooks/editWebhookMessage.ts rename to helpers/webhooks/editWebhookMessage.ts index f9daae7ef..05fb18bd5 100644 --- a/plugins/bot/helpers/webhooks/editWebhookMessage.ts +++ b/helpers/webhooks/editWebhookMessage.ts @@ -1,8 +1,9 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage, FileContent, MessageComponentTypes } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../types/discordeno.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { MessageComponentTypes } from "../../types/shared.ts"; import { Attachment } from "../../transformers/attachment.ts"; import { Embed } from "../../transformers/embed.ts"; -import { AllowedMentions, MessageComponents } from "../../typings.ts"; export async function editWebhookMessage( bot: Bot, diff --git a/plugins/bot/helpers/webhooks/editWebhookWithToken.ts b/helpers/webhooks/editWebhookWithToken.ts similarity index 84% rename from plugins/bot/helpers/webhooks/editWebhookWithToken.ts rename to helpers/webhooks/editWebhookWithToken.ts index 965945092..5ceccac6b 100644 --- a/plugins/bot/helpers/webhooks/editWebhookWithToken.ts +++ b/helpers/webhooks/editWebhookWithToken.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; import { ModifyWebhook } from "./editWebhook.ts"; /** Edit a webhook. Returns the updated webhook object on success. */ diff --git a/plugins/bot/helpers/webhooks/getWebhook.ts b/helpers/webhooks/getWebhook.ts similarity index 77% rename from plugins/bot/helpers/webhooks/getWebhook.ts rename to helpers/webhooks/getWebhook.ts index 4d1f352c0..690bf0355 100644 --- a/plugins/bot/helpers/webhooks/getWebhook.ts +++ b/helpers/webhooks/getWebhook.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; /** Returns the new webhook object for the given id. */ export async function getWebhook(bot: Bot, webhookId: bigint) { diff --git a/plugins/bot/helpers/webhooks/getWebhookMessage.ts b/helpers/webhooks/getWebhookMessage.ts similarity index 85% rename from plugins/bot/helpers/webhooks/getWebhookMessage.ts rename to helpers/webhooks/getWebhookMessage.ts index f54bc0d3b..4b0b4e828 100644 --- a/plugins/bot/helpers/webhooks/getWebhookMessage.ts +++ b/helpers/webhooks/getWebhookMessage.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMessage } from "../../types/discord.ts"; export interface GetWebhookMessageOptions { threadId: bigint; diff --git a/plugins/bot/helpers/webhooks/getWebhookWithToken.ts b/helpers/webhooks/getWebhookWithToken.ts similarity index 81% rename from plugins/bot/helpers/webhooks/getWebhookWithToken.ts rename to helpers/webhooks/getWebhookWithToken.ts index 3eb97e0c5..e5a9d3500 100644 --- a/plugins/bot/helpers/webhooks/getWebhookWithToken.ts +++ b/helpers/webhooks/getWebhookWithToken.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; /** Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. */ export async function getWebhookWithToken(bot: Bot, webhookId: bigint, token: string) { diff --git a/plugins/bot/helpers/webhooks/getWebhooks.ts b/helpers/webhooks/getWebhooks.ts similarity index 73% rename from plugins/bot/helpers/webhooks/getWebhooks.ts rename to helpers/webhooks/getWebhooks.ts index fd0a8b817..d58889ec1 100644 --- a/plugins/bot/helpers/webhooks/getWebhooks.ts +++ b/helpers/webhooks/getWebhooks.ts @@ -1,6 +1,6 @@ -import { Bot } from "../../bot.ts"; -import { DiscordWebhook } from "../../deps.ts"; -import { BotCollection as Collection } from "../../util/collection.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordWebhook } from "../../types/discord.ts"; +import { Collection } from "../../util/collection.ts"; /** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */ export async function getWebhooks(bot: Bot, guildId: bigint) { diff --git a/plugins/bot/helpers/webhooks/mod.ts b/helpers/webhooks/mod.ts similarity index 100% rename from plugins/bot/helpers/webhooks/mod.ts rename to helpers/webhooks/mod.ts diff --git a/plugins/bot/helpers/webhooks/sendWebhook.ts b/helpers/webhooks/sendWebhook.ts similarity index 92% rename from plugins/bot/helpers/webhooks/sendWebhook.ts rename to helpers/webhooks/sendWebhook.ts index 778ca9038..fcd1fe8dc 100644 --- a/plugins/bot/helpers/webhooks/sendWebhook.ts +++ b/helpers/webhooks/sendWebhook.ts @@ -1,7 +1,7 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMessage, FileContent } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; import { Embed } from "../../transformers/embed.ts"; -import { AllowedMentions, MessageComponents } from "../../typings.ts"; +import { DiscordMessage } from "../../types/discord.ts"; +import { AllowedMentions, FileContent, MessageComponents } from "../../types/discordeno.ts"; /** Send a webhook with webhook Id and webhook token */ export async function sendWebhook(bot: Bot, webhookId: bigint, webhookToken: string, options: ExecuteWebhook) { diff --git a/mod.ts b/mod.ts index 4956aa28d..cdf461342 100644 --- a/mod.ts +++ b/mod.ts @@ -1,4 +1,9 @@ export * from "./gateway/mod.ts"; +export * from "./handlers/mod.ts"; +export * from "./helpers/mod.ts"; export * from "./rest/mod.ts"; +export * from "./transformers/mod.ts"; export * from "./types/mod.ts"; export * from "./util/mod.ts"; + +export * from "./bot.ts"; diff --git a/plugins/bot/deps.ts b/plugins/bot/deps.ts deleted file mode 100644 index ac326e73f..000000000 --- a/plugins/bot/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../../mod.ts"; diff --git a/plugins/bot/mod.ts b/plugins/bot/mod.ts deleted file mode 100644 index c6791bb95..000000000 --- a/plugins/bot/mod.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./handlers/mod.ts"; -export * from "./helpers/mod.ts"; -export * from "./transformers/mod.ts"; -export * from "./util/mod.ts"; -export * from "./bot.ts"; -export * from "./typings.ts"; -// This will export everything from discordeno as well. Makes it easier to use. -export * from "./deps.ts"; diff --git a/plugins/bot/util/collection.ts b/plugins/bot/util/collection.ts deleted file mode 100644 index cd2934157..000000000 --- a/plugins/bot/util/collection.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { Bot } from "../bot.ts"; - -export class BotCollection extends Map { - maxSize: number | undefined; - sweeper: BotCollectionSweeper & { intervalId?: number } | undefined; - - constructor(entries?: (readonly (readonly [K, V])[] | null) | Map, options?: BotCollectionOptions) { - super(entries ?? []); - - this.maxSize = options?.maxSize; - - if (!options?.sweeper) return; - - this.startSweeper(options.sweeper); - } - - startSweeper(options: BotCollectionSweeper): number { - if (this.sweeper?.intervalId) clearInterval(this.sweeper.intervalId); - - this.sweeper = options; - this.sweeper.intervalId = setInterval(() => { - this.forEach((value, key) => { - if (!this.sweeper?.filter(value, key, options.bot)) return; - - this.delete(key); - return key; - }); - }, options.interval); - - return this.sweeper.intervalId!; - } - - stopSweeper(): void { - return clearInterval(this.sweeper?.intervalId); - } - - changeSweeperInterval(newInterval: number) { - if (!this.sweeper) return; - - this.startSweeper({ filter: this.sweeper.filter, interval: newInterval }); - } - - changeSweeperFilter(newFilter: (value: V, key: K, bot: Bot) => boolean) { - if (!this.sweeper) return; - - this.startSweeper({ filter: newFilter, interval: this.sweeper.interval }); - } - - set(key: K, value: V) { - // When this collection is maxSized make sure we can add first - if ((this.maxSize || this.maxSize === 0) && this.size >= this.maxSize) { - return this; - } - - return super.set(key, value); - } - - forceSet(key: K, value: V) { - return super.set(key, value); - } - - array() { - return [...this.values()]; - } - - /** Retrieve the value of the first element in this collection */ - first(): V | undefined { - return this.values().next().value; - } - - last(): V | undefined { - return [...this.values()][this.size - 1]; - } - - random(): V | undefined { - const array = [...this.values()]; - return array[Math.floor(Math.random() * array.length)]; - } - - find(callback: (value: V, key: K) => boolean) { - for (const key of this.keys()) { - const value = this.get(key)!; - if (callback(value, key)) return value; - } - // If nothing matched - return; - } - - filter(callback: (value: V, key: K) => boolean) { - const relevant = new BotCollection(); - this.forEach((value, key) => { - if (callback(value, key)) relevant.set(key, value); - }); - - return relevant; - } - - map(callback: (value: V, key: K) => T) { - const results = []; - for (const key of this.keys()) { - const value = this.get(key)!; - results.push(callback(value, key)); - } - return results; - } - - some(callback: (value: V, key: K) => boolean) { - for (const key of this.keys()) { - const value = this.get(key)!; - if (callback(value, key)) return true; - } - - return false; - } - - every(callback: (value: V, key: K) => boolean) { - for (const key of this.keys()) { - const value = this.get(key)!; - if (!callback(value, key)) return false; - } - - return true; - } - - reduce(callback: (accumulator: T, value: V, key: K) => T, initialValue?: T): T { - let accumulator: T = initialValue!; - - for (const key of this.keys()) { - const value = this.get(key)!; - accumulator = callback(accumulator, value, key); - } - - return accumulator; - } -} - -export interface BotCollectionOptions { - sweeper?: BotCollectionSweeper; - maxSize?: number; -} - -export interface BotCollectionSweeper { - /** The filter to determine whether an element should be deleted or not */ - filter: (value: V, key: K, ...args: any[]) => boolean; - /** The interval in which the sweeper should run */ - interval: number; - /** The bot object itself */ - bot?: Bot; -} diff --git a/plugins/bot/util/mod.ts b/plugins/bot/util/mod.ts deleted file mode 100644 index 14d9f9c1c..000000000 --- a/plugins/bot/util/mod.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./bigint.ts"; -export * from "./collection.ts"; -export * from "./hash.ts"; -export * from "./permissions.ts"; -export * from "./routes.ts"; -export * from "./urlToBase64.ts"; -export * from "./utils.ts"; -export * from "./validateLength.ts"; diff --git a/rest/createRequestBody.ts b/rest/createRequestBody.ts index 9781c7a63..97855debd 100644 --- a/rest/createRequestBody.ts +++ b/rest/createRequestBody.ts @@ -1,5 +1,5 @@ import { RestManager } from "./restManager.ts"; -import { FileContent } from "../types/shared.ts"; +import { FileContent } from "../types/discordeno.ts"; import { USER_AGENT } from "../util/constants.ts"; import { RequestMethod, RestPayload, RestRequest } from "./rest.ts"; diff --git a/rest/runMethod.ts b/rest/runMethod.ts index b7ea8fd02..f1c3d18e5 100644 --- a/rest/runMethod.ts +++ b/rest/runMethod.ts @@ -43,10 +43,8 @@ export async function runMethod( }); if (!result.ok) { - errorStack.message = result.statusText; - rest.debug(`[ERROR] ${errorStack.message}`); - // Closes the response to prevent memory leak - await result.text(); + errorStack.message = result.statusText as Error["message"]; + console.error(`Error: ${errorStack.message}`); throw errorStack; } diff --git a/template/bigbot/src/bot/types/command.ts b/template/bigbot/src/bot/types/command.ts index 8d498a2e8..6a15f5d90 100644 --- a/template/bigbot/src/bot/types/command.ts +++ b/template/bigbot/src/bot/types/command.ts @@ -190,41 +190,41 @@ export type ConvertArgumentDefinitionsToArgs< [P in keyof T]: T[P] extends StringOptionalArgumentDefinition // STRING ? { [_ in getName]?: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb - T[P]["choices"][number]["value"] + T[P]["choices"][number]["value"] : string; } : T[P] extends StringArgumentDefinition ? { - [_ in getName]: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb - T[P]["choices"][number]["value"] - : string; - } + [_ in getName]: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb + T[P]["choices"][number]["value"] + : string; + } : // INTEGER T[P] extends IntegerOptionalArgumentDefinition ? { - [_ in getName]?: T[P]["choices"] extends readonly { name: string; value: number }[] ? // @ts-ignore ts being dumb - T[P]["choices"][number]["value"] - : number; - } + [_ in getName]?: T[P]["choices"] extends readonly { name: string; value: number }[] ? // @ts-ignore ts being dumb + T[P]["choices"][number]["value"] + : number; + } : T[P] extends IntegerArgumentDefinition ? { - [_ in getName]: T[P]["choices"] extends readonly { name: string; value: number }[] ? // @ts-ignore ts being dumb - T[P]["choices"][number]["value"] - : number; - } + [_ in getName]: T[P]["choices"] extends readonly { name: string; value: number }[] ? // @ts-ignore ts being dumb + T[P]["choices"][number]["value"] + : number; + } : // BOOLEAN T[P] extends BooleanOptionalArgumentDefinition ? { [_ in getName]?: boolean } : T[P] extends BooleanArgumentDefinition ? { [_ in getName]: boolean } : // USER T[P] extends UserOptionalArgumentDefinition ? { - [_ in getName]?: { - user: User; - member: Member; - }; - } + [_ in getName]?: { + user: User; + member: Member; + }; + } : T[P] extends UserArgumentDefinition ? { - [_ in getName]: { - user: User; - member: Member; - }; - } + [_ in getName]: { + user: User; + member: Member; + }; + } : // CHANNEL T[P] extends ChannelOptionalArgumentDefinition ? { [_ in getName]?: Channel } : T[P] extends ChannelArgumentDefinition ? { [_ in getName]: Channel } @@ -233,30 +233,30 @@ export type ConvertArgumentDefinitionsToArgs< : T[P] extends RoleArgumentDefinition ? { [_ in getName]: Role } : // MENTIONABLE T[P] extends MentionableOptionalArgumentDefinition ? { - [_ in getName]?: Role | { - user: User; - member: Member; - }; - } + [_ in getName]?: Role | { + user: User; + member: Member; + }; + } : T[P] extends MentionableArgumentDefinition ? { - [_ in getName]: Role | { - user: User; - member: Member; - }; - } + [_ in getName]: Role | { + user: User; + member: Member; + }; + } : // SUBCOMMAND T[P] extends SubcommandArgumentDefinition ? { - [_ in getName]?: T[P]["options"] extends readonly ArgumentDefinition[] ? // @ts-ignore ignore this for a bit - ConvertArgumentDefinitionsToArgs - : // deno-lint-ignore ban-types - {}; - } + [_ in getName]?: T[P]["options"] extends readonly ArgumentDefinition[] ? // @ts-ignore ignore this for a bit + ConvertArgumentDefinitionsToArgs + : // deno-lint-ignore ban-types + {}; + } : // SUBCOMMAND GROUP T[P] extends SubcommandGroupArgumentDefinition ? { - [_ in getName]?: ConvertArgumentDefinitionsToArgs< - T[P]["options"] - >; - } + [_ in getName]?: ConvertArgumentDefinitionsToArgs< + T[P]["options"] + >; + } : never; }[number] > diff --git a/tests/channels/deleteWithReason.test.ts b/tests/channels/deleteWithReason.test.ts index f961ae81d..8f56ced12 100644 --- a/tests/channels/deleteWithReason.test.ts +++ b/tests/channels/deleteWithReason.test.ts @@ -1,4 +1,4 @@ -import { assertExists, assertRejects } from "../deps.ts"; +import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; @@ -17,8 +17,7 @@ Deno.test({ await bot.helpers.deleteChannel(channel.id, "with a reason"); // Check if channel still exists - await assertRejects( - () => bot.helpers.getChannel(channel.id), - ); + const exists = await bot.helpers.getChannel(channel.id); + assertEquals(exists, undefined); }, }); diff --git a/tests/channels/deleteWithoutReason.test.ts b/tests/channels/deleteWithoutReason.test.ts index 595a25eb4..9295dfa4b 100644 --- a/tests/channels/deleteWithoutReason.test.ts +++ b/tests/channels/deleteWithoutReason.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertExists, assertRejects } from "../deps.ts"; +import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; @@ -18,8 +18,7 @@ Deno.test({ await bot.helpers.deleteChannel(channel.id); // Check if channel still exists - await assertRejects( - () => bot.helpers.getChannel(channel.id), - ); + const exists = await bot.helpers.getChannel(channel.id); + assertEquals(exists, undefined); }, }); diff --git a/tests/channels/messages/message.test.ts b/tests/channels/messages/message.test.ts index 4263ec206..20f5e3825 100644 --- a/tests/channels/messages/message.test.ts +++ b/tests/channels/messages/message.test.ts @@ -1,5 +1,5 @@ import { ButtonStyles, ChannelTypes, delay, MessageComponentTypes } from "../../../mod.ts"; -import { assertEquals, assertExists, assertNotEquals, assertRejects } from "../../deps.ts"; +import { assertEquals, assertExists, assertNotEquals } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; @@ -167,7 +167,8 @@ Deno.test({ assertEquals(message.content, "Hello Skillz"); await bot.helpers.deleteMessage(channel.id, message.id, "Test"); - await assertRejects(() => bot.helpers.getMessage(channel.id, message.id)); + const deletedMessage = await bot.helpers.getMessage(channel.id, message.id); + assertEquals(deletedMessage, undefined); }); // Delete the message without a reason @@ -179,7 +180,8 @@ Deno.test({ assertEquals(message.content, "Hello Skillz"); await bot.helpers.deleteMessage(channel.id, message.id); - await assertRejects(() => bot.helpers.getMessage(channel.id, message.id)); + const deletedMessage = await bot.helpers.getMessage(channel.id, message.id); + assertEquals(deletedMessage, undefined); }); // Bulk delete messages with a reason @@ -197,8 +199,10 @@ Deno.test({ assertEquals(message2.content, "Hello Skillz 2"); await bot.helpers.deleteMessages(channel.id, [message1.id, message2.id], "Test"); - await assertRejects(() => bot.helpers.getMessage(channel.id, message1.id)); - await assertRejects(() => bot.helpers.getMessage(channel.id, message2.id)); + const deletedMessage1 = await bot.helpers.getMessage(channel.id, message1.id); + assertEquals(deletedMessage1, undefined); + const deletedMessage2 = await bot.helpers.getMessage(channel.id, message2.id); + assertEquals(deletedMessage2, undefined); }); // Bulk delete messages without a reason @@ -217,8 +221,10 @@ Deno.test({ await bot.helpers.deleteMessages(channel.id, [message1.id, message2.id]); await delay(3000); - await assertRejects(() => bot.helpers.getMessage(channel.id, message1.id)); - await assertRejects(() => bot.helpers.getMessage(channel.id, message2.id)); + const deletedMessage1 = await bot.helpers.getMessage(channel.id, message1.id); + assertEquals(deletedMessage1, undefined); + const deletedMessage2 = await bot.helpers.getMessage(channel.id, message2.id); + assertEquals(deletedMessage2, undefined); }); // Get a message diff --git a/tests/guilds/events/events.test.ts b/tests/guilds/events/events.test.ts index 842b76494..57969fb6a 100644 --- a/tests/guilds/events/events.test.ts +++ b/tests/guilds/events/events.test.ts @@ -1,5 +1,5 @@ import { ChannelTypes, ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../mod.ts"; -import { assertEquals, assertExists, assertRejects } from "../../deps.ts"; +import { assertEquals, assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; @@ -179,9 +179,8 @@ Deno.test({ "[scheduled event] delete the guild scheduled event.", async () => { await bot.helpers.deleteScheduledEvent(CACHED_COMMUNITY_GUILD_ID, event.id); - await assertRejects( - () => bot.helpers.getScheduledEvent(CACHED_COMMUNITY_GUILD_ID, event.id), - ); + const fetchedEvent = await bot.helpers.getScheduledEvent(CACHED_COMMUNITY_GUILD_ID, event.id); + assertEquals(fetchedEvent, undefined); }, ); diff --git a/tests/guilds/guild.test.ts b/tests/guilds/guild.test.ts index e46809b4c..226d880b4 100644 --- a/tests/guilds/guild.test.ts +++ b/tests/guilds/guild.test.ts @@ -1,11 +1,14 @@ import { ChannelTypes } from "../../mod.ts"; -import { assertEquals, assertExists, assertNotEquals, assertRejects } from "../deps.ts"; +import { assertEquals, assertExists, assertNotEquals } from "../deps.ts"; import { loadBot } from "../mod.ts"; Deno.test({ name: "[guild] Create a guild", async fn(t) { const bot = loadBot(); + + // Delete the oldest guild(most likely to have finished tests). + const guild = await bot.helpers.createGuild({ name: "Discordeno-test", }); @@ -85,7 +88,8 @@ Deno.test({ // Get vanity URL await t.step("[guild] Get vanity URL", async () => { - await assertRejects(() => bot.helpers.getVanityUrl(guild.id)); + const vanityUrl = await bot.helpers.getVanityUrl(guild.id); + assertEquals(vanityUrl.code, undefined); }); // Emoji related tests @@ -124,9 +128,8 @@ Deno.test({ await bot.helpers.deleteEmoji(guild.id, emoji.id); - await assertRejects( - () => bot.helpers.getEmoji(guild.id, emoji.id!), - ); + const exists = await bot.helpers.getEmoji(guild.id, emoji.id); + assertEquals(exists.id, undefined); }, }); @@ -146,9 +149,8 @@ Deno.test({ await bot.helpers.deleteEmoji(guild.id, emoji.id, "with a reason"); - await assertRejects( - () => bot.helpers.getEmoji(guild.id, emoji.id!), - ); + const exists = await bot.helpers.getEmoji(guild.id, emoji.id); + assertEquals(exists.id, undefined); }, }); @@ -263,10 +265,9 @@ Deno.test({ // Delete a guild await t.step("[guild] Delete a guild", async () => { await bot.helpers.deleteGuild(guild.id); - - await assertRejects( - () => bot.helpers.getGuild(guild.id), - ); + // + const exists = await bot.helpers.getGuild(guild.id); + assertEquals(exists, undefined); }); } catch (error) { // If any errors arise, delete the guild diff --git a/tests/guilds/members/bans.test.ts b/tests/guilds/members/bans.test.ts index e7aa87170..2decad742 100644 --- a/tests/guilds/members/bans.test.ts +++ b/tests/guilds/members/bans.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertExists, assertRejects } from "../../deps.ts"; +import { assertEquals, assertExists } from "../../deps.ts"; import { loadBot } from "../../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../../utils.ts"; @@ -66,9 +66,7 @@ Deno.test({ bot.helpers.unbanMember(CACHED_COMMUNITY_GUILD_ID, ianID), ]); - await assertRejects( - () => bot.helpers.getBan(CACHED_COMMUNITY_GUILD_ID, wolfID), - ); + assertEquals(await bot.helpers.getBan(CACHED_COMMUNITY_GUILD_ID, wolfID), undefined); }, }); }, diff --git a/tests/mod.ts b/tests/mod.ts index a0151d535..12827381a 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -1,4 +1,4 @@ -import { createBot, createRestManager } from "../plugins/bot/mod.ts"; +import { createBot, createRestManager, runMethod } from "../mod.ts"; import { dotenv } from "./deps.ts"; dotenv({ export: true, path: `${Deno.cwd()}/.env` }); diff --git a/tests/rest.ts b/tests/rest.ts index 306b7fa46..301846ed5 100644 --- a/tests/rest.ts +++ b/tests/rest.ts @@ -87,9 +87,8 @@ async function handleRequest(conn: Deno.Conn) { error.code, error, ); - requestEvent.respondWith( - new Response(error.message, { + new Response(JSON.stringify(error), { status: error.code ?? 469, }), ); diff --git a/tests/utils.test.ts b/tests/utils.test.ts index cb6b1a5ce..a4aaea2dd 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -1,13 +1,6 @@ -import { - bigintToSnowflake, - formatImageURL, - hasProperty, - iconBigintToHash, - iconHashToBigInt, - removeTokenPrefix, - snowflakeToBigint, - validateLength, -} from "../plugins/bot/mod.ts"; +import { formatImageURL, hasProperty, iconBigintToHash, iconHashToBigInt, validateLength } from "../mod.ts"; +import { bigintToSnowflake, snowflakeToBigint } from "../util/bigint.ts"; +import { removeTokenPrefix } from "../util/token.ts"; import { assertEquals, assertNotEquals } from "./deps.ts"; import { loadBot } from "./mod.ts"; diff --git a/tests/webhook/deleteWebhook.test.ts b/tests/webhook/deleteWebhook.test.ts index 75a399c3a..c8ad9029f 100644 --- a/tests/webhook/deleteWebhook.test.ts +++ b/tests/webhook/deleteWebhook.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertExists, assertRejects } from "../deps.ts"; +import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; @@ -16,9 +16,9 @@ Deno.test({ await bot.helpers.deleteWebhook(webhook.id); // Fetch the webhook to validate it was deleted - await assertRejects( - () => bot.helpers.getWebhook(webhook.id), - ); + const deletedWebhook = await bot.helpers.getWebhook(webhook.id); + + assertEquals(deletedWebhook, undefined); await bot.helpers.deleteChannel(channel.id); }, diff --git a/tests/webhook/deleteWebhookWithToken.test.ts b/tests/webhook/deleteWebhookWithToken.test.ts index cea284791..2554d5e60 100644 --- a/tests/webhook/deleteWebhookWithToken.test.ts +++ b/tests/webhook/deleteWebhookWithToken.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertExists, assertRejects } from "../deps.ts"; +import { assertEquals, assertExists } from "../deps.ts"; import { loadBot } from "../mod.ts"; import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; @@ -17,9 +17,9 @@ Deno.test({ await bot.helpers.deleteWebhookWithToken(webhook.id, webhook.token); // Fetch the webhook to validate it was deleted - await assertRejects( - () => bot.helpers.getWebhook(webhook.id), - ); + const deletedWebhook = await bot.helpers.getWebhook(webhook.id); + + assertEquals(deletedWebhook, undefined); await bot.helpers.deleteChannel(channel.id); }, diff --git a/plugins/bot/transformers/activity.ts b/transformers/activity.ts similarity index 92% rename from plugins/bot/transformers/activity.ts rename to transformers/activity.ts index 649828f31..51744ead2 100644 --- a/plugins/bot/transformers/activity.ts +++ b/transformers/activity.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordActivity, Optionalize } from "../deps.ts"; +import { DiscordActivity } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformActivity(bot: Bot, payload: DiscordActivity) { const activity = { diff --git a/plugins/bot/transformers/application.ts b/transformers/application.ts similarity index 91% rename from plugins/bot/transformers/application.ts rename to transformers/application.ts index 85d61975f..16a1f0e4a 100644 --- a/plugins/bot/transformers/application.ts +++ b/transformers/application.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordApplication, Optionalize } from "../deps.ts"; +import { DiscordApplication } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformApplication(bot: Bot, payload: DiscordApplication) { const application = { diff --git a/plugins/bot/transformers/applicationCommand.ts b/transformers/applicationCommand.ts similarity index 90% rename from plugins/bot/transformers/applicationCommand.ts rename to transformers/applicationCommand.ts index a69651c53..f1cad2182 100644 --- a/plugins/bot/transformers/applicationCommand.ts +++ b/transformers/applicationCommand.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordApplicationCommand, Optionalize } from "../deps.ts"; +import { DiscordApplicationCommand } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformApplicationCommand(bot: Bot, payload: DiscordApplicationCommand) { const applicationCommand = { diff --git a/plugins/bot/transformers/applicationCommandOption.ts b/transformers/applicationCommandOption.ts similarity index 89% rename from plugins/bot/transformers/applicationCommandOption.ts rename to transformers/applicationCommandOption.ts index f58abc186..38f1d7c94 100644 --- a/plugins/bot/transformers/applicationCommandOption.ts +++ b/transformers/applicationCommandOption.ts @@ -1,5 +1,7 @@ import { Bot } from "../bot.ts"; -import { ApplicationCommandOptionTypes, ChannelTypes, DiscordApplicationCommandOption, Localization } from "../deps.ts"; +import { DiscordApplicationCommandOption, DiscordApplicationCommandOptionChoice } from "../types/discord.ts"; +import { ApplicationCommandOptionTypes, ChannelTypes, Localization } from "../types/shared.ts"; +import { Optionalize } from "../types/shared.ts"; import { ApplicationCommandOptionChoice } from "./applicationCommandOptionChoice.ts"; export function transformApplicationCommandOption( diff --git a/plugins/bot/transformers/applicationCommandOptionChoice.ts b/transformers/applicationCommandOptionChoice.ts similarity index 77% rename from plugins/bot/transformers/applicationCommandOptionChoice.ts rename to transformers/applicationCommandOptionChoice.ts index 31f3c1f16..edbaf6167 100644 --- a/plugins/bot/transformers/applicationCommandOptionChoice.ts +++ b/transformers/applicationCommandOptionChoice.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordApplicationCommandOptionChoice, Optionalize } from "../deps.ts"; +import { DiscordApplicationCommandOptionChoice } from "../types/discord.ts"; +import { Camelize, Localization, Optionalize } from "../types/shared.ts"; export function transformApplicationCommandOptionChoice(bot: Bot, payload: DiscordApplicationCommandOptionChoice) { const applicationCommandChoice = { diff --git a/plugins/bot/transformers/applicationCommandPermission.ts b/transformers/applicationCommandPermission.ts similarity index 85% rename from plugins/bot/transformers/applicationCommandPermission.ts rename to transformers/applicationCommandPermission.ts index 11ffbe6ee..6e8b0f9cd 100644 --- a/plugins/bot/transformers/applicationCommandPermission.ts +++ b/transformers/applicationCommandPermission.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordGuildApplicationCommandPermissions, Optionalize } from "../deps.ts"; +import { DiscordGuildApplicationCommandPermissions } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformApplicationCommandPermission(bot: Bot, payload: DiscordGuildApplicationCommandPermissions) { const applicationCommandPermission = { diff --git a/plugins/bot/transformers/attachment.ts b/transformers/attachment.ts similarity index 84% rename from plugins/bot/transformers/attachment.ts rename to transformers/attachment.ts index 82d425f5e..370f56dab 100644 --- a/plugins/bot/transformers/attachment.ts +++ b/transformers/attachment.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordAttachment, Optionalize } from "../deps.ts"; +import { DiscordAttachment } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformAttachment(bot: Bot, payload: DiscordAttachment) { const attachment = { diff --git a/plugins/bot/transformers/auditLogEntry.ts b/transformers/auditLogEntry.ts similarity index 97% rename from plugins/bot/transformers/auditLogEntry.ts rename to transformers/auditLogEntry.ts index 31f8687f8..398d1518b 100644 --- a/plugins/bot/transformers/auditLogEntry.ts +++ b/transformers/auditLogEntry.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordAuditLogEntry, Optionalize } from "../deps.ts"; +import { DiscordAuditLogEntry } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry) { const auditLogEntry = { diff --git a/plugins/bot/transformers/automodActionExecution.ts b/transformers/automodActionExecution.ts similarity index 91% rename from plugins/bot/transformers/automodActionExecution.ts rename to transformers/automodActionExecution.ts index ece01b9a9..bc8712087 100644 --- a/plugins/bot/transformers/automodActionExecution.ts +++ b/transformers/automodActionExecution.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordAutoModerationActionExecution, Optionalize } from "../deps.ts"; +import { DiscordAutoModerationActionExecution } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformAutoModerationActionExecution(bot: Bot, payload: DiscordAutoModerationActionExecution) { const rule = { diff --git a/plugins/bot/transformers/automodRule.ts b/transformers/automodRule.ts similarity index 91% rename from plugins/bot/transformers/automodRule.ts rename to transformers/automodRule.ts index 46344a35d..0d77c3346 100644 --- a/plugins/bot/transformers/automodRule.ts +++ b/transformers/automodRule.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordAutoModerationRule, Optionalize } from "../deps.ts"; +import { DiscordAutoModerationRule } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformAutoModerationRule(bot: Bot, payload: DiscordAutoModerationRule) { const rule = { diff --git a/plugins/bot/transformers/channel.ts b/transformers/channel.ts similarity index 97% rename from plugins/bot/transformers/channel.ts rename to transformers/channel.ts index 42cf9cee4..ccbe70887 100644 --- a/plugins/bot/transformers/channel.ts +++ b/transformers/channel.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordChannel, Optionalize } from "../deps.ts"; +import { DiscordChannel } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; const Mask = (1n << 64n) - 1n; diff --git a/plugins/bot/transformers/component.ts b/transformers/component.ts similarity index 94% rename from plugins/bot/transformers/component.ts rename to transformers/component.ts index bb5c64c16..9ee322ac8 100644 --- a/plugins/bot/transformers/component.ts +++ b/transformers/component.ts @@ -1,6 +1,6 @@ import { Bot } from "../bot.ts"; -import { ButtonStyles, DiscordComponent, MessageComponentTypes, TextStyles } from "../deps.ts"; -import { SelectOption } from "../typings.ts"; +import { ButtonStyles, MessageComponentTypes, SelectOption, TextStyles } from "../mod.ts"; +import { DiscordComponent } from "../types/discord.ts"; export function transformComponent(bot: Bot, payload: DiscordComponent): Component { return { diff --git a/plugins/bot/transformers/embed.ts b/transformers/embed.ts similarity index 93% rename from plugins/bot/transformers/embed.ts rename to transformers/embed.ts index 2b99e1a70..bab34f0e2 100644 --- a/plugins/bot/transformers/embed.ts +++ b/transformers/embed.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordEmbed, Optionalize } from "../deps.ts"; +import { DiscordEmbed } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformEmbed(bot: Bot, payload: DiscordEmbed) { const embed = { diff --git a/plugins/bot/transformers/emoji.ts b/transformers/emoji.ts similarity index 85% rename from plugins/bot/transformers/emoji.ts rename to transformers/emoji.ts index fa824350a..b3214b914 100644 --- a/plugins/bot/transformers/emoji.ts +++ b/transformers/emoji.ts @@ -1,6 +1,7 @@ import { Bot } from "../bot.ts"; -import { DiscordEmoji, Optionalize } from "../deps.ts"; +import { DiscordEmoji } from "../types/discord.ts"; import { EmojiToggles } from "./toggles/emoji.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformEmoji(bot: Bot, payload: DiscordEmoji) { const emoji = { diff --git a/plugins/bot/transformers/gatewayBot.ts b/transformers/gatewayBot.ts similarity index 83% rename from plugins/bot/transformers/gatewayBot.ts rename to transformers/gatewayBot.ts index 3ec730c0b..be7f40f21 100644 --- a/plugins/bot/transformers/gatewayBot.ts +++ b/transformers/gatewayBot.ts @@ -1,4 +1,5 @@ -import { DiscordGetGatewayBot, Optionalize } from "../deps.ts"; +import { DiscordGetGatewayBot } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformGatewayBot(payload: DiscordGetGatewayBot) { const gatewayBot = { diff --git a/plugins/bot/transformers/guild.ts b/transformers/guild.ts similarity index 96% rename from plugins/bot/transformers/guild.ts rename to transformers/guild.ts index b26295084..788e2e77a 100644 --- a/plugins/bot/transformers/guild.ts +++ b/transformers/guild.ts @@ -1,8 +1,9 @@ import type { Emoji } from "../transformers/emoji.ts"; import { Bot } from "../bot.ts"; -import { BotCollection as Collection } from "../util/collection.ts"; +import { Collection } from "../util/collection.ts"; +import { DiscordGuild } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; import { GuildToggles } from "./toggles/guild.ts"; -import { DiscordGuild, Optionalize } from "../deps.ts"; export function transformGuild(bot: Bot, payload: { guild: DiscordGuild } & { shardId: number }) { const guildId = bot.transformers.snowflake(payload.guild.id); diff --git a/plugins/bot/transformers/integration.ts b/transformers/integration.ts similarity index 92% rename from plugins/bot/transformers/integration.ts rename to transformers/integration.ts index c8bcc63e8..1098fe211 100644 --- a/plugins/bot/transformers/integration.ts +++ b/transformers/integration.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordIntegrationCreateUpdate, Optionalize } from "../deps.ts"; +import { DiscordIntegrationCreateUpdate } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreateUpdate) { const integration = { diff --git a/plugins/bot/transformers/interaction.ts b/transformers/interaction.ts similarity index 96% rename from plugins/bot/transformers/interaction.ts rename to transformers/interaction.ts index 9b8ff3228..eb8f8292f 100644 --- a/plugins/bot/transformers/interaction.ts +++ b/transformers/interaction.ts @@ -1,17 +1,17 @@ import { Bot } from "../bot.ts"; import { - ChannelTypes, DiscordAttachment, DiscordInteraction, DiscordInteractionDataOption, DiscordInteractionDataResolved, - Optionalize, -} from "../deps.ts"; -import { BotCollection as Collection } from "../util/collection.ts"; +} from "../types/discord.ts"; +import { ChannelTypes } from "../types/shared.ts"; +import { Collection } from "../util/collection.ts"; import { Attachment } from "./attachment.ts"; import { Member, User } from "./member.ts"; import { Message } from "./message.ts"; import { Role } from "./role.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformInteraction(bot: Bot, payload: DiscordInteraction) { const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined; diff --git a/plugins/bot/transformers/invite.ts b/transformers/invite.ts similarity index 94% rename from plugins/bot/transformers/invite.ts rename to transformers/invite.ts index 37764002c..19364bd64 100644 --- a/plugins/bot/transformers/invite.ts +++ b/transformers/invite.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordInviteCreate, Optionalize } from "../deps.ts"; +import { DiscordInviteCreate } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformInvite(bot: Bot, invite: DiscordInviteCreate) { const transformedInvite = { diff --git a/plugins/bot/transformers/member.ts b/transformers/member.ts similarity index 91% rename from plugins/bot/transformers/member.ts rename to transformers/member.ts index 341c9cb83..48b8bcdb0 100644 --- a/plugins/bot/transformers/member.ts +++ b/transformers/member.ts @@ -1,7 +1,8 @@ -import { Bot } from "../bot.ts"; -import { DiscordMember, DiscordUser, Optionalize } from "../deps.ts"; +import type { Bot } from "../bot.ts"; +import { DiscordMember, DiscordUser } from "../types/discord.ts"; import { MemberToggles } from "./toggles/member.ts"; import { UserToggles } from "./toggles/user.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformUser(bot: Bot, payload: DiscordUser) { const user = { diff --git a/plugins/bot/transformers/message.ts b/transformers/message.ts similarity index 96% rename from plugins/bot/transformers/message.ts rename to transformers/message.ts index 8c56b489f..4a0c421a8 100644 --- a/plugins/bot/transformers/message.ts +++ b/transformers/message.ts @@ -1,6 +1,8 @@ import { Bot } from "../bot.ts"; -import { CHANNEL_MENTION_REGEX, DiscordMessage, Optionalize } from "../deps.ts"; +import { DiscordMessage } from "../types/discord.ts"; +import { CHANNEL_MENTION_REGEX } from "../util/constants.ts"; import { MemberToggles } from "./toggles/member.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformMessage(bot: Bot, payload: DiscordMessage) { const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined; diff --git a/plugins/bot/transformers/mod.ts b/transformers/mod.ts similarity index 100% rename from plugins/bot/transformers/mod.ts rename to transformers/mod.ts diff --git a/plugins/bot/transformers/presence.ts b/transformers/presence.ts similarity index 92% rename from plugins/bot/transformers/presence.ts rename to transformers/presence.ts index 34f79a806..403ff7e3e 100644 --- a/plugins/bot/transformers/presence.ts +++ b/transformers/presence.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordPresenceUpdate, Optionalize } from "../deps.ts"; +import { DiscordPresenceUpdate } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; import { UserToggles } from "./toggles/user.ts"; export const statusTypes = Object.freeze({ diff --git a/plugins/bot/transformers/reverse/activity.ts b/transformers/reverse/activity.ts similarity index 95% rename from plugins/bot/transformers/reverse/activity.ts rename to transformers/reverse/activity.ts index 945fa4ec4..a5c8a6335 100644 --- a/plugins/bot/transformers/reverse/activity.ts +++ b/transformers/reverse/activity.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordActivity } from "../../deps.ts"; +import { DiscordActivity } from "../../types/discord.ts"; import { Activity } from "../activity.ts"; export function transformActivityToDiscordActivity(bot: Bot, payload: Activity): DiscordActivity { diff --git a/plugins/bot/transformers/reverse/allowedMentions.ts b/transformers/reverse/allowedMentions.ts similarity index 69% rename from plugins/bot/transformers/reverse/allowedMentions.ts rename to transformers/reverse/allowedMentions.ts index 529b6ed7f..690a68fd0 100644 --- a/plugins/bot/transformers/reverse/allowedMentions.ts +++ b/transformers/reverse/allowedMentions.ts @@ -1,6 +1,4 @@ -import { Bot } from "../../bot.ts"; -import { DiscordAllowedMentions } from "../../deps.ts"; -import { AllowedMentions } from "../../typings.ts"; +import { AllowedMentions, Bot, DiscordAllowedMentions } from "../../mod.ts"; export function transformAllowedMentionsToDiscordAllowedMentions( bot: Bot, diff --git a/plugins/bot/transformers/reverse/application.ts b/transformers/reverse/application.ts similarity index 94% rename from plugins/bot/transformers/reverse/application.ts rename to transformers/reverse/application.ts index 54d28ca8f..db746e255 100644 --- a/plugins/bot/transformers/reverse/application.ts +++ b/transformers/reverse/application.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordApplication } from "../../deps.ts"; +import { DiscordApplication } from "../../types/discord.ts"; import { Application } from "../application.ts"; export function transformApplicationToDiscordApplication(bot: Bot, payload: Application): DiscordApplication { diff --git a/plugins/bot/transformers/reverse/component.ts b/transformers/reverse/component.ts similarity index 95% rename from plugins/bot/transformers/reverse/component.ts rename to transformers/reverse/component.ts index 360f353d1..7d142b156 100644 --- a/plugins/bot/transformers/reverse/component.ts +++ b/transformers/reverse/component.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordComponent } from "../../deps.ts"; +import { DiscordComponent } from "../../types/discord.ts"; import { Component } from "../component.ts"; export function transformComponentToDiscordComponent(bot: Bot, payload: Component): DiscordComponent { diff --git a/plugins/bot/transformers/reverse/embed.ts b/transformers/reverse/embed.ts similarity index 96% rename from plugins/bot/transformers/reverse/embed.ts rename to transformers/reverse/embed.ts index 00d9db114..02bc31fdd 100644 --- a/plugins/bot/transformers/reverse/embed.ts +++ b/transformers/reverse/embed.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordEmbed } from "../../deps.ts"; +import { DiscordEmbed } from "../../types/discord.ts"; import { Embed } from "../embed.ts"; export function transformEmbedToDiscordEmbed(bot: Bot, payload: Embed): DiscordEmbed { diff --git a/plugins/bot/transformers/reverse/member.ts b/transformers/reverse/member.ts similarity index 93% rename from plugins/bot/transformers/reverse/member.ts rename to transformers/reverse/member.ts index 566cf4333..c3aa8aa18 100644 --- a/plugins/bot/transformers/reverse/member.ts +++ b/transformers/reverse/member.ts @@ -1,5 +1,5 @@ -import { Bot } from "../../bot.ts"; -import { DiscordMember, DiscordUser } from "../../deps.ts"; +import type { Bot } from "../../bot.ts"; +import { DiscordMember, DiscordUser } from "../../types/discord.ts"; import { Member, User } from "../member.ts"; export function transformUserToDiscordUser(bot: Bot, payload: User): DiscordUser { diff --git a/plugins/bot/transformers/reverse/mod.ts b/transformers/reverse/mod.ts similarity index 100% rename from plugins/bot/transformers/reverse/mod.ts rename to transformers/reverse/mod.ts diff --git a/plugins/bot/transformers/reverse/team.ts b/transformers/reverse/team.ts similarity index 92% rename from plugins/bot/transformers/reverse/team.ts rename to transformers/reverse/team.ts index 496c34ffe..dd3ad6f99 100644 --- a/plugins/bot/transformers/reverse/team.ts +++ b/transformers/reverse/team.ts @@ -1,5 +1,5 @@ import { Bot } from "../../bot.ts"; -import { DiscordTeam } from "../../deps.ts"; +import { DiscordTeam } from "../../types/discord.ts"; import { Team } from "../team.ts"; export function transformTeamToDiscordTeam(bot: Bot, payload: Team): DiscordTeam { diff --git a/plugins/bot/transformers/role.ts b/transformers/role.ts similarity index 90% rename from plugins/bot/transformers/role.ts rename to transformers/role.ts index 2816d5cb8..f5a9f05a6 100644 --- a/plugins/bot/transformers/role.ts +++ b/transformers/role.ts @@ -1,6 +1,7 @@ import { Bot } from "../bot.ts"; -import { DiscordRole, Optionalize } from "../deps.ts"; +import { DiscordRole } from "../types/discord.ts"; import { RoleToggles } from "./toggles/role.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformRole(bot: Bot, payload: { role: DiscordRole } & { guildId: bigint }) { const role = { diff --git a/plugins/bot/transformers/scheduledEvent.ts b/transformers/scheduledEvent.ts similarity index 92% rename from plugins/bot/transformers/scheduledEvent.ts rename to transformers/scheduledEvent.ts index 571c314f0..8c6bc08f9 100644 --- a/plugins/bot/transformers/scheduledEvent.ts +++ b/transformers/scheduledEvent.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordScheduledEvent, Optionalize } from "../deps.ts"; +import { DiscordScheduledEvent } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformScheduledEvent( bot: Bot, diff --git a/plugins/bot/transformers/stageInstance.ts b/transformers/stageInstance.ts similarity index 85% rename from plugins/bot/transformers/stageInstance.ts rename to transformers/stageInstance.ts index d00c68ca9..a88cdbe9a 100644 --- a/plugins/bot/transformers/stageInstance.ts +++ b/transformers/stageInstance.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordStageInstance, Optionalize } from "../deps.ts"; +import { DiscordStageInstance } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformStageInstance(bot: Bot, payload: DiscordStageInstance) { const stageInstance = { diff --git a/plugins/bot/transformers/sticker.ts b/transformers/sticker.ts similarity index 92% rename from plugins/bot/transformers/sticker.ts rename to transformers/sticker.ts index 7e6efdeed..bbf6f6f83 100644 --- a/plugins/bot/transformers/sticker.ts +++ b/transformers/sticker.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordSticker, DiscordStickerPack, Optionalize } from "../deps.ts"; +import { DiscordSticker, DiscordStickerPack } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformSticker(bot: Bot, payload: DiscordSticker) { const sticker = { diff --git a/plugins/bot/transformers/team.ts b/transformers/team.ts similarity index 87% rename from plugins/bot/transformers/team.ts rename to transformers/team.ts index b23f2a975..09a6a4e8a 100644 --- a/plugins/bot/transformers/team.ts +++ b/transformers/team.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordTeam, Optionalize } from "../deps.ts"; +import { DiscordTeam } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformTeam(bot: Bot, payload: DiscordTeam) { const id = bot.transformers.snowflake(payload.id); diff --git a/plugins/bot/transformers/template.ts b/transformers/template.ts similarity index 88% rename from plugins/bot/transformers/template.ts rename to transformers/template.ts index d915b85be..af76569b1 100644 --- a/plugins/bot/transformers/template.ts +++ b/transformers/template.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordTemplate, Optionalize } from "../deps.ts"; +import { DiscordTemplate } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformTemplate(bot: Bot, payload: DiscordTemplate) { const template = { diff --git a/plugins/bot/transformers/threadMember.ts b/transformers/threadMember.ts similarity index 85% rename from plugins/bot/transformers/threadMember.ts rename to transformers/threadMember.ts index 31190cc6e..8be600172 100644 --- a/plugins/bot/transformers/threadMember.ts +++ b/transformers/threadMember.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordThreadMember, DiscordThreadMemberGuildCreate, Optionalize } from "../deps.ts"; +import { DiscordThreadMember, DiscordThreadMemberGuildCreate } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformThreadMember(bot: Bot, payload: DiscordThreadMember) { const threadMember = { diff --git a/plugins/bot/transformers/toggles/ToggleBitfield.ts b/transformers/toggles/ToggleBitfield.ts similarity index 100% rename from plugins/bot/transformers/toggles/ToggleBitfield.ts rename to transformers/toggles/ToggleBitfield.ts diff --git a/plugins/bot/transformers/toggles/emoji.ts b/transformers/toggles/emoji.ts similarity index 96% rename from plugins/bot/transformers/toggles/emoji.ts rename to transformers/toggles/emoji.ts index c0ec54efd..43bdd1cd2 100644 --- a/plugins/bot/transformers/toggles/emoji.ts +++ b/transformers/toggles/emoji.ts @@ -1,4 +1,4 @@ -import { DiscordEmoji } from "../../deps.ts"; +import { DiscordEmoji, DiscordRole } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const EmojiToggle = { diff --git a/plugins/bot/transformers/toggles/guild.ts b/transformers/toggles/guild.ts similarity index 98% rename from plugins/bot/transformers/toggles/guild.ts rename to transformers/toggles/guild.ts index fdb21363f..5a1cfc59a 100644 --- a/plugins/bot/transformers/toggles/guild.ts +++ b/transformers/toggles/guild.ts @@ -1,5 +1,6 @@ -import { DiscordGuild, GuildFeatures } from "../../deps.ts"; -import { ToggleBitfieldBigint } from "./ToggleBitfield.ts"; +import { DiscordGuild } from "../../types/discord.ts"; +import { GuildFeatures } from "../../types/shared.ts"; +import { ToggleBitfield, ToggleBitfieldBigint } from "./ToggleBitfield.ts"; export const GuildToggle = { /** Whether the bot is the owner of the guild */ diff --git a/plugins/bot/transformers/toggles/member.ts b/transformers/toggles/member.ts similarity index 95% rename from plugins/bot/transformers/toggles/member.ts rename to transformers/toggles/member.ts index d1df6d64f..f37cf0c91 100644 --- a/plugins/bot/transformers/toggles/member.ts +++ b/transformers/toggles/member.ts @@ -1,4 +1,4 @@ -import { DiscordMember } from "../../deps.ts"; +import { DiscordMember, DiscordUser } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const MemberToggle = { diff --git a/plugins/bot/transformers/toggles/mod.ts b/transformers/toggles/mod.ts similarity index 100% rename from plugins/bot/transformers/toggles/mod.ts rename to transformers/toggles/mod.ts diff --git a/plugins/bot/transformers/toggles/role.ts b/transformers/toggles/role.ts similarity index 97% rename from plugins/bot/transformers/toggles/role.ts rename to transformers/toggles/role.ts index dec1b3e93..1325f74e6 100644 --- a/plugins/bot/transformers/toggles/role.ts +++ b/transformers/toggles/role.ts @@ -1,4 +1,4 @@ -import { DiscordRole } from "../../deps.ts"; +import { DiscordRole } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const RoleToggle = { diff --git a/plugins/bot/transformers/toggles/user.ts b/transformers/toggles/user.ts similarity index 97% rename from plugins/bot/transformers/toggles/user.ts rename to transformers/toggles/user.ts index af3801209..91267464d 100644 --- a/plugins/bot/transformers/toggles/user.ts +++ b/transformers/toggles/user.ts @@ -1,4 +1,4 @@ -import { DiscordUser } from "../../deps.ts"; +import { DiscordUser } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const UserToggle = { diff --git a/plugins/bot/transformers/toggles/voice.ts b/transformers/toggles/voice.ts similarity index 97% rename from plugins/bot/transformers/toggles/voice.ts rename to transformers/toggles/voice.ts index 2e0b0694d..17fc70441 100644 --- a/plugins/bot/transformers/toggles/voice.ts +++ b/transformers/toggles/voice.ts @@ -1,4 +1,4 @@ -import { DiscordVoiceState } from "../../deps.ts"; +import { DiscordUser, DiscordVoiceState } from "../../types/discord.ts"; import { ToggleBitfield } from "./ToggleBitfield.ts"; export const VoiceStateToggle = { diff --git a/plugins/bot/transformers/voiceRegion.ts b/transformers/voiceRegion.ts similarity index 79% rename from plugins/bot/transformers/voiceRegion.ts rename to transformers/voiceRegion.ts index a4cb8eda9..db128de09 100644 --- a/plugins/bot/transformers/voiceRegion.ts +++ b/transformers/voiceRegion.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordVoiceRegion, Optionalize } from "../deps.ts"; +import { DiscordVoiceRegion } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformVoiceRegion(bot: Bot, payload: DiscordVoiceRegion) { const voiceRegion = { diff --git a/plugins/bot/transformers/voiceState.ts b/transformers/voiceState.ts similarity index 90% rename from plugins/bot/transformers/voiceState.ts rename to transformers/voiceState.ts index 56017f297..7a032095f 100644 --- a/plugins/bot/transformers/voiceState.ts +++ b/transformers/voiceState.ts @@ -1,6 +1,7 @@ import { Bot } from "../bot.ts"; -import { DiscordVoiceState, Optionalize } from "../deps.ts"; +import { DiscordVoiceState } from "../types/discord.ts"; import { VoiceStateToggles } from "./toggles/voice.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformVoiceState(bot: Bot, payload: { voiceState: DiscordVoiceState } & { guildId: bigint }) { const voiceState = { diff --git a/plugins/bot/transformers/webhook.ts b/transformers/webhook.ts similarity index 93% rename from plugins/bot/transformers/webhook.ts rename to transformers/webhook.ts index cadc87b66..52398ed02 100644 --- a/plugins/bot/transformers/webhook.ts +++ b/transformers/webhook.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordWebhook, Optionalize } from "../deps.ts"; +import { DiscordWebhook } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformWebhook(bot: Bot, payload: DiscordWebhook) { const webhook = { diff --git a/plugins/bot/transformers/welcomeScreen.ts b/transformers/welcomeScreen.ts similarity index 85% rename from plugins/bot/transformers/welcomeScreen.ts rename to transformers/welcomeScreen.ts index 23f8aa370..06b9fb9c2 100644 --- a/plugins/bot/transformers/welcomeScreen.ts +++ b/transformers/welcomeScreen.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordWelcomeScreen, Optionalize } from "../deps.ts"; +import { DiscordWelcomeScreen } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformWelcomeScreen(bot: Bot, payload: DiscordWelcomeScreen) { const welcomeScreen = { diff --git a/plugins/bot/transformers/widget.ts b/transformers/widget.ts similarity index 89% rename from plugins/bot/transformers/widget.ts rename to transformers/widget.ts index db631df6a..a77960bdc 100644 --- a/plugins/bot/transformers/widget.ts +++ b/transformers/widget.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordGuildWidget, Optionalize } from "../deps.ts"; +import { DiscordGuildWidget } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformWidget(bot: Bot, payload: DiscordGuildWidget) { const widget = { diff --git a/plugins/bot/transformers/widgetSettings.ts b/transformers/widgetSettings.ts similarity index 75% rename from plugins/bot/transformers/widgetSettings.ts rename to transformers/widgetSettings.ts index 1dba70f65..2754e00c2 100644 --- a/plugins/bot/transformers/widgetSettings.ts +++ b/transformers/widgetSettings.ts @@ -1,5 +1,6 @@ import { Bot } from "../bot.ts"; -import { DiscordGuildWidgetSettings, Optionalize } from "../deps.ts"; +import { DiscordGuildWidgetSettings } from "../types/discord.ts"; +import { Optionalize } from "../types/shared.ts"; export function transformWidgetSettings(bot: Bot, payload: DiscordGuildWidgetSettings) { const widget = { diff --git a/types/discord.ts b/types/discord.ts index 37cd84c49..47b85414b 100644 --- a/types/discord.ts +++ b/types/discord.ts @@ -768,13 +768,6 @@ export interface DiscordPresenceUpdate { client_status: DiscordClientStatus; } -export interface DiscordStatusUpdate { - /** User's current activities */ - activities: DiscordActivity[]; - /** Either "idle", "dnd", "online", or "offline" */ - status: "idle" | "dnd" | "online" | "offline"; -} - /** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-structure */ export interface DiscordWelcomeScreen { /** The server description shown in the welcome screen */ diff --git a/plugins/bot/typings.ts b/types/discordeno.ts similarity index 96% rename from plugins/bot/typings.ts rename to types/discordeno.ts index 004ce64af..48ec45b74 100644 --- a/plugins/bot/typings.ts +++ b/types/discordeno.ts @@ -1,4 +1,4 @@ -import { AllowedMentionsTypes, ButtonStyles, MessageComponentTypes, TextStyles } from "./deps.ts"; +import { AllowedMentionsTypes, ButtonStyles, MessageComponentTypes, TextStyles } from "./shared.ts"; export type MessageComponents = ActionRow[]; @@ -111,6 +111,13 @@ export interface AllowedMentions { users?: bigint[]; } +export interface FileContent { + /** The file blob */ + blob: Blob; + /** The name of the file */ + name: string; +} + /** https://discord.com/developers/docs/resources/guild#search-guild-members-query-string-params */ export interface SearchMembers { /** Query string to match username(s) and nickname(s) against */ diff --git a/types/mod.ts b/types/mod.ts index 1ef8f1ddd..92e59dd47 100644 --- a/types/mod.ts +++ b/types/mod.ts @@ -1,2 +1,3 @@ export * from "./discord.ts"; +export * from "./discordeno.ts"; export * from "./shared.ts"; diff --git a/types/shared.ts b/types/shared.ts index 500118819..a9c76de56 100644 --- a/types/shared.ts +++ b/types/shared.ts @@ -1201,31 +1201,6 @@ export enum Locales { export type Localization = Partial>; -export interface FileContent { - /** The file blob */ - blob: Blob; - /** The name of the file */ - name: string; -} - -export interface GatewayBot { - /** The WSS URL that can be used for connecting to the gateway */ - url: string; - /** The recommended number of shards to use when connecting */ - shards: number; - /** Information on the current session start limit */ - sessionStartLimit: { - /** The total number of session starts the current user is allowed */ - total: number; - /** The remaining number of session starts the current user is allowed */ - remaining: number; - /** The number of milliseconds after which the limit resets */ - resetAfter: number; - /** The number of identify requests allowed per 5 seconds */ - maxConcurrency: number; - }; -} - // UTILS export type AtLeastOne }> = Partial & U[keyof U]; @@ -1238,7 +1213,7 @@ export type CamelCase = S extends `${infer P1}_${infer P2}${in : Lowercase; export type Camelize = { [K in keyof T as CamelCase]: T[K] extends Array ? U extends {} ? Array> - : T[K] + : T[K] : T[K] extends {} ? Camelize : never; }; @@ -1293,8 +1268,8 @@ export type AnythingBut = Exclude< * object identity type */ export type Id = T extends infer U ? { - [K in keyof U]: U[K]; -} + [K in keyof U]: U[K]; + } : never; export type KeysWithUndefined = { @@ -1318,8 +1293,8 @@ type OptionalizeAux = Id< */ export type Optionalize = T extends object ? T extends Array ? number extends T["length"] ? T[number] extends object ? Array> - : T - : Partial + : T + : Partial : OptionalizeAux : T; diff --git a/plugins/bot/util/bigint.ts b/util/bigint.ts similarity index 100% rename from plugins/bot/util/bigint.ts rename to util/bigint.ts diff --git a/util/bucket.ts b/util/bucket.ts index d9683525b..5429c4416 100644 --- a/util/bucket.ts +++ b/util/bucket.ts @@ -1,5 +1,5 @@ import { PickPartial } from "../types/shared.ts"; -import { delay } from "./delay.ts"; +import { delay } from "./utils.ts"; /** A Leaky Bucket. * Useful for rate limiting purposes. diff --git a/gateway/calculateShardId.ts b/util/calculateShardId.ts similarity index 74% rename from gateway/calculateShardId.ts rename to util/calculateShardId.ts index d07c1a4e5..820d2124e 100644 --- a/gateway/calculateShardId.ts +++ b/util/calculateShardId.ts @@ -1,4 +1,4 @@ -import { GatewayManager } from "./manager/gatewayManager.ts"; +import { GatewayManager } from "../gateway/manager/gatewayManager.ts"; export function calculateShardId(gateway: GatewayManager, guildId: bigint) { if (gateway.manager.totalShards === 1) return 0; diff --git a/util/collection.ts b/util/collection.ts index 3d161c64c..2d53e101a 100644 --- a/util/collection.ts +++ b/util/collection.ts @@ -1,10 +1,49 @@ +import { Bot } from "../bot.ts"; + export class Collection extends Map { maxSize: number | undefined; + sweeper: CollectionSweeper & { intervalId?: number } | undefined; constructor(entries?: (readonly (readonly [K, V])[] | null) | Map, options?: CollectionOptions) { super(entries ?? []); this.maxSize = options?.maxSize; + + if (!options?.sweeper) return; + + this.startSweeper(options.sweeper); + } + + startSweeper(options: CollectionSweeper): number { + if (this.sweeper?.intervalId) clearInterval(this.sweeper.intervalId); + + this.sweeper = options; + this.sweeper.intervalId = setInterval(() => { + this.forEach((value, key) => { + if (!this.sweeper?.filter(value, key, options.bot)) return; + + this.delete(key); + return key; + }); + }, options.interval); + + return this.sweeper.intervalId!; + } + + stopSweeper(): void { + return clearInterval(this.sweeper?.intervalId); + } + + changeSweeperInterval(newInterval: number) { + if (!this.sweeper) return; + + this.startSweeper({ filter: this.sweeper.filter, interval: newInterval }); + } + + changeSweeperFilter(newFilter: (value: V, key: K, bot: Bot) => boolean) { + if (!this.sweeper) return; + + this.startSweeper({ filter: newFilter, interval: this.sweeper.interval }); } set(key: K, value: V) { @@ -96,5 +135,15 @@ export class Collection extends Map { } export interface CollectionOptions { + sweeper?: CollectionSweeper; maxSize?: number; } + +export interface CollectionSweeper { + /** The filter to determine whether an element should be deleted or not */ + filter: (value: V, key: K, ...args: any[]) => boolean; + /** The interval in which the sweeper should run */ + interval: number; + /** The bot object itself */ + bot?: Bot; +} diff --git a/util/delay.ts b/util/delay.ts deleted file mode 100644 index 19f288203..000000000 --- a/util/delay.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** Pause the execution for a given amount of milliseconds. */ -export function delay(ms: number): Promise { - return new Promise((res): number => - setTimeout((): void => { - res(); - }, ms) - ); -} diff --git a/plugins/bot/util/hash.ts b/util/hash.ts similarity index 100% rename from plugins/bot/util/hash.ts rename to util/hash.ts diff --git a/util/mod.ts b/util/mod.ts index 89115b018..13f0b85db 100644 --- a/util/mod.ts +++ b/util/mod.ts @@ -1,5 +1,7 @@ -export * from "./bucket.ts"; +export * from "./bigint.ts"; +export * from "./calculateShardId.ts"; export * from "./collection.ts"; export * from "./constants.ts"; -export * from "./delay.ts"; -export * from "./token.ts"; +export * from "./hash.ts"; +export * from "./utils.ts"; +export * from "./validateLength.ts"; diff --git a/plugins/bot/util/permissions.ts b/util/permissions.ts similarity index 91% rename from plugins/bot/util/permissions.ts rename to util/permissions.ts index 9a2198c1c..1386eaf11 100644 --- a/plugins/bot/util/permissions.ts +++ b/util/permissions.ts @@ -1,4 +1,4 @@ -import { BitwisePermissionFlags, PermissionStrings } from "../deps.ts"; +import { BitwisePermissionFlags, PermissionStrings } from "../types/shared.ts"; /** This function converts a bitwise string to permission strings */ export function calculatePermissions(permissionBits: bigint) { diff --git a/plugins/bot/util/routes.ts b/util/routes.ts similarity index 99% rename from plugins/bot/util/routes.ts rename to util/routes.ts index 7b0ae66a1..b5a4c3ac7 100644 --- a/plugins/bot/util/routes.ts +++ b/util/routes.ts @@ -1,4 +1,3 @@ -import { baseEndpoints } from "../deps.ts"; import { ListArchivedThreads } from "../helpers/channels/threads/getArchivedThreads.ts"; import { GetGuildAuditLog } from "../helpers/guilds/getAuditLogs.ts"; import { GetBans } from "../helpers/guilds/getBans.ts"; @@ -14,6 +13,7 @@ import { isGetMessagesLimit, } from "../helpers/messages/getMessages.ts"; import { GetReactions } from "../helpers/messages/getReactions.ts"; +import { baseEndpoints } from "./constants.ts"; export const routes = { GATEWAY_BOT: () => { diff --git a/plugins/bot/util/urlToBase64.ts b/util/urlToBase64.ts similarity index 100% rename from plugins/bot/util/urlToBase64.ts rename to util/urlToBase64.ts diff --git a/plugins/bot/util/utils.ts b/util/utils.ts similarity index 76% rename from plugins/bot/util/utils.ts rename to util/utils.ts index 02716d0cf..e4c6339f3 100644 --- a/plugins/bot/util/utils.ts +++ b/util/utils.ts @@ -1,5 +1,14 @@ import { ImageFormat, ImageSize } from "../helpers/members/avatarUrl.ts"; +/** Pause the execution for a given amount of milliseconds. */ +export function delay(ms: number): Promise { + return new Promise((res): number => + setTimeout((): void => { + res(); + }, ms) + ); +} + /** Help format an image url. */ export function formatImageURL(url: string, size: ImageSize = 128, format?: ImageFormat) { return `${url}.${format || (url.includes("/a_") ? "gif" : "jpg")}?size=${size}`; diff --git a/plugins/bot/util/validateLength.ts b/util/validateLength.ts similarity index 100% rename from plugins/bot/util/validateLength.ts rename to util/validateLength.ts