├── .editorconfig ├── .github └── workflows │ ├── cache-providers.yml │ ├── cache.yml │ ├── commit.yml │ ├── internal.yml │ ├── pr.yml │ ├── release.yml │ └── shared.yml ├── .gitignore ├── CONTRIBUTING.md ├── Directory.Build.props ├── Directory.Build.targets ├── Directory.Packages.props ├── LICENSE ├── NuGet.config ├── README.md ├── Starnight.sln ├── benchmarks ├── regression-test │ ├── BenchmarkComparer.cs │ ├── CICommand.cs │ ├── Program.cs │ ├── Starnight.Benchmarks.RegressionTests.csproj │ └── TrackCommand.cs └── suite │ ├── Internal │ └── JsonConverterBenchmarks.cs │ ├── Program.cs │ ├── ResultTransformation │ ├── BenchmarkTransformer.cs │ ├── Models │ │ ├── BenchmarkModel.cs │ │ ├── HostEnvironmentModel.cs │ │ ├── MemoryModel.cs │ │ ├── ReportModel.cs │ │ └── StatisticsModel.cs │ └── Representation │ │ ├── BenchmarkResultModel.cs │ │ └── StoredBenchmarkModel.cs │ ├── Starnight.Benchmarks.csproj │ └── SuiteConfiguration.cs ├── build-tools.cmd ├── build-tools.sh ├── data └── events-internal.json ├── designs ├── gen-caching.md ├── gen-shim.md ├── ngen-internal-events.md └── readme.md ├── docs ├── articles │ ├── index.md │ └── internal │ │ ├── getting-started.md │ │ ├── index.md │ │ ├── listeners.md │ │ └── rest.md └── index.md ├── gen ├── Caching │ ├── CacheUpdateEmitter.cs │ ├── CacheUpdateGenerator.cs │ ├── CacheUpdateGeneratorHelper.cs │ └── CacheUpdaterMetadata.cs ├── NamespaceSymbolExtensions.cs ├── Shims │ ├── ShimEmitter.cs │ ├── ShimGenerator.cs │ └── ShimGeneratorHelper.cs ├── Starnight.SourceGenerators.csproj ├── TypeSymbolExtensions.cs └── WrapperEntities │ ├── DebugLogger.cs │ ├── DictionaryTransformationMetadata.cs │ ├── PropertyMetadataExtractor.cs │ ├── TransformationEmitterHelper.cs │ ├── WrapperEmitter.cs │ ├── WrapperGenerator.cs │ ├── WrapperMetadata.cs │ ├── WrapperPropertyMetadata.cs │ ├── WrapperTransformationType.cs │ └── WrapperTransformations.cs ├── img ├── banner.png └── starnight.png ├── pack.cmd ├── pack.sh ├── src ├── Starnight.Caching.Providers │ ├── Abstractions │ │ ├── BaseCacheEntry.cs │ │ ├── BaseCacheProviderOptions.cs │ │ └── ICacheProvider.cs │ ├── Memory │ │ ├── MemoryCacheEntry.cs │ │ ├── MemoryCacheProvider.cs │ │ └── MemoryCacheProviderOptions.cs │ ├── ServiceCollectionExtensions.cs │ ├── Starnight.Caching.Providers.csproj │ └── StarnightCacheKind.cs ├── Starnight.Caching │ ├── Extensions │ │ └── ServiceCollectionExtensions.cs │ ├── KeyHelper.cs │ ├── Listeners │ │ ├── CreateCacheListener.cs │ │ ├── DeleteCacheListener.cs │ │ └── UpdateCacheListener.cs │ ├── Services │ │ ├── IStarnightCacheService.cs │ │ └── StarnightCacheService.cs │ ├── Shims │ │ ├── CachingChannelRestResource.cs │ │ ├── CachingEmojiRestResource.cs │ │ ├── CachingGuildRestResource.cs │ │ ├── CachingInviteRestResource.cs │ │ ├── CachingScheduledEventRestResource.cs │ │ ├── CachingStickerRestResource.cs │ │ ├── CachingUserRestResource.cs │ │ └── readme.md │ └── Starnight.Caching.csproj ├── Starnight.Internal │ ├── Converters │ │ ├── DiscordPermissionJsonConverter.cs │ │ ├── GatewayEventJsonConverter.cs │ │ ├── NullBooleanJsonConverter.cs │ │ ├── OptionalParameterJsonConverter.cs │ │ ├── OptionalParameterJsonConverterFactory.cs │ │ └── OptionalTypeInfoResolver.cs │ ├── DiscordApiConstants.cs │ ├── Entities │ │ ├── Channels │ │ │ ├── DiscordChannel.cs │ │ │ ├── DiscordChannelMention.cs │ │ │ ├── DiscordChannelOverwrite.cs │ │ │ ├── DiscordFollowedChannel.cs │ │ │ ├── DiscordWebhook.cs │ │ │ └── Threads │ │ │ │ ├── DiscordDefaultForumReaction.cs │ │ │ │ ├── DiscordForumTag.cs │ │ │ │ ├── DiscordThreadMember.cs │ │ │ │ └── DiscordThreadMetadata.cs │ │ ├── DiscordSnowflakeObject.cs │ │ ├── Guilds │ │ │ ├── Audit │ │ │ │ ├── DiscordAuditLogChange.cs │ │ │ │ ├── DiscordAuditLogEntry.cs │ │ │ │ ├── DiscordAuditLogEntryOptionalData.cs │ │ │ │ └── DiscordAuditLogObject.cs │ │ │ ├── AutoModeration │ │ │ │ ├── DiscordAutoModerationAction.cs │ │ │ │ ├── DiscordAutoModerationActionMetadata.cs │ │ │ │ ├── DiscordAutoModerationRule.cs │ │ │ │ └── DiscordAutoModerationTriggerMetadata.cs │ │ │ ├── DiscordEmoji.cs │ │ │ ├── DiscordGuild.cs │ │ │ ├── DiscordGuildBan.cs │ │ │ ├── DiscordGuildIntegration.cs │ │ │ ├── DiscordGuildIntegrationAccount.cs │ │ │ ├── DiscordGuildIntegrationApplication.cs │ │ │ ├── DiscordGuildMember.cs │ │ │ ├── DiscordGuildOnboarding.cs │ │ │ ├── DiscordGuildOnboardingOption.cs │ │ │ ├── DiscordGuildOnboardingPrompt.cs │ │ │ ├── DiscordGuildPreview.cs │ │ │ ├── DiscordGuildTemplate.cs │ │ │ ├── DiscordGuildWelcomeChannel.cs │ │ │ ├── DiscordGuildWelcomeScreen.cs │ │ │ ├── DiscordGuildWidget.cs │ │ │ ├── DiscordGuildWidgetSettings.cs │ │ │ ├── DiscordRole.cs │ │ │ ├── DiscordRoleSubscriptionData.cs │ │ │ ├── DiscordRoleTags.cs │ │ │ ├── DiscordScheduledEvent.cs │ │ │ ├── DiscordScheduledEventMetadata.cs │ │ │ ├── DiscordScheduledEventStatus.cs │ │ │ ├── DiscordScheduledEventUser.cs │ │ │ ├── DiscordUnavailableGuild.cs │ │ │ ├── Invites │ │ │ │ └── DiscordInvite.cs │ │ │ └── RoleConnections │ │ │ │ └── DiscordRoleConnectionMetadata.cs │ │ ├── Interactions │ │ │ ├── ApplicationCommands │ │ │ │ ├── DiscordApplicationCommand.cs │ │ │ │ ├── DiscordApplicationCommandDataOption.cs │ │ │ │ ├── DiscordApplicationCommandOption.cs │ │ │ │ ├── DiscordApplicationCommandOptionChoice.cs │ │ │ │ ├── DiscordApplicationCommandPermission.cs │ │ │ │ └── DiscordApplicationCommandPermissions.cs │ │ │ ├── Components │ │ │ │ ├── AbstractDiscordMessageComponent.cs │ │ │ │ ├── AbstractInteractiveDiscordMessageComponent.cs │ │ │ │ ├── DiscordActionRowComponent.cs │ │ │ │ ├── DiscordButtonComponent.cs │ │ │ │ ├── DiscordSelectMenuComponent.cs │ │ │ │ ├── DiscordSelectMenuOption.cs │ │ │ │ └── DiscordTextInputComponent.cs │ │ │ ├── DiscordInteraction.cs │ │ │ ├── DiscordInteractionData.cs │ │ │ ├── DiscordInteractionResolvedData.cs │ │ │ └── DiscordMessageInteraction.cs │ │ ├── Messages │ │ │ ├── DiscordAllowedMentions.cs │ │ │ ├── DiscordMessage.cs │ │ │ ├── DiscordMessageActivity.cs │ │ │ ├── DiscordMessageAttachment.cs │ │ │ ├── DiscordMessageReaction.cs │ │ │ ├── DiscordMessageReference.cs │ │ │ └── Embeds │ │ │ │ ├── DiscordEmbed.cs │ │ │ │ ├── DiscordEmbedAuthor.cs │ │ │ │ ├── DiscordEmbedField.cs │ │ │ │ ├── DiscordEmbedFooter.cs │ │ │ │ ├── DiscordEmbedImage.cs │ │ │ │ ├── DiscordEmbedProvider.cs │ │ │ │ ├── DiscordEmbedThumbnail.cs │ │ │ │ └── DiscordEmbedVideo.cs │ │ ├── Stickers │ │ │ ├── DiscordMessageSticker.cs │ │ │ ├── DiscordSticker.cs │ │ │ └── DiscordStickerPack.cs │ │ ├── Teams │ │ │ ├── DiscordApplication.cs │ │ │ ├── DiscordApplicationInstallParameters.cs │ │ │ ├── DiscordTeam.cs │ │ │ └── DiscordTeamMember.cs │ │ ├── Users │ │ │ ├── Activities │ │ │ │ ├── DiscordActivity.cs │ │ │ │ ├── DiscordActivityAssets.cs │ │ │ │ ├── DiscordActivityButton.cs │ │ │ │ ├── DiscordActivityEmoji.cs │ │ │ │ ├── DiscordActivityParty.cs │ │ │ │ ├── DiscordActivitySecrets.cs │ │ │ │ └── DiscordActivityTimestamps.cs │ │ │ ├── DiscordClientStatus.cs │ │ │ ├── DiscordPresence.cs │ │ │ ├── DiscordUser.cs │ │ │ └── DiscordUserConnection.cs │ │ └── Voice │ │ │ ├── DiscordStageInstance.cs │ │ │ ├── DiscordVoiceRegion.cs │ │ │ └── DiscordVoiceState.cs │ ├── Exceptions │ │ ├── AbstractDiscordException.cs │ │ ├── DiscordRestException.cs │ │ ├── StarnightGatewayConnectionRefusedException.cs │ │ ├── StarnightInvalidListenerException.cs │ │ ├── StarnightInvalidOutboundEventException.cs │ │ └── StarnightRequestRejectedException.cs │ ├── Extensions │ │ ├── HostBuilderExtensions.cs │ │ ├── ServiceCollectionExtensions.cs │ │ └── SnowflakeExtensions.cs │ ├── Gateway │ │ ├── DiscordGatewayClient.cs │ │ ├── DiscordGatewayClientOptions.cs │ │ ├── DiscordGatewayCloseEventCode.cs │ │ ├── DiscordGatewayIntents.cs │ │ ├── DiscordGatewayOpcode.cs │ │ ├── Events │ │ │ ├── Control │ │ │ │ └── ZombiedEvent.cs │ │ │ ├── IDiscordGatewayDispatchEvent.cs │ │ │ ├── IDiscordGatewayEvent.cs │ │ │ ├── IDiscordGatewayEvent`1.cs │ │ │ ├── IGatewayEvent.cs │ │ │ ├── Inbound │ │ │ │ ├── DiscordConnectedEvent.cs │ │ │ │ ├── DiscordHelloEvent.cs │ │ │ │ ├── DiscordInboundHeartbeatEvent.cs │ │ │ │ ├── DiscordInvalidSessionEvent.cs │ │ │ │ ├── DiscordReconnectEvent.cs │ │ │ │ ├── DiscordResumedEvent.cs │ │ │ │ ├── DiscordUnknownInboundEvent.cs │ │ │ │ └── Dispatch │ │ │ │ │ ├── DiscordAllMessageReactionsRemovedEvent.cs │ │ │ │ │ ├── DiscordApplicationCommandPermissionsUpdatedEvent.cs │ │ │ │ │ ├── DiscordAuditLogEntryCreatedEvent.cs │ │ │ │ │ ├── DiscordAutoModerationActionExecutedEvent.cs │ │ │ │ │ ├── DiscordAutoModerationRuleCreatedEvent.cs │ │ │ │ │ ├── DiscordAutoModerationRuleDeletedEvent.cs │ │ │ │ │ ├── DiscordAutoModerationRuleUpdatedEvent.cs │ │ │ │ │ ├── DiscordChannelCreatedEvent.cs │ │ │ │ │ ├── DiscordChannelDeletedEvent.cs │ │ │ │ │ ├── DiscordChannelPinsUpdatedEvent.cs │ │ │ │ │ ├── DiscordChannelUpdatedEvent.cs │ │ │ │ │ ├── DiscordEmojiMessageReactionsRemovedEvent.cs │ │ │ │ │ ├── DiscordGuildBanAddedEvent.cs │ │ │ │ │ ├── DiscordGuildBanRemovedEvent.cs │ │ │ │ │ ├── DiscordGuildCreatedEvent.cs │ │ │ │ │ ├── DiscordGuildDeletedEvent.cs │ │ │ │ │ ├── DiscordGuildEmojisUpdatedEvent.cs │ │ │ │ │ ├── DiscordGuildIntegrationsUpdatedEvent.cs │ │ │ │ │ ├── DiscordGuildMemberAddedEvent.cs │ │ │ │ │ ├── DiscordGuildMemberRemovedEvent.cs │ │ │ │ │ ├── DiscordGuildMemberUpdatedEvent.cs │ │ │ │ │ ├── DiscordGuildMembersChunkEvent.cs │ │ │ │ │ ├── DiscordGuildRoleCreatedEvent.cs │ │ │ │ │ ├── DiscordGuildRoleDeletedEvent.cs │ │ │ │ │ ├── DiscordGuildRoleUpdatedEvent.cs │ │ │ │ │ ├── DiscordGuildStickersUpdatedEvent.cs │ │ │ │ │ ├── DiscordGuildUpdatedEvent.cs │ │ │ │ │ ├── DiscordIntegrationCreatedEvent.cs │ │ │ │ │ ├── DiscordIntegrationDeletedEvent.cs │ │ │ │ │ ├── DiscordIntegrationUpdatedEvent.cs │ │ │ │ │ ├── DiscordInteractionCreatedEvent.cs │ │ │ │ │ ├── DiscordInviteCreatedEvent.cs │ │ │ │ │ ├── DiscordInviteDeletedEvent.cs │ │ │ │ │ ├── DiscordMessageCreatedEvent.cs │ │ │ │ │ ├── DiscordMessageDeletedEvent.cs │ │ │ │ │ ├── DiscordMessageReactionAddedEvent.cs │ │ │ │ │ ├── DiscordMessageReactionRemovedEvent.cs │ │ │ │ │ ├── DiscordMessageUpdatedEvent.cs │ │ │ │ │ ├── DiscordMessagesBulkDeletedEvent.cs │ │ │ │ │ ├── DiscordPresenceUpdatedEvent.cs │ │ │ │ │ ├── DiscordScheduledEventCreatedEvent.cs │ │ │ │ │ ├── DiscordScheduledEventDeletedEvent.cs │ │ │ │ │ ├── DiscordScheduledEventUpdatedEvent.cs │ │ │ │ │ ├── DiscordScheduledEventUserAddedEvent.cs │ │ │ │ │ ├── DiscordScheduledEventUserRemovedEvent.cs │ │ │ │ │ ├── DiscordStageInstanceCreatedEvent.cs │ │ │ │ │ ├── DiscordStageInstanceDeletedEvent.cs │ │ │ │ │ ├── DiscordStageInstanceUpdatedEvent.cs │ │ │ │ │ ├── DiscordThreadCreatedEvent.cs │ │ │ │ │ ├── DiscordThreadDeletedEvent.cs │ │ │ │ │ ├── DiscordThreadListSyncEvent.cs │ │ │ │ │ ├── DiscordThreadMemberUpdatedEvent.cs │ │ │ │ │ ├── DiscordThreadMembersUpdatedEvent.cs │ │ │ │ │ ├── DiscordThreadUpdatedEvent.cs │ │ │ │ │ ├── DiscordTypingStartedEvent.cs │ │ │ │ │ ├── DiscordUnknownDispatchEvent.cs │ │ │ │ │ ├── DiscordUserUpdatedEvent.cs │ │ │ │ │ ├── DiscordVoiceServerUpdatedEvent.cs │ │ │ │ │ ├── DiscordVoiceStateUpdatedEvent.cs │ │ │ │ │ ├── DiscordWebhooksUpdatedEvent.cs │ │ │ │ │ └── EventDeserializer.cs │ │ │ └── Outbound │ │ │ │ ├── DiscordIdentifyCommand.cs │ │ │ │ ├── DiscordOutboundHeartbeatEvent.cs │ │ │ │ ├── DiscordRequestGuildMembersEvent.cs │ │ │ │ ├── DiscordResumeEvent.cs │ │ │ │ ├── DiscordUpdatePresenceEvent.cs │ │ │ │ └── DiscordUpdateVoiceStateEvent.cs │ │ ├── GatewayRegistration.cs │ │ ├── InboundGatewayFrame.cs │ │ ├── Listeners │ │ │ ├── IListener.cs │ │ │ ├── IListener`1.cs │ │ │ ├── ListenerCollection.cs │ │ │ ├── ListenerDispatcher.cs │ │ │ ├── ListenerPhase.cs │ │ │ ├── ListenerService.cs │ │ │ └── ServiceCollectionExtensions.cs │ │ ├── Payloads │ │ │ ├── DiscordSessionStartLimit.cs │ │ │ ├── GetGatewayBotResponsePayload.cs │ │ │ ├── Inbound │ │ │ │ ├── ConnectedPayload.cs │ │ │ │ ├── Dispatch │ │ │ │ │ ├── AllMessageReactionsRemovedPayload.cs │ │ │ │ │ ├── AutoModerationActionExecutedPayload.cs │ │ │ │ │ ├── ChannelPinsUpdatedPayload.cs │ │ │ │ │ ├── EmojiMessageReactionsRemovedPayload.cs │ │ │ │ │ ├── GuildBanAddedPayload.cs │ │ │ │ │ ├── GuildBanRemovedPayload.cs │ │ │ │ │ ├── GuildEmojisUpdatedPayload.cs │ │ │ │ │ ├── GuildIntegrationsUpdatedPayload.cs │ │ │ │ │ ├── GuildMemberRemovedPayload.cs │ │ │ │ │ ├── GuildMembersChunkPayload.cs │ │ │ │ │ ├── GuildRoleCreatedPayload.cs │ │ │ │ │ ├── GuildRoleDeletedPayload.cs │ │ │ │ │ ├── GuildRoleUpdatedPayload.cs │ │ │ │ │ ├── GuildStickersUpdatedPayload.cs │ │ │ │ │ ├── IntegrationDeletedPayload.cs │ │ │ │ │ ├── InviteCreatedPayload.cs │ │ │ │ │ ├── InviteDeletedPayload.cs │ │ │ │ │ ├── MessageDeletedPayload.cs │ │ │ │ │ ├── MessageReactionAddedPayload.cs │ │ │ │ │ ├── MessageReactionRemovedPayload.cs │ │ │ │ │ ├── MessagesBulkDeletedPayload.cs │ │ │ │ │ ├── PresenceUpdatedPayload.cs │ │ │ │ │ ├── ScheduledEventUserAddedPayload.cs │ │ │ │ │ ├── ScheduledEventUserRemovedPayload.cs │ │ │ │ │ ├── ThreadListSyncPayload.cs │ │ │ │ │ ├── ThreadMembersUpdatedPayload.cs │ │ │ │ │ ├── TypingStartedPayload.cs │ │ │ │ │ ├── VoiceServerUpdatedPayload.cs │ │ │ │ │ └── WebhooksUpdatedPayload.cs │ │ │ │ └── HelloPayload.cs │ │ │ └── Outbound │ │ │ │ ├── DiscordIdentifyConnectionProperties.cs │ │ │ │ ├── IdentifyPayload.cs │ │ │ │ ├── RequestGuildMembersPayload.cs │ │ │ │ ├── ResumePayload.cs │ │ │ │ └── UpdateVoiceStatePayload.cs │ │ ├── Services │ │ │ ├── DiscordGatewayRestResource.cs │ │ │ ├── IInboundGatewayService.cs │ │ │ ├── IOutboundGatewayService.cs │ │ │ ├── InboundGatewayService.cs │ │ │ ├── OutboundGatewayService.cs │ │ │ └── TransportService.cs │ │ └── State │ │ │ ├── DiscordGatewayClientState.cs │ │ │ ├── GatewayClientStateTracker.cs │ │ │ └── GatewayClientStateTrackerExtensions.cs │ ├── Models │ │ ├── ApplicationCommands │ │ │ ├── ApplicationCommand.cs │ │ │ ├── ApplicationCommandOption.cs │ │ │ ├── ApplicationCommandOptionChoice.cs │ │ │ └── ApplicationCommandPermission.cs │ │ ├── Emojis │ │ │ └── PartialEmoji.cs │ │ └── MessageComponents │ │ │ ├── AbstractComponent.cs │ │ │ ├── AbstractInteractiveComponent.cs │ │ │ ├── ActionRowComponent.cs │ │ │ ├── ButtonComponent.cs │ │ │ ├── ChannelSelectComponent.cs │ │ │ ├── MentionableSelectComponent.cs │ │ │ ├── RoleSelectComponent.cs │ │ │ ├── TextInputComponent.cs │ │ │ ├── TextSelectComponent.cs │ │ │ ├── TextSelectOption.cs │ │ │ └── UserSelectComponent.cs │ ├── Rest │ │ ├── Exceptions │ │ │ ├── GlobalRateLimitExceededException.cs │ │ │ └── RateLimitExceededException.cs │ │ ├── IRestRequest.cs │ │ ├── MultipartRestRequest.cs │ │ ├── Payloads │ │ │ ├── ApplicationCommands │ │ │ │ ├── CreateApplicationCommandRequestPayload.cs │ │ │ │ ├── CreateFollowupMessageRequestPayload.cs │ │ │ │ ├── CreateInteractionCallbackRequestPayload.cs │ │ │ │ ├── DiscordInteractionCallbackData.cs │ │ │ │ ├── EditApplicationCommandRequestPayload.cs │ │ │ │ ├── EditFollowupMessageRequestPayload.cs │ │ │ │ └── EditOriginalResponseRequestPayload.cs │ │ │ ├── AutoModeration │ │ │ │ ├── CreateAutoModerationRuleRequestPayload.cs │ │ │ │ └── ModifyAutoModerationRuleRequestPayload.cs │ │ │ ├── Channels │ │ │ │ ├── AddGroupDMRecipientRequestPayload.cs │ │ │ │ ├── CreateChannelInviteRequestPayload.cs │ │ │ │ ├── CreateMessageRequestPayload.cs │ │ │ │ ├── EditChannelPermissionsRequestPayload.cs │ │ │ │ ├── EditMessageRequestPayload.cs │ │ │ │ ├── ForumTagPayload.cs │ │ │ │ ├── ForumThreadMessageParameters.cs │ │ │ │ ├── ListArchivedThreadsResponsePayload.cs │ │ │ │ ├── ModifyGroupDMRequestPayload.cs │ │ │ │ ├── ModifyGuildChannelRequestPayload.cs │ │ │ │ ├── ModifyThreadChannelRequestPayload.cs │ │ │ │ ├── StartThreadFromMessageRequestPayload.cs │ │ │ │ ├── StartThreadInForumChannelRequestPayload.cs │ │ │ │ └── StartThreadWithoutMessageRequestPayload.cs │ │ │ ├── DiscordAttachmentFile.cs │ │ │ ├── Emojis │ │ │ │ ├── CreateGuildEmojiRequestPayload.cs │ │ │ │ └── ModifyGuildEmojiRequestPayload.cs │ │ │ ├── GuildTemplates │ │ │ │ ├── CreateGuildFromTemplateRequestPayload.cs │ │ │ │ ├── CreateGuildTemplateRequestPayload.cs │ │ │ │ └── ModifyGuildTemplateRequestPayload.cs │ │ │ ├── Guilds │ │ │ │ ├── AddGuildMemberRequestPayload.cs │ │ │ │ ├── CreateGuildChannelRequestPayload.cs │ │ │ │ ├── CreateGuildRoleRequestPayload.cs │ │ │ │ ├── ListActiveThreadsResponsePayload.cs │ │ │ │ ├── ModifyCurrentUserVoiceStateRequestPayload.cs │ │ │ │ ├── ModifyGuildChannelPositionRequestPayload.cs │ │ │ │ ├── ModifyGuildMemberRequestPayload.cs │ │ │ │ ├── ModifyGuildRequestPayload.cs │ │ │ │ ├── ModifyGuildRoleRequestPayload.cs │ │ │ │ ├── ModifyRolePositionRequestPayload.cs │ │ │ │ └── ModifyUserVoiceStateRequestPayload.cs │ │ │ ├── ScheduledEvents │ │ │ │ ├── CreateScheduledEventRequestPayload.cs │ │ │ │ └── ModifyScheduledEventRequestPayload.cs │ │ │ ├── StageInstances │ │ │ │ ├── CreateStageInstanceRequestPayload.cs │ │ │ │ └── ModifyStageInstanceRequestPayload.cs │ │ │ ├── Stickers │ │ │ │ ├── CreateGuildStickerRequestPayload.cs │ │ │ │ ├── ListNitroStickerPacksResponsePayload.cs │ │ │ │ └── ModifyGuildStickerRequestPayload.cs │ │ │ ├── Users │ │ │ │ └── ModifyCurrentUserRequestPayload.cs │ │ │ └── Webhooks │ │ │ │ ├── CreateWebhookRequestPayload.cs │ │ │ │ ├── EditWebhookMessageRequestPayload.cs │ │ │ │ ├── ExecuteWebhookRequestPayload.cs │ │ │ │ ├── ModifyWebhookRequestPayload.cs │ │ │ │ └── ModifyWebhookWithTokenRequestPayload.cs │ │ ├── PollyRateLimitPolicy.cs │ │ ├── QueryBuilder.cs │ │ ├── RatelimitBucket.cs │ │ ├── Resources │ │ │ ├── IDiscordApplicationCommandsRestResource.cs │ │ │ ├── IDiscordAuditLogRestResource.cs │ │ │ ├── IDiscordAutoModerationRestResource.cs │ │ │ ├── IDiscordChannelRestResource.cs │ │ │ ├── IDiscordEmojiRestResource.cs │ │ │ ├── IDiscordGuildRestResource.cs │ │ │ ├── IDiscordGuildTemplateRestResource.cs │ │ │ ├── IDiscordInviteRestResource.cs │ │ │ ├── IDiscordRoleConnectionRestResource.cs │ │ │ ├── IDiscordScheduledEventRestResource.cs │ │ │ ├── IDiscordStageInstanceRestResource.cs │ │ │ ├── IDiscordStickerRestResource.cs │ │ │ ├── IDiscordUserRestResource.cs │ │ │ ├── IDiscordVoiceRestResource.cs │ │ │ ├── IDiscordWebhookRestResource.cs │ │ │ └── Implementation │ │ │ │ ├── AbstractRestResource.cs │ │ │ │ ├── DiscordApplicationCommandsRestResource.cs │ │ │ │ ├── DiscordAuditLogRestResource.cs │ │ │ │ ├── DiscordAutoModerationRestResource.cs │ │ │ │ ├── DiscordChannelRestResource.cs │ │ │ │ ├── DiscordEmojiRestResource.cs │ │ │ │ ├── DiscordGuildRestResource.cs │ │ │ │ ├── DiscordGuildTemplateRestResource.cs │ │ │ │ ├── DiscordInviteRestResource.cs │ │ │ │ ├── DiscordRoleConnectionRestResource.cs │ │ │ │ ├── DiscordScheduledEventRestResource.cs │ │ │ │ ├── DiscordStageInstanceRestResource.cs │ │ │ │ ├── DiscordStickerRestResource.cs │ │ │ │ ├── DiscordUserRestResource.cs │ │ │ │ ├── DiscordVoiceRestResource.cs │ │ │ │ ├── DiscordWebhookRestResource.cs │ │ │ │ └── RestResourceTemplate.txt │ │ ├── RestClient.cs │ │ ├── RestClientOptions.cs │ │ ├── RestRegistration.cs │ │ └── RestRequest.cs │ ├── Starnight.Internal.csproj │ ├── StarnightInternalConstants.cs │ └── TokenContainer.cs ├── Starnight.Shared │ ├── Entities │ │ ├── DiscordPermissions.cs │ │ ├── _Channels │ │ │ ├── DiscordChannelFlags.cs │ │ │ ├── DiscordChannelOverwriteType.cs │ │ │ ├── DiscordChannelType.cs │ │ │ ├── DiscordDefaultThreadSortOrder.cs │ │ │ ├── DiscordVideoQualityMode.cs │ │ │ └── DiscordWebhookType.cs │ │ ├── _Guilds │ │ │ ├── DiscordAuditLogEntryOptionalDataType.cs │ │ │ ├── DiscordAuditLogEvent.cs │ │ │ ├── DiscordAutoModerationActionType.cs │ │ │ ├── DiscordAutoModerationEventType.cs │ │ │ ├── DiscordAutoModerationKeywordPresetType.cs │ │ │ ├── DiscordAutoModerationTriggerType.cs │ │ │ ├── DiscordGuildBoostLevel.cs │ │ │ ├── DiscordGuildExplicitContentFilterLevel.cs │ │ │ ├── DiscordGuildIntegrationExpireBehaviour.cs │ │ │ ├── DiscordGuildMessageNotificationsLevel.cs │ │ │ ├── DiscordGuildMultiFactorAuthLevel.cs │ │ │ ├── DiscordGuildNsfwLevel.cs │ │ │ ├── DiscordGuildOnboardingPromptType.cs │ │ │ ├── DiscordGuildSystemChannelFlags.cs │ │ │ ├── DiscordGuildVerificationLevel.cs │ │ │ ├── DiscordRoleConnectionMetadataType.cs │ │ │ ├── DiscordScheduledEventPrivacyLevel.cs │ │ │ ├── DiscordScheduledEventType.cs │ │ │ └── DiscordVoiceInviteTargetType.cs │ │ ├── _Interactions │ │ │ ├── DiscordApplicationCommandOptionType.cs │ │ │ ├── DiscordApplicationCommandPermissionType.cs │ │ │ ├── DiscordApplicationCommandType.cs │ │ │ ├── DiscordButtonStyle.cs │ │ │ ├── DiscordInteractionCallbackType.cs │ │ │ ├── DiscordInteractionType.cs │ │ │ ├── DiscordLocale.cs │ │ │ ├── DiscordMessageComponentType.cs │ │ │ └── DiscordTextInputStyle.cs │ │ ├── _Messages │ │ │ ├── DiscordMessageActivityType.cs │ │ │ ├── DiscordMessageFlags.cs │ │ │ └── DiscordMessageType.cs │ │ ├── _Stickers │ │ │ ├── DiscordStickerFormatType.cs │ │ │ └── DiscordStickerType.cs │ │ ├── _Teams │ │ │ ├── DiscordApplicationFlags.cs │ │ │ └── DiscordTeamMembershipState.cs │ │ ├── _Users │ │ │ ├── DiscordActivityFlags.cs │ │ │ ├── DiscordActivityType.cs │ │ │ ├── DiscordPremiumType.cs │ │ │ ├── DiscordUserConnectionVisibility.cs │ │ │ └── DiscordUserFlags.cs │ │ └── _Voice │ │ │ └── DiscordStagePrivacyLevel.cs │ ├── Exceptions │ │ ├── AbstractStarnightException.cs │ │ ├── StarnightInvalidConnectionException.cs │ │ └── StarnightSharedRatelimitHitException.cs │ ├── Optional.cs │ ├── Starnight.Shared.csproj │ └── readme.md └── Starnight │ ├── Entities │ ├── IStarnightEntity.cs │ └── IStarnightEntity`2.cs │ ├── Infrastructure │ ├── Logging │ │ ├── StarnightLogger.cs │ │ └── StarnightLoggerProvider.cs │ ├── SerializationServices │ │ └── StarnightEntityExtensions.cs │ └── TransformationServices │ │ ├── CollectionTransformerService.cs │ │ ├── DisableCollectionTransformationAttribute.cs │ │ ├── GenerateInterfaceImplementationAttribute.cs │ │ ├── ICollectionTransformerService.cs │ │ └── RenameTransformedPropertyAttribute.cs │ ├── Snowflake.GenericMath.cs │ ├── Snowflake.TimeOperations.cs │ ├── Snowflake.cs │ ├── Starnight.csproj │ ├── StarnightClient.Construction.cs │ ├── StarnightClient.Miscellaneous.cs │ ├── StarnightClient.cs │ ├── StarnightClientBuilder.cs │ ├── StarnightClientOptions.cs │ └── StarnightIntents.cs ├── styleguide.md ├── test ├── Starnight.Internal.Tests │ ├── JsonSerializerTests.cs │ └── Starnight.Internal.Tests.csproj └── Starnight.TestBot │ ├── Program.cs │ ├── Starnight.TestBot.csproj │ └── TestListener.cs └── tools ├── Directory.Build.props ├── generators └── Starnight.Generators.GenerateInternalEvents │ ├── EventEmitter.cs │ ├── GeneratorMetadata.cs │ ├── GeneratorMetadataEntry.cs │ ├── MetadataExtractor.cs │ ├── Program.cs │ └── Starnight.Generators.GenerateInternalEvents.csproj └── pack-workflow.sh /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | name: "Test Pull Request" 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | build_pr: 8 | runs-on: "ubuntu-latest" 9 | if: "!contains(toJSON(github.event.commits.*.message), '[ci-skip]')" 10 | 11 | steps: 12 | - uses: "actions/checkout@v3" 13 | 14 | - name: "Setup .NET" 15 | uses: "actions/setup-dotnet@v2" 16 | with: 17 | dotnet-version: 7.0.x 18 | 19 | - name: "Build PR" 20 | run: "bash tools/pack-workflow.sh --pr ${{ github.run_number }}" 21 | 22 | - name: Upload a Build Artifact 23 | uses: actions/upload-artifact@v3 24 | with: 25 | name: Starnight 26 | path: ./build/ 27 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Starnight Banner 3 |
4 | Starnight Library 5 |

6 |

7 | 8 | Modern Discord API wrapper & library targeting .NET 7, lightweight and efficient. 9 | 10 | ## Credits: 11 | 12 | Thanks to [Naamloos](https://github.com/Naamloos) for the idea to the discord webhook CI thing. 13 | 14 | Also thanks to naam for the idea to generally make this a thing. 15 | 16 | https://discord.gg/8TKJaGs 17 | -------------------------------------------------------------------------------- /benchmarks/regression-test/CICommand.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.RegressionTests; 2 | 3 | using System; 4 | using System.ComponentModel; 5 | using System.Diagnostics.CodeAnalysis; 6 | 7 | using Spectre.Console.Cli; 8 | 9 | public sealed class CICommand : Command 10 | { 11 | public sealed class Settings : CommandSettings 12 | { 13 | [Description("The regression threshold, in percentage points from base, at which to consider the benchmark failed.")] 14 | [CommandOption("-t|--threshold")] 15 | public Single RegressionThreshold { get; init; } 16 | 17 | [Description("Specifies whether to log the individual worst regressions and best improvements.")] 18 | [CommandOption("-d|--diffs")] 19 | public Boolean LogDiffs { get; init; } 20 | } 21 | 22 | public override Int32 Execute 23 | ( 24 | [NotNull] 25 | CommandContext context, 26 | 27 | [NotNull] 28 | Settings settings 29 | ) 30 | { 31 | return 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /benchmarks/regression-test/Starnight.Benchmarks.RegressionTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/BenchmarkTransformer.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation; 2 | 3 | using System.Collections.Generic; 4 | 5 | using Starnight.Benchmarks.ResultTransformation.Models; 6 | using Starnight.Benchmarks.ResultTransformation.Representation; 7 | 8 | public static class BenchmarkTransformer 9 | { 10 | public static StoredBenchmarkModel Transform 11 | ( 12 | ReportModel report 13 | ) 14 | { 15 | List runBenchmarks = new(); 16 | 17 | foreach(BenchmarkModel model in report.Benchmarks) 18 | { 19 | runBenchmarks.Add 20 | ( 21 | new BenchmarkResultModel 22 | { 23 | Method = model.Method, 24 | Mean = model.Statistics.Mean, 25 | StandardError = model.Statistics.StandardError, 26 | AllocatedBytes = model.Memory.BytesAllocatedPerOperation 27 | } 28 | ); 29 | } 30 | 31 | return new() 32 | { 33 | Environment = report.HostEnvironmentInfo, 34 | Results = runBenchmarks 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Models/BenchmarkModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Models; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents a singular benchmark. 7 | /// 8 | public sealed record BenchmarkModel 9 | { 10 | /// 11 | /// The name of the benchmark method, used as a display name. 12 | /// 13 | public required String Method { get; init; } 14 | 15 | /// 16 | /// The statistics for this benchmark run. 17 | /// 18 | public required StatisticsModel Statistics { get; init; } 19 | 20 | /// 21 | /// The memory usage statistics for this benchmark run. 22 | /// 23 | public required MemoryModel Memory { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Models/MemoryModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Models; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents the to-us relevant memory data. 7 | /// 8 | public sealed record MemoryModel 9 | { 10 | /// 11 | /// The amount of data allocated on the managed heap during a single run. 12 | /// 13 | public required Int32 BytesAllocatedPerOperation { get; init; } 14 | } 15 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Models/ReportModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Models; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Represents the base report object. 8 | /// 9 | public sealed record ReportModel 10 | { 11 | /// 12 | /// The title of the benchmark. This will later be transformed to the filename. 13 | /// 14 | public required String Title { get; init; } 15 | 16 | /// 17 | /// The host environment. 18 | /// 19 | public required HostEnvironmentModel HostEnvironmentInfo { get; init; } 20 | 21 | /// 22 | /// All benchmarks that were part of this run. 23 | /// 24 | public required IEnumerable Benchmarks { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Models/StatisticsModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Models; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents the relevant-to-us statistics of a given benchmark run. 7 | /// 8 | public sealed record StatisticsModel 9 | { 10 | /// 11 | /// Gets the mean execution time of the benchmark. 12 | /// 13 | public required Decimal Mean { get; init; } 14 | 15 | /// 16 | /// Gets the standard error of the mean. 17 | /// 18 | public required Decimal StandardError { get; init; } 19 | } 20 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Representation/BenchmarkResultModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Representation; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents the result of a single benchmark run. 7 | /// 8 | public sealed record BenchmarkResultModel 9 | { 10 | /// 11 | /// The name of the given benchmark method, used as a display name. 12 | /// 13 | public required String Method { get; init; } 14 | 15 | /// 16 | /// Gets the mean execution time of the benchmark. 17 | /// 18 | public required Decimal Mean { get; init; } 19 | 20 | /// 21 | /// Gets the standard error of the mean. 22 | /// 23 | public required Decimal StandardError { get; init; } 24 | 25 | /// 26 | /// The amount of data allocated on the managed heap during a single run. 27 | /// 28 | public required Int32 AllocatedBytes { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /benchmarks/suite/ResultTransformation/Representation/StoredBenchmarkModel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks.ResultTransformation.Representation; 2 | 3 | using System.Collections.Generic; 4 | 5 | using Starnight.Benchmarks.ResultTransformation.Models; 6 | 7 | /// 8 | /// Represents a transformed and stored benchmark. 9 | /// 10 | public sealed record StoredBenchmarkModel 11 | { 12 | /// 13 | /// The environment this benchmark was ran in. 14 | /// 15 | public required HostEnvironmentModel Environment { get; init; } 16 | 17 | /// 18 | /// The results of the benchmark runs. 19 | /// 20 | public required IEnumerable Results { get; init; } 21 | } 22 | -------------------------------------------------------------------------------- /benchmarks/suite/Starnight.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /benchmarks/suite/SuiteConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Benchmarks; 2 | 3 | using BenchmarkDotNet.Configs; 4 | using BenchmarkDotNet.Diagnosers; 5 | using BenchmarkDotNet.Exporters.Json; 6 | using BenchmarkDotNet.Loggers; 7 | 8 | internal class SuiteConfiguration : ManualConfig 9 | { 10 | public SuiteConfiguration() 11 | { 12 | _ = this.AddLogger(NullLogger.Instance); 13 | _ = this.AddExporter(JsonExporter.BriefCompressed); 14 | _ = this.AddDiagnoser(MemoryDiagnoser.Default); 15 | _ = this.KeepBenchmarkFiles(); 16 | this.UnionRule = ConfigUnionRule.AlwaysUseGlobal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /designs/gen-shim.md: -------------------------------------------------------------------------------- 1 | # The Starnight Shim Source Generator 2 | 3 | The shim source generator is located in `/gen/Shims` and exists to automatically generate redirects for shims that don't cover every 4 | single method. In its current state, it is very rudimentary and performs no validity checking, thus, it is advised to avoid using it 5 | outside of `/src/Starnight.Caching/Shims` for now. 6 | 7 | It currently operates by taking all partial methods on a type and implementing them through a field of the name `underlying`. Since 8 | the emitted `ShimAttribute` holds the interface the shim is built over, in the future, it should be updated to utilize this 9 | type information, in order to only shim methods fulfilling the following criteria: 10 | 11 | - The method is present on the specified interface type. 12 | - The method is not yet implemented in another partial file (partiality is handled rather interestingly by source generation). 13 | - There is an object of the specified interface type that the shim can be implemented through. 14 | -------------------------------------------------------------------------------- /designs/ngen-internal-events.md: -------------------------------------------------------------------------------- 1 | # The Internal Event Deserialization generator 2 | 3 | The internal event deserialization generator is tasked with generating the deserializer for dispatch events. It is, more specifically, 4 | used to generate `/src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/EventDeserializer.cs` from `/data/events-internal.json`, 5 | according to the steps laid out in [the rudimentary native generator documentation](../CONTRIBUTING.md#internal-tooling). 6 | 7 | This scenario is considered a good use-case for the generator because events change very rarely, and thus, not regenerating the 8 | deserializer on every build is perfectly warranted - in fact, doing so is a waste of time and resources. 9 | -------------------------------------------------------------------------------- /designs/readme.md: -------------------------------------------------------------------------------- 1 | # Starnight Designs 2 | 3 | This folder holds the documentation and rationales to all major, compulsive design choices taken in Starnight, as well as smaller decisions, 4 | ideas and designs, to preserve the rationales for later considerations and revisions. 5 | 6 | ## Table of Contents 7 | 8 | 1. Roslyn Source Generators 9 | 10 | - [The Caching Generator](./gen-caching.md) 11 | - [The Shim Generator](./gen-shim.md) 12 | 13 | 2. Native Code Generators 14 | 15 | - [The Internal Event Deserialization Generator](./ngen-internal-events.md) 16 | -------------------------------------------------------------------------------- /docs/articles/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StarnightLibrary/starnight/f9166f9d94d6c2cba9046f30cf1095d288292da0/docs/articles/index.md -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | this is a thing -------------------------------------------------------------------------------- /gen/Caching/CacheUpdaterMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.Caching; 2 | 3 | using System; 4 | 5 | using Microsoft.CodeAnalysis; 6 | 7 | internal record struct CacheUpdaterMetadata 8 | { 9 | public String ContainingTypeName { get; set; } 10 | public String ContainingNamespaceName { get; set; } 11 | public String MethodName { get; set; } 12 | public Accessibility MethodAccessibility { get; set; } 13 | public ITypeSymbol ReturnType { get; set; } 14 | public ITypeSymbol FirstParameterType { get; set; } 15 | public ITypeSymbol SecondParameterType { get; set; } 16 | public String FirstParameter { get; set; } 17 | public String SecondParameter { get; set; } 18 | 19 | public String TrackingStruct => $"StarnightCachingTrackingType_{this.ReturnType.Name}"; 20 | } 21 | -------------------------------------------------------------------------------- /gen/NamespaceSymbolExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using Microsoft.CodeAnalysis; 7 | 8 | internal static class NamespaceSymbolExtensions 9 | { 10 | public static String GetFullNamespace(this INamespaceSymbol symbol) 11 | { 12 | INamespaceSymbol @namespace = symbol; 13 | 14 | List names = new() 15 | { 16 | @namespace.Name 17 | }; 18 | 19 | while(!@namespace.ContainingNamespace.IsGlobalNamespace) 20 | { 21 | @namespace = @namespace.ContainingNamespace; 22 | names.Add(@namespace.Name); 23 | } 24 | 25 | names.Reverse(); 26 | return String.Join(".", names); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gen/Shims/ShimGeneratorHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.Shims; 2 | 3 | using System; 4 | 5 | internal class ShimGeneratorHelper 6 | { 7 | public const String Attribute = """ 8 | // auto-generated code 9 | namespace Starnight.SourceGenerators.Shims; 10 | 11 | [global::System.AttributeUsage(global::System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)] 12 | [global::System.CodeDom.Compiler.GeneratedCode("starnight-shim-generator", "0.1.0")] 13 | internal sealed class ShimAttribute : global::System.Attribute 14 | { } 15 | """; 16 | } 17 | -------------------------------------------------------------------------------- /gen/WrapperEntities/DebugLogger.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | using System.Text; 5 | 6 | internal static class DebugLogger 7 | { 8 | private static readonly StringBuilder log = new(); 9 | 10 | public static String Output => log.ToString(); 11 | 12 | public static void AppendLine(String line) => log.AppendLine(line); 13 | } 14 | -------------------------------------------------------------------------------- /gen/WrapperEntities/DictionaryTransformationMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | 5 | internal record struct DictionaryTransformationMetadata 6 | { 7 | public String InternalKey { get; set; } 8 | 9 | public String InternalValue { get; set; } 10 | 11 | public String WrapperKey { get; set; } 12 | 13 | public String WrapperValue { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /gen/WrapperEntities/WrapperMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using Microsoft.CodeAnalysis; 7 | 8 | internal record WrapperMetadata 9 | { 10 | public String ContainingNamespace { get; set; } = null!; 11 | public String TypeName { get; set; } = null!; 12 | public List DisabledTransformations { get; set; } = null!; 13 | public Dictionary Renames { get; set; } = null!; 14 | public Boolean GenerateInterfaceImplementation { get; set; } = false; 15 | public INamedTypeSymbol InternalType { get; set; } = null!; 16 | } 17 | -------------------------------------------------------------------------------- /gen/WrapperEntities/WrapperPropertyMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | 5 | using Microsoft.CodeAnalysis; 6 | 7 | internal class WrapperPropertyMetadata 8 | { 9 | public String NewName { get; set; } = null!; 10 | 11 | public WrapperTransformations AppliedTransformations { get; set; } = null!; 12 | 13 | public String TypeDeclaration { get; set; } = null!; 14 | 15 | public String? IntermediaryTypeDeclaration { get; set; } = null; 16 | 17 | public INamedTypeSymbol InternalType { get; set; } = null!; 18 | 19 | public DictionaryTransformationMetadata? DictionaryMetadata { get; set; } = null!; 20 | } 21 | -------------------------------------------------------------------------------- /gen/WrapperEntities/WrapperTransformationType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | 5 | internal enum WrapperTransformationType : Byte 6 | { 7 | None, 8 | OptionalFolding, 9 | ImmutableList, 10 | ImmutableDictionary, 11 | DictionaryKey, 12 | Snowflake, 13 | NullableBoolean, 14 | Records, 15 | ConservationNullableValueType, 16 | ConservationGeneral, 17 | ConservationEnumerable, 18 | ConservationDictionary 19 | } 20 | -------------------------------------------------------------------------------- /gen/WrapperEntities/WrapperTransformations.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.SourceGenerators.WrapperEntities; 2 | 3 | using System; 4 | 5 | internal record WrapperTransformations 6 | { 7 | private readonly WrapperTransformationType[] transformations = new WrapperTransformationType[8]; 8 | private Int32 index = 0; 9 | 10 | public WrapperTransformations() 11 | { 12 | } 13 | 14 | public WrapperTransformationType this[Int32 index] 15 | { 16 | get => this.transformations[index]; 17 | set => this.transformations[index] = value; 18 | } 19 | 20 | public WrapperTransformationType Current 21 | { 22 | get => this[this.index]; 23 | set => this[this.index] = value; 24 | } 25 | 26 | public void MoveNext() => this.index++; 27 | 28 | public void Reset() => this.index = 0; 29 | 30 | public WrapperTransformationType Next 31 | => this[this.index + 1]; 32 | 33 | public WrapperTransformationType DictionaryNext 34 | => this[this.index + 2]; 35 | } 36 | -------------------------------------------------------------------------------- /img/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StarnightLibrary/starnight/f9166f9d94d6c2cba9046f30cf1095d288292da0/img/banner.png -------------------------------------------------------------------------------- /img/starnight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StarnightLibrary/starnight/f9166f9d94d6c2cba9046f30cf1095d288292da0/img/starnight.png -------------------------------------------------------------------------------- /pack.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | for %%x in (%*) do ( 4 | 5 | if "%%x"=="shared" ( 6 | dotnet pack -o build -c Release src/Starnight.Shared --include-source --include-symbols -p:TreatWarningsAsErrors=false 7 | ) 8 | 9 | if "%%x"=="caching-providers" ( 10 | dotnet pack -o build -c Release src/Starnight.Caching.Providers --include-source --include-symbols -p:TreatWarningsAsErrors=false 11 | ) 12 | 13 | if "%%x"=="internal" ( 14 | dotnet pack -o build -c Release src/Starnight.Internal --include-source --include-symbols -p:TreatWarningsAsErrors=false 15 | ) 16 | 17 | if "%%x"=="caching" ( 18 | dotnet pack -o build -c Release src/Starnight.Caching --include-source --include-symbols -p:TreatWarningsAsErrors=false 19 | ) 20 | 21 | if "%%x"=="main" ( 22 | dotnet pack -o build -c Release src/Starnight --include-source --include-symbols -p:TreatWarningsAsErrors=false 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /pack.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build 2 | 3 | for var in "$@" 4 | do 5 | case $var in 6 | 7 | shared) 8 | dotnet pack -o build -c Release src/Starnight.Shared --include-source --include-symbols -p:TreatWarningsAsErrors=false 9 | ;; 10 | 11 | caching-providers) 12 | dotnet pack -o build -c Release src/Starnight.Caching.Providers --include-source --include-symbols -p:TreatWarningsAsErrors=false 13 | ;; 14 | 15 | internal) 16 | dotnet pack -o build -c Release src/Starnight.Internal --include-source --include-symbols -p:TreatWarningsAsErrors=false 17 | ;; 18 | 19 | caching) 20 | dotnet pack -o build -c Release src/Starnight.Caching --include-source --include-symbols -p:TreatWarningsAsErrors=false 21 | ;; 22 | 23 | main) 24 | dotnet pack -o build -c Release src/Starnight --include-source --include-symbols -p:TreatWarningsAsErrors=false 25 | ;; 26 | esac 27 | done 28 | -------------------------------------------------------------------------------- /src/Starnight.Caching.Providers/Abstractions/BaseCacheEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Caching.Providers.Abstractions; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents an extendable class for more complex cache entries supported by . 7 | /// 8 | public record BaseCacheEntry 9 | { 10 | /// 11 | /// The key used to store this object into cache. 12 | /// 13 | public String Key { get; set; } = null!; 14 | 15 | /// 16 | /// The value of this cache entry. 17 | /// 18 | public Object Value { get; set; } = null!; 19 | } 20 | -------------------------------------------------------------------------------- /src/Starnight.Caching.Providers/Memory/MemoryCacheEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Caching.Providers.Memory; 2 | 3 | using System; 4 | 5 | using Microsoft.Extensions.Caching.Memory; 6 | 7 | using Starnight.Caching.Providers.Abstractions; 8 | 9 | /// 10 | /// Represents an entry in a 11 | /// 12 | public record MemoryCacheEntry : BaseCacheEntry 13 | { 14 | /// 15 | /// Overrides the absolute expiration for this entry. 16 | /// 17 | public TimeSpan? AbsoluteExpiration { get; set; } 18 | 19 | /// 20 | /// Overrides the sliding expiration for this entry. 21 | /// 22 | public TimeSpan? SlidingExpiration { get; set; } 23 | 24 | /// 25 | /// Sets a post-eviction callback for this entry. 26 | /// 27 | public PostEvictionDelegate? PostEvictionCallback { get; set; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Caching.Providers/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Caching.Providers; 2 | 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | using Starnight.Caching.Providers.Abstractions; 6 | using Starnight.Caching.Providers.Memory; 7 | 8 | /// 9 | /// Provides extension methods to for starnight's caching. 10 | /// 11 | public static class ServiceCollectionExtensions 12 | { 13 | /// 14 | /// Adds starnight's memory caching to the service collection. 15 | /// 16 | public static IServiceCollection AddStarnightMemoryCache(this IServiceCollection services) 17 | => services.AddSingleton(); 18 | } 19 | -------------------------------------------------------------------------------- /src/Starnight.Caching.Providers/Starnight.Caching.Providers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Lightweight and fast Discord API wrapper 5 | 0.3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Starnight.Caching.Providers/StarnightCacheKind.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Caching.Providers; 2 | 3 | using Starnight.Caching.Providers.Memory; 4 | 5 | /// 6 | /// Represents all available caching provider implementations. 7 | /// 8 | public enum StarnightCacheKind 9 | { 10 | /// 11 | /// 12 | /// 13 | Memory 14 | } 15 | -------------------------------------------------------------------------------- /src/Starnight.Caching/Starnight.Caching.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Caching library for Starnight 5 | 0.4.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Converters/OptionalParameterJsonConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Converters; 2 | 3 | using System; 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | internal class OptionalParameterJsonConverter : JsonConverter> 8 | { 9 | public override Optional Read 10 | ( 11 | ref Utf8JsonReader reader, 12 | Type typeToConvert, 13 | JsonSerializerOptions options 14 | ) 15 | { 16 | TParamType value = JsonSerializer.Deserialize(ref reader, options)!; 17 | return new Optional(value); 18 | } 19 | 20 | 21 | public override void Write 22 | ( 23 | Utf8JsonWriter writer, 24 | Optional value, 25 | JsonSerializerOptions options 26 | ) 27 | { 28 | if(value.HasValue) 29 | { 30 | JsonSerializer.Serialize(writer, value.Value, options); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Converters/OptionalParameterJsonConverterFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Converters; 2 | 3 | using System; 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | internal class OptionalParameterJsonConverterFactory : JsonConverterFactory 8 | { 9 | public override Boolean CanConvert(Type typeToConvert) 10 | => typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Optional<>); 11 | 12 | public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options) 13 | { 14 | Type wrappedType = typeToConvert.GetGenericArguments()[0]; 15 | 16 | return (JsonConverter)Activator.CreateInstance 17 | ( 18 | typeof(OptionalParameterJsonConverter<>) 19 | .MakeGenericType(wrappedType) 20 | )!; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Channels/DiscordChannelMention.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Channels; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Entities; 7 | 8 | /// 9 | /// Represents a discord channel mention object. 10 | /// 11 | public sealed record DiscordChannelMention : DiscordSnowflakeObject 12 | { 13 | /// 14 | /// The guild containing the channel. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The type of the mentioned channel. 21 | /// 22 | [JsonPropertyName("type")] 23 | public required DiscordChannelType ChannelType { get; init; } 24 | 25 | /// 26 | /// The name of the mentioned channel. 27 | /// 28 | [JsonPropertyName("name")] 29 | public required String Name { get; init; } = default!; 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Channels/DiscordChannelOverwrite.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Channels; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Entities; 6 | 7 | /// 8 | /// Represents a discord channel permission overwrite. 9 | /// 10 | public sealed record DiscordChannelOverwrite : DiscordSnowflakeObject 11 | { 12 | /// 13 | /// Overwrite type - either role or member. 14 | /// 15 | [JsonPropertyName("type")] 16 | public required DiscordChannelOverwriteType Type { get; init; } 17 | 18 | /// 19 | /// Granted permissions, by overwrite. 20 | /// 21 | [JsonPropertyName("allow")] 22 | public required DiscordPermissions Allow { get; init; } 23 | 24 | /// 25 | /// Denied permissions, by overwrite. 26 | /// 27 | [JsonPropertyName("deny")] 28 | public required DiscordPermissions Deny { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Channels/DiscordFollowedChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Channels; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a followed announcement channel. 8 | /// 9 | public sealed record DiscordFollowedChannel 10 | { 11 | /// 12 | /// Snowflake identifier of the source channel. 13 | /// 14 | [JsonPropertyName("channel_id")] 15 | public required Int64 ChannelId { get; init; } 16 | 17 | /// 18 | /// Snowflake identifier of the created target webhook. 19 | /// 20 | [JsonPropertyName("webhook_id")] 21 | public required Int64 WebhookId { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Channels/Threads/DiscordDefaultForumReaction.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Channels.Threads; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the default emoji reaction to a forum post. Exactly one field must be set. 8 | /// 9 | public sealed record DiscordDefaultForumReaction 10 | { 11 | /// 12 | /// The snowflake ID of a custom emoji. 13 | /// 14 | [JsonPropertyName("emoji_id")] 15 | public Int64? EmojiId { get; init; } 16 | 17 | /// 18 | /// The unicode representation of the emoji. 19 | /// 20 | [JsonPropertyName("emoji_name")] 21 | public String? EmojiName { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/AutoModeration/DiscordAutoModerationAction.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds.AutoModeration; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Entities; 6 | 7 | /// 8 | /// Represents an action which is executed whenever a rule is triggered. 9 | /// 10 | public sealed record DiscordAutoModerationAction 11 | { 12 | /// 13 | /// The type of action. 14 | /// 15 | [JsonPropertyName("type")] 16 | public required DiscordAutoModerationActionType Type { get; init; } 17 | 18 | /// 19 | /// Additional metadata for execution of this action. 20 | /// 21 | [JsonPropertyName("metadata")] 22 | public Optional Metadata { get; init; } 23 | } 24 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordGuildBan.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | 8 | /// 9 | /// Represents a guild ban. 10 | /// 11 | public sealed record DiscordGuildBan 12 | { 13 | /// 14 | /// Audit log reason for this ban. 15 | /// 16 | [JsonPropertyName("reason")] 17 | public String? Reason { get; init; } 18 | 19 | /// 20 | /// The user affected by this ban. 21 | /// 22 | [JsonPropertyName("user")] 23 | public required DiscordUser User { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordGuildIntegrationAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a Discord Guild Integration Account object. 8 | /// 9 | public sealed record DiscordGuildIntegrationAccount 10 | { 11 | /// 12 | /// ID of the integration account. 13 | /// 14 | [JsonPropertyName("id")] 15 | public required String Id { get; init; } 16 | 17 | /// 18 | /// Name of the integration account. 19 | /// 20 | [JsonPropertyName("name")] 21 | public required String Name { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordGuildWelcomeScreen.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents a welcome screen for this guild. 9 | /// 10 | public sealed record DiscordGuildWelcomeScreen 11 | { 12 | /// 13 | /// The guild description shown in this welcome screen. 14 | /// 15 | [JsonPropertyName("description")] 16 | public String? Description { get; init; } 17 | 18 | /// 19 | /// The channels shown in this welcome screen, up to 5. 20 | /// 21 | [JsonPropertyName("welcome_channels")] 22 | public required IEnumerable WelcomeChannels { get; init; } 23 | } 24 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordGuildWidgetSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents settings for the object. 8 | /// 9 | public sealed record DiscordGuildWidgetSettings 10 | { 11 | /// 12 | /// Whether this widget should be enabled. 13 | /// 14 | [JsonPropertyName("enabled")] 15 | public required Boolean IsEnabled { get; init; } 16 | 17 | /// 18 | /// The snowflake identifier of the channel this widget binds to. 19 | /// 20 | [JsonPropertyName("channel_id")] 21 | public Int64? ChannelId { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordScheduledEventMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents metadata about a scheduled event. 8 | /// 9 | public sealed record DiscordScheduledEventMetadata 10 | { 11 | /// 12 | /// Location of this event, 1 - 100 characters. 13 | /// 14 | [JsonPropertyName("location")] 15 | public Optional Location { get; init; } 16 | } 17 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordScheduledEventStatus.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the status of a scheduled event. 5 | /// 6 | /// 7 | /// Once the status is set to or , the status can no longer be updated. 8 | /// 9 | public enum DiscordScheduledEventStatus 10 | { 11 | Scheduled = 1, 12 | Active, 13 | Completed, 14 | Cancelled 15 | } 16 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordScheduledEventUser.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | 8 | /// 9 | /// Represents a scheduled event user. 10 | /// 11 | public sealed record DiscordScheduledEventUser 12 | { 13 | /// 14 | /// The snowflake identifier of the event the user subscribed to. 15 | /// 16 | [JsonPropertyName("guild_scheduled_event_id")] 17 | public required Int64 ScheduledEventId { get; init; } 18 | 19 | /// 20 | /// The user which subscribed to the event. 21 | /// 22 | [JsonPropertyName("user")] 23 | public required DiscordUser User { get; init; } 24 | 25 | /// 26 | /// Guild member object for the specified user in the guild this event belongs to. 27 | /// 28 | [JsonPropertyName("member")] 29 | public Optional Member { get; init; } 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Guilds/DiscordUnavailableGuild.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an unavailable guild, a guild which is either unavailable or not yet sent to the client. 8 | /// 9 | public sealed record DiscordUnavailableGuild : DiscordSnowflakeObject 10 | { 11 | /// 12 | /// Indicates whether this guild is unavailable. 13 | /// 14 | /// 15 | /// If this is sent as part of a GuildDeleted event, this indicates whether the guild is actually unavailable or 16 | /// whether the user has been removed from this guild. 17 | /// 18 | [JsonPropertyName("unavailable")] 19 | public required Boolean Unavailable { get; init; } 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Interactions/ApplicationCommands/DiscordApplicationCommandPermission.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Interactions.ApplicationCommands; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Entities; 7 | 8 | /// 9 | /// Represents a singular application command permission overwrite. 10 | /// 11 | public sealed record DiscordApplicationCommandPermission : DiscordSnowflakeObject 12 | { 13 | /// 14 | /// The object type targeted by this overwrite. 15 | /// 16 | [JsonPropertyName("type")] 17 | public required DiscordApplicationCommandPermissionType Type { get; init; } 18 | 19 | /// 20 | /// Whether this permission allows or disallows use of the command. 21 | /// 22 | [JsonPropertyName("permission")] 23 | public required Boolean Permission { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Interactions/Components/AbstractInteractiveDiscordMessageComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Interactions.Components; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an interactive message component. 8 | /// 9 | [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] 10 | [JsonDerivedType(typeof(DiscordButtonComponent), 2)] 11 | [JsonDerivedType(typeof(DiscordSelectMenuComponent), 3)] 12 | [JsonDerivedType(typeof(DiscordTextInputComponent), 4)] 13 | public abstract record AbstractInteractiveDiscordMessageComponent : AbstractDiscordMessageComponent 14 | { 15 | /// 16 | /// A developer-defined ID for this component, max. 100 characters. 17 | /// 18 | [JsonPropertyName("custom_id")] 19 | public Optional CustomId { get; init; } 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Interactions/Components/DiscordActionRowComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Interactions.Components; 2 | 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an action row: a non-interactive container for other components. 8 | /// 9 | public record DiscordActionRowComponent : AbstractDiscordMessageComponent 10 | { 11 | /// 12 | /// Up to five sub-components for this action row. 13 | /// 14 | [JsonPropertyName("components")] 15 | public IEnumerable Components { get; init; } = null!; 16 | } 17 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/DiscordMessageActivity.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Entities; 7 | 8 | /// 9 | /// Represents a message activity. 10 | /// 11 | public sealed record DiscordMessageActivity 12 | { 13 | /// 14 | /// Type of this message activity. 15 | /// 16 | [JsonPropertyName("type")] 17 | public required DiscordMessageActivityType Type { get; init; } 18 | 19 | /// 20 | /// Party ID from a rich presence event. 21 | /// 22 | [JsonPropertyName("party_id")] 23 | public Optional PartyId { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/DiscordMessageReaction.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | 8 | /// 9 | /// Represents a discord message reaction. 10 | /// 11 | public sealed record DiscordMessageReaction 12 | { 13 | /// 14 | /// Gets however often this emoji has been used to react. 15 | /// 16 | [JsonPropertyName("count")] 17 | public required Int32 Count { get; init; } 18 | 19 | /// 20 | /// Whether the current user reacted using this emoji. 21 | /// 22 | [JsonPropertyName("me")] 23 | public required Boolean CurrentUserReacted { get; init; } 24 | 25 | /// 26 | /// More emoji information 27 | /// 28 | [JsonPropertyName("emoji")] 29 | public required DiscordEmoji Emoji { get; init; } 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedAuthor.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a discord embed author. 8 | /// 9 | public sealed record DiscordEmbedAuthor 10 | { 11 | /// 12 | /// Author name. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// Author url. 19 | /// 20 | [JsonPropertyName("url")] 21 | public Optional Url { get; init; } 22 | 23 | /// 24 | /// Author icon url. This only supports http://, https:// and attachment:// 25 | /// 26 | [JsonPropertyName("icon_url")] 27 | public Optional IconUrl { get; init; } 28 | 29 | /// 30 | /// Proxied author icon url. 31 | /// 32 | [JsonPropertyName("proxy_icon_url")] 33 | public Optional ProxiedIconUrl { get; init; } 34 | } 35 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedField.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an embed field. 8 | /// 9 | public sealed record DiscordEmbedField 10 | { 11 | /// 12 | /// Field title. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// Field text. 19 | /// 20 | [JsonPropertyName("value")] 21 | public required String Value { get; init; } 22 | 23 | /// 24 | /// Whether this field should be displayed inline. 25 | /// 26 | [JsonPropertyName("inline")] 27 | public Optional Inline { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedFooter.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an embed footer. 8 | /// 9 | public sealed record DiscordEmbedFooter 10 | { 11 | /// 12 | /// Footer text. 13 | /// 14 | [JsonPropertyName("text")] 15 | public required String Text { get; init; } 16 | 17 | /// 18 | /// Footer icon url. This only supports http://, https:// and attachment:// 19 | /// 20 | [JsonPropertyName("icon_url")] 21 | public Optional IconUrl { get; init; } 22 | 23 | /// 24 | /// Proxied footer icon url. 25 | /// 26 | [JsonPropertyName("proxy_icon_url")] 27 | public Optional ProxiedIconUrl { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedImage.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an image displayed in an embed. 8 | /// 9 | public sealed record DiscordEmbedImage 10 | { 11 | /// 12 | /// Image source url. 13 | /// 14 | [JsonPropertyName("url")] 15 | public required String Url { get; init; } 16 | 17 | /// 18 | /// A proxied source url for this image. 19 | /// 20 | [JsonPropertyName("proxy_url")] 21 | public Optional ProxiedUrl { get; init; } 22 | 23 | /// 24 | /// Image height in pixels. 25 | /// 26 | [JsonPropertyName("height")] 27 | public Optional Height { get; init; } 28 | 29 | /// 30 | /// Image width in pixels. 31 | /// 32 | [JsonPropertyName("width")] 33 | public Optional Width { get; init; } 34 | } 35 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an embed provider. 8 | /// 9 | public sealed record DiscordEmbedProvider 10 | { 11 | /// 12 | /// Provider name. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// Provider url. 19 | /// 20 | [JsonPropertyName("url")] 21 | public Optional Url { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Messages/Embeds/DiscordEmbedVideo.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Messages.Embeds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a video played in a discord embed. 8 | /// 9 | public sealed record DiscordEmbedVideo 10 | { 11 | /// 12 | /// Video source url. 13 | /// 14 | [JsonPropertyName("url")] 15 | public required String Url { get; init; } 16 | 17 | /// 18 | /// A proxied source url for this video. 19 | /// 20 | [JsonPropertyName("proxy_url")] 21 | public Optional ProxiedUrl { get; init; } 22 | 23 | /// 24 | /// Video height in pixels. 25 | /// 26 | [JsonPropertyName("height")] 27 | public Optional Height { get; init; } 28 | 29 | /// 30 | /// Video width in pixels. 31 | /// 32 | [JsonPropertyName("width")] 33 | public Optional Width { get; init; } 34 | } 35 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Stickers/DiscordMessageSticker.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Stickers; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Entities; 7 | using Starnight.Internal.Entities.Messages; 8 | 9 | /// 10 | /// Represents a stripped-down sticker object, used in s 11 | /// 12 | public sealed record DiscordMessageSticker : DiscordSnowflakeObject 13 | { 14 | /// 15 | /// Name of this sticker. 16 | /// 17 | [JsonPropertyName("name")] 18 | public required String Name { get; init; } 19 | 20 | /// 21 | /// Format type of this sticker. 22 | /// 23 | [JsonPropertyName("format_type")] 24 | public required DiscordStickerFormatType Format { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Teams/DiscordApplicationInstallParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Teams; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | using Starnight.Entities; 8 | 9 | /// 10 | /// Represents the parameters required for installing an application. 11 | /// 12 | public record DiscordApplicationInstallParameters 13 | { 14 | /// 15 | /// The OAuth2 scopes to add this application to the server with. 16 | /// 17 | [JsonPropertyName("scopes")] 18 | public required IEnumerable Scopes { get; init; } 19 | 20 | /// 21 | /// The permissions this application will request for its bot role. 22 | /// 23 | [JsonPropertyName("permissions")] 24 | public required DiscordPermissions Permissions { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Teams/DiscordTeam.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Teams; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents a discord team. 9 | /// 10 | public sealed record DiscordTeam : DiscordSnowflakeObject 11 | { 12 | /// 13 | /// The icon hash for this team's icon. 14 | /// 15 | [JsonPropertyName("icon")] 16 | public String? Icon { get; init; } 17 | 18 | /// 19 | /// Array of team members. 20 | /// 21 | [JsonPropertyName("members")] 22 | public required IEnumerable Members { get; init; } 23 | 24 | /// 25 | /// Team name. 26 | /// 27 | [JsonPropertyName("name")] 28 | public required String Name { get; init; } 29 | 30 | /// 31 | /// Team owner snowflake identifier. 32 | /// 33 | [JsonPropertyName("owner_user_id")] 34 | public required Int64 TeamOwnerId { get; init; } 35 | } 36 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/Activities/DiscordActivityButton.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users.Activities; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a clickable RPC button. Every presence may have at most two buttons. 8 | /// 9 | public sealed record DiscordActivityButton 10 | { 11 | /// 12 | /// Text shown on the button, 1 - 32 characters. 13 | /// 14 | [JsonPropertyName("label")] 15 | public required String Label { get; init; } 16 | 17 | /// 18 | /// URL opened when clicking the button, 1 - 512 characters. 19 | /// 20 | [JsonPropertyName("url")] 21 | public required String Url { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/Activities/DiscordActivityEmoji.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users.Activities; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an emoji displayed as part of an activity. 8 | /// 9 | public sealed record DiscordActivityEmoji 10 | { 11 | /// 12 | /// The name of the emoji. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// The ID of the emoji. 19 | /// 20 | [JsonPropertyName("id")] 21 | public Optional Id { get; init; } 22 | 23 | /// 24 | /// Whether this emoji is animated. 25 | /// 26 | [JsonPropertyName("animated")] 27 | public Optional Animated { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/Activities/DiscordActivityParty.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users.Activities; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents an activity party. 9 | /// 10 | public sealed record DiscordActivityParty 11 | { 12 | /// 13 | /// The party ID. 14 | /// 15 | [JsonPropertyName("id")] 16 | public Optional Id { get; init; } 17 | 18 | /// 19 | /// size[0]: current size of the party. 20 | /// 21 | /// size[1]: maximum size of the party. 22 | /// 23 | [JsonPropertyName("size")] 24 | public Optional> Size { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/Activities/DiscordActivitySecrets.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users.Activities; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the secrets 8 | /// 9 | public sealed record DiscordActivitySecrets 10 | { 11 | /// 12 | /// The secret used to join a party. 13 | /// 14 | [JsonPropertyName("join")] 15 | public Optional JoinSecret { get; init; } 16 | 17 | /// 18 | /// The secret used to spectate a game. 19 | /// 20 | [JsonPropertyName("spectate")] 21 | public Optional SpectateSecret { get; init; } 22 | 23 | /// 24 | /// The secret for a specific instanced match. 25 | /// 26 | [JsonPropertyName("match")] 27 | public Optional MatchSecret { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/Activities/DiscordActivityTimestamps.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users.Activities; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the timestamps associated with an activity. 8 | /// 9 | public sealed record DiscordActivityTimestamps 10 | { 11 | /// 12 | /// Unix time in milliseconds of when this activity started. 13 | /// 14 | [JsonPropertyName("start")] 15 | public Optional Start { get; init; } 16 | 17 | /// 18 | /// Unix time in milliseconds of when this activity will end. 19 | /// 20 | [JsonPropertyName("end")] 21 | public Optional End { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Entities/Users/DiscordClientStatus.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Entities.Users; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the statuses of this user's current platforms. 8 | /// 9 | public sealed record DiscordClientStatus 10 | { 11 | /// 12 | /// The user's status set for an active desktop session. 13 | /// 14 | [JsonPropertyName("desktop")] 15 | public Optional Desktop { get; init; } 16 | 17 | /// 18 | /// The user's status set for an active mobile session. 19 | /// 20 | [JsonPropertyName("mobile")] 21 | public Optional Mobile { get; init; } 22 | 23 | /// 24 | /// The user's status set for an active web session. 25 | /// 26 | [JsonPropertyName("web")] 27 | public Optional Web { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Exceptions/AbstractDiscordException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Exceptions; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents an abstract base class for all gateway/rest exceptions. 7 | /// 8 | public abstract class AbstractDiscordException : Exception 9 | { 10 | /// 11 | public AbstractDiscordException 12 | ( 13 | String message 14 | ) 15 | : base(message) 16 | { } 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Exceptions/StarnightGatewayConnectionRefusedException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | using System.Runtime.CompilerServices; 5 | 6 | using Starnight.Internal.Gateway.Payloads; 7 | 8 | /// 9 | /// An exception thrown if Starnight refused to connect to the gateway. 10 | /// 11 | public class StarnightGatewayConnectionRefusedException : AbstractStarnightException 12 | { 13 | /// 14 | /// The session start limit received from Discord. 15 | /// 16 | public DiscordSessionStartLimit? SessionStartLimit { get; set; } 17 | 18 | public StarnightGatewayConnectionRefusedException 19 | ( 20 | String message, 21 | DiscordSessionStartLimit? sessionStartLimit = null, 22 | 23 | [CallerMemberName] 24 | String caller = "" 25 | ) 26 | : base(message, caller) 27 | => this.SessionStartLimit = sessionStartLimit; 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Exceptions/StarnightInvalidListenerException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Exceptions; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Runtime.CompilerServices; 6 | 7 | using Starnight.Exceptions; 8 | 9 | /// 10 | /// An exception thrown if Starnight encountered an outbound event too large to send to Discord. 11 | /// 12 | public class StarnightInvalidListenerException : AbstractStarnightException 13 | { 14 | /// 15 | /// The event whose serialized form exceeded 4096 bytes. 16 | /// 17 | public required Type ListenerType { get; set; } 18 | 19 | [SetsRequiredMembers] 20 | public StarnightInvalidListenerException 21 | ( 22 | String message, 23 | Type listenerType, 24 | 25 | [CallerMemberName] 26 | String caller = "" 27 | ) 28 | : base(message, caller) 29 | => this.ListenerType = listenerType; 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Exceptions/StarnightInvalidOutboundEventException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Runtime.CompilerServices; 6 | 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Thrown if an event is considered invalid by the Starnight gateway client. 11 | /// 12 | public class StarnightInvalidOutboundEventException : AbstractStarnightException 13 | { 14 | /// 15 | /// The event which was invalid in one way or another. 16 | /// 17 | public required IDiscordGatewayEvent Event { get; set; } 18 | 19 | [SetsRequiredMembers] 20 | public StarnightInvalidOutboundEventException 21 | ( 22 | String message, 23 | IDiscordGatewayEvent @event, 24 | 25 | [CallerMemberName] 26 | String caller = "" 27 | ) 28 | : base(message, caller) 29 | => this.Event = @event; 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Exceptions/StarnightRequestRejectedException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Runtime.CompilerServices; 6 | 7 | using Starnight.Internal.Rest; 8 | 9 | /// 10 | /// Thrown if Starnight rejected a request from being made. 11 | /// 12 | public class StarnightRequestRejectedException : AbstractStarnightException 13 | { 14 | /// 15 | /// The request Starnight rejected. 16 | /// 17 | public required IRestRequest Request { get; set; } 18 | 19 | [SetsRequiredMembers] 20 | public StarnightRequestRejectedException 21 | ( 22 | String message, 23 | IRestRequest request, 24 | 25 | [CallerMemberName] 26 | String caller = "" 27 | ) 28 | : base(message, caller) 29 | => this.Request = request; 30 | } 31 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Control/ZombiedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Control; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents a control event fired when the gateway considers the connection to be zombied. 7 | /// 8 | public sealed record ZombiedEvent : IGatewayEvent 9 | { 10 | /// 11 | /// Gets the last sequence ID received, for debugging purposes. 12 | /// 13 | public required Int32 LastReceivedSequence { get; init; } 14 | } 15 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/IDiscordGatewayEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events; 2 | 3 | /// 4 | /// Represents a barebones gateway payload. Note that implementers must set JSON attributes themselves, that is: 5 | /// 6 | /// 7 | /// - must be annotated as [JsonPropertyName("op")]
8 | ///
9 | public interface IDiscordGatewayEvent : IGatewayEvent 10 | { 11 | /// 12 | /// Indicates the opcode of this gateway event or command. 13 | /// 14 | public DiscordGatewayOpcode Opcode { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/IDiscordGatewayEvent`1.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events; 2 | /// 3 | /// Represents a payload for any opcode. Note that implementers must set JSON attributes themselves, that is: 4 | /// 5 | /// 6 | /// 7 | /// - must be annotated as [JsonPropertyName("d")]
8 | ///
9 | public interface IDiscordGatewayEvent : IDiscordGatewayEvent 10 | { 11 | /// 12 | /// The payload data for this command/event. 13 | /// 14 | public TData Data { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/IGatewayEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events; 2 | 3 | /// 4 | /// Marker interface for all events utilized by the Starnight gateway. 5 | /// 6 | public interface IGatewayEvent 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordConnectedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound; 8 | 9 | /// 10 | /// READY event. 11 | /// 12 | public sealed record DiscordConnectedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ConnectedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordHelloEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | using Starnight.Internal.Gateway.Payloads.Inbound; 7 | 8 | /// 9 | /// Represents a gateway Hello event. 10 | /// 11 | public sealed record DiscordHelloEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required HelloPayload Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public required DiscordGatewayOpcode Opcode { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordInboundHeartbeatEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | /// 6 | /// Fired by the gateway to indicate that a heartbeat has been acknowledged. 7 | /// 8 | public sealed record DiscordInboundHeartbeatEvent : IDiscordGatewayEvent 9 | { 10 | /// 11 | [JsonPropertyName("op")] 12 | public required DiscordGatewayOpcode Opcode { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordInvalidSessionEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | 8 | /// 9 | /// Indicates to the client that the session is invalid, and that it may need to reconnect. 10 | /// 11 | public sealed record DiscordInvalidSessionEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | /// Indicates whether the session is resumable. 15 | /// 16 | [JsonPropertyName("d")] 17 | public required Boolean Data { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("op")] 21 | public required DiscordGatewayOpcode Opcode { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordReconnectEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | /// 6 | /// Indicates to the client that it should reconnect. 7 | /// 8 | public sealed record DiscordReconnectEvent : IDiscordGatewayEvent 9 | { 10 | /// 11 | [JsonPropertyName("op")] 12 | public required DiscordGatewayOpcode Opcode { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordResumedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Dispatched if resumption was successful. 8 | /// 9 | public sealed record DiscordResumedEvent : IDiscordGatewayEvent 10 | { 11 | /// 12 | [JsonPropertyName("op")] 13 | public required DiscordGatewayOpcode Opcode { get; set; } 14 | 15 | /// 16 | [JsonPropertyName("s")] 17 | public required Int32 Sequence { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("t")] 21 | public required String EventName { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/DiscordUnknownInboundEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound; 2 | 3 | using System.Text.Json; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents an inbound event with an unknown/unexpected opcode. 8 | /// 9 | public sealed record DiscordUnknownInboundEvent : IDiscordGatewayEvent 10 | { 11 | /// 12 | [JsonPropertyName("op")] 13 | public DiscordGatewayOpcode Opcode { get; set; } 14 | 15 | /// 16 | /// The full payload of this event. 17 | /// 18 | [JsonPropertyName("event")] 19 | public JsonElement Event { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordAuditLogEntryCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds.Audit; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | public sealed record DiscordAuditLogEntryCreatedEvent 10 | : IDiscordGatewayDispatchEvent 11 | { 12 | /// 13 | [JsonPropertyName("s")] 14 | public required Int32 Sequence { get; set; } 15 | 16 | /// 17 | [JsonPropertyName("t")] 18 | public required String EventName { get; set; } 19 | 20 | /// 21 | [JsonPropertyName("d")] 22 | public required DiscordAuditLogEntry Data { get; set; } 23 | 24 | /// 25 | [JsonPropertyName("op")] 26 | public required DiscordGatewayOpcode Opcode { get; set; } 27 | } 28 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordAutoModerationRuleCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds.AutoModeration; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a new auto moderation rule is created. 11 | /// 12 | public sealed record DiscordAutoModerationRuleCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordAutoModerationRule Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordAutoModerationRuleDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds.AutoModeration; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when an auto moderation rule is deleted. 11 | /// 12 | public sealed record DiscordAutoModerationRuleDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordAutoModerationRule Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordAutoModerationRuleUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds.AutoModeration; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Sent when an auto moderation rule is updated. 11 | /// 12 | public sealed record DiscordAutoModerationRuleUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordAutoModerationRule Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordChannelCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a new channel is created. 11 | /// 12 | public sealed record DiscordChannelCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordChannelDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a channel is deleted. 11 | /// 12 | public sealed record DiscordChannelDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordChannelPinsUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a ChannelPinsUpdated event. 11 | /// 12 | public sealed record DiscordChannelPinsUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ChannelPinsUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordChannelUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a channel is updated. 11 | /// 12 | public sealed record DiscordChannelUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildBanAddedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildBanAdded event. 11 | /// 12 | public sealed record DiscordGuildBanAddedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildBanAddedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildBanRemovedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildBanRemoved event. 11 | /// 12 | public sealed record DiscordGuildBanRemovedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildBanRemovedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildCreated event. 11 | /// 12 | public sealed record DiscordGuildCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuild Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildDeleted event. 11 | /// 12 | public sealed record DiscordGuildDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordUnavailableGuild Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildEmojisUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildEmojisUpdated event. 11 | /// 12 | public sealed record DiscordGuildEmojisUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildEmojisUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildIntegrationsUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildIntegrationsUpdated event. 11 | /// 12 | public sealed record DiscordGuildIntegrationsUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildIntegrationsUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildMemberAddedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildMemberAdded event. 11 | /// 12 | public sealed record DiscordGuildMemberAddedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuildMember Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildMemberRemovedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildMemberRemoved event. 11 | /// 12 | public sealed record DiscordGuildMemberRemovedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildMemberRemovedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildMemberUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildMemberUpdated event. 11 | /// 12 | public sealed record DiscordGuildMemberUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuildMember Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildMembersChunkEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildMembersChunk event. 11 | /// 12 | public class DiscordGuildMembersChunkEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildMembersChunkPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildRoleCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildRoleCreated event. 11 | /// 12 | public sealed record DiscordGuildRoleCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildRoleCreatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildRoleDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildRoleDeleted event. 11 | /// 12 | public sealed record DiscordGuildRoleDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildRoleDeletedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildRoleUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildRoleUpdated event. 11 | /// 12 | public sealed record DiscordGuildRoleUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildRoleUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildStickersUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildStickersUpdated event. 11 | /// 12 | public sealed record DiscordGuildStickersUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required GuildStickersUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordGuildUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildUpdated event. 11 | /// 12 | public sealed record DiscordGuildUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuild Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordIntegrationCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents an IntegrationCreated event. 11 | /// 12 | public sealed record DiscordIntegrationCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuildIntegration Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordIntegrationDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents an IntegrationDeleted event. 11 | /// 12 | public sealed record DiscordIntegrationDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required IntegrationDeletedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordIntegrationUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents an IntegrationUpdated event. 11 | /// 12 | public sealed record DiscordIntegrationUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordGuildIntegration Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordInteractionCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Interactions; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents an InteractionCreated event. 11 | /// 12 | public sealed record DiscordInteractionCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordInteraction Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordInviteCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents an InviteCreated event. 11 | /// 12 | public sealed record DiscordInviteCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required InviteCreatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordInviteDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents an InviteDeleted event. 11 | /// 12 | public sealed record DiscordInviteDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required InviteDeletedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessageCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Messages; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a MessageCreated event. 11 | /// 12 | public sealed record DiscordMessageCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordMessage Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessageDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a MessageDeleted event. 11 | /// 12 | public sealed record DiscordMessageDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required MessageDeletedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessageReactionAddedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a MessageReactionAdded event. 11 | /// 12 | public sealed record DiscordMessageReactionAddedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required MessageReactionAddedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessageReactionRemovedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a MessageReactionRemoved event. 11 | /// 12 | public sealed record DiscordMessageReactionRemovedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required MessageReactionRemovedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessageUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Messages; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | public sealed record DiscordMessageUpdatedEvent : IDiscordGatewayDispatchEvent 10 | { 11 | /// 12 | [JsonPropertyName("s")] 13 | public required Int32 Sequence { get; set; } 14 | 15 | /// 16 | [JsonPropertyName("t")] 17 | public required String EventName { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("d")] 21 | public required DiscordMessage Data { get; set; } 22 | 23 | /// 24 | [JsonPropertyName("op")] 25 | public required DiscordGatewayOpcode Opcode { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordMessagesBulkDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | public sealed record DiscordMessagesBulkDeletedEvent : IDiscordGatewayDispatchEvent 10 | { 11 | /// 12 | [JsonPropertyName("s")] 13 | public required Int32 Sequence { get; set; } 14 | 15 | /// 16 | [JsonPropertyName("t")] 17 | public required String EventName { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("d")] 21 | public required MessagesBulkDeletedPayload Data { get; set; } 22 | 23 | /// 24 | [JsonPropertyName("op")] 25 | public required DiscordGatewayOpcode Opcode { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordPresenceUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a PresenceUpdated event. 11 | /// 12 | public sealed record DiscordPresenceUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required PresenceUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordScheduledEventCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildScheduledEventCreated event. 11 | /// 12 | public sealed record DiscordScheduledEventCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordScheduledEvent Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordScheduledEventDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildScheduledEventDeleted event. 11 | /// 12 | public sealed record DiscordScheduledEventDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordScheduledEvent Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordScheduledEventUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a GuildScheduledEventUpdated event. 11 | /// 12 | public sealed record DiscordScheduledEventUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordScheduledEvent Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordScheduledEventUserAddedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildScheduledEventUserAdded event. 11 | /// 12 | public sealed record DiscordScheduledEventUserAddedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ScheduledEventUserAddedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordScheduledEventUserRemovedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a GuildScheduledEventUserRemoved event. 11 | /// 12 | public sealed record DiscordScheduledEventUserRemovedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ScheduledEventUserRemovedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordStageInstanceCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Voice; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a StageInstanceCreated event. 11 | /// 12 | public sealed record DiscordStageInstanceCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordStageInstance Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordStageInstanceDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Voice; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a StageInstanceDeleted event. 11 | /// 12 | public sealed record DiscordStageInstanceDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordStageInstance Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordStageInstanceUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Voice; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a StageInstanceUpdated event. 11 | /// 12 | public sealed record DiscordStageInstanceUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordStageInstance Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a new thread is created or if the current user is added to an existing thread. 11 | /// 12 | public sealed record DiscordThreadCreatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadDeletedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a thread is deleted. 11 | /// 12 | public sealed record DiscordThreadDeletedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadListSyncEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Fired when the user gains access to a channel. 11 | /// 12 | public sealed record DiscordThreadListSyncEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ThreadListSyncPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadMemberUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels.Threads; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// ThreadMemberUpdated event. 11 | /// 12 | public sealed record DiscordThreadMemberUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordThreadMember Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadMembersUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a ThreadMembersUpdated event. 11 | /// 12 | public sealed record DiscordThreadMembersUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required ThreadMembersUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordThreadUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Fired when a thread is updated. 11 | /// 12 | public sealed record DiscordThreadUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordChannel Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordTypingStartedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | public sealed record DiscordTypingStartedEvent : IDiscordGatewayDispatchEvent 10 | { 11 | /// 12 | [JsonPropertyName("s")] 13 | public required Int32 Sequence { get; set; } 14 | 15 | /// 16 | [JsonPropertyName("t")] 17 | public required String EventName { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("d")] 21 | public required TypingStartedPayload Data { get; set; } 22 | 23 | /// 24 | [JsonPropertyName("op")] 25 | public required DiscordGatewayOpcode Opcode { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordUnknownDispatchEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents an unknown dispatch event. 11 | /// 12 | public sealed record DiscordUnknownDispatchEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required JsonElement Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordUserUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents an UserUpdated event. 11 | /// 12 | public sealed record DiscordUserUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordUser Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordVoiceServerUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a VoiceServerUpdated event. 11 | /// 12 | public sealed record DiscordVoiceServerUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required VoiceServerUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordVoiceStateUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Voice; 7 | using Starnight.Internal.Gateway.Events; 8 | 9 | /// 10 | /// Represents a VoiceStateUpdated event. 11 | /// 12 | public sealed record DiscordVoiceStateUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required DiscordVoiceState Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Inbound/Dispatch/DiscordWebhooksUpdatedEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | using Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 8 | 9 | /// 10 | /// Represents a WebhooksUpdated event. 11 | /// 12 | public sealed record DiscordWebhooksUpdatedEvent : IDiscordGatewayDispatchEvent 13 | { 14 | /// 15 | [JsonPropertyName("s")] 16 | public required Int32 Sequence { get; set; } 17 | 18 | /// 19 | [JsonPropertyName("t")] 20 | public required String EventName { get; set; } 21 | 22 | /// 23 | [JsonPropertyName("d")] 24 | public required WebhooksUpdatedPayload Data { get; set; } 25 | 26 | /// 27 | [JsonPropertyName("op")] 28 | public required DiscordGatewayOpcode Opcode { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordIdentifyCommand.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | using Starnight.Internal.Gateway.Payloads.Outbound; 7 | 8 | /// 9 | /// Serverbound, command. 10 | /// 11 | public sealed record DiscordIdentifyEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required IdentifyPayload Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public DiscordGatewayOpcode Opcode { get; set; } = DiscordGatewayOpcode.Identify; 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordOutboundHeartbeatEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Gateway.Events; 7 | 8 | /// 9 | /// Represents an outbound heartbeat event. 10 | /// 11 | public sealed record DiscordOutboundHeartbeatEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | /// The last sequence number received by the client. 15 | /// 16 | [JsonPropertyName("d")] 17 | public required Int32 Data { get; set; } 18 | 19 | /// 20 | [JsonPropertyName("op")] 21 | public required DiscordGatewayOpcode Opcode { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordRequestGuildMembersEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | using Starnight.Internal.Gateway.Payloads.Outbound; 7 | 8 | /// 9 | /// Gateway command to request guild members through the gateway. 10 | /// 11 | public sealed record DiscordRequestGuildMembersEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required RequestGuildMembersPayload Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public DiscordGatewayOpcode Opcode { get; set; } = DiscordGatewayOpcode.RequestGuildMembers; 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordResumeEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | using Starnight.Internal.Gateway.Payloads.Outbound; 7 | 8 | /// 9 | /// Serverbound, command. 10 | /// 11 | public sealed record DiscordResumeEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required ResumePayload Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public DiscordGatewayOpcode Opcode { get; set; } = DiscordGatewayOpcode.Resume; 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordUpdatePresenceEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Entities.Users; 6 | using Starnight.Internal.Gateway.Events; 7 | 8 | /// 9 | /// Represents an Update Presence gateway command 10 | /// 11 | public sealed record DiscordUpdatePresenceEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required DiscordPresence Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public DiscordGatewayOpcode Opcode { get; set; } = DiscordGatewayOpcode.PresenceUpdate; 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Events/Outbound/DiscordUpdateVoiceStateEvent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Events.Outbound; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | using Starnight.Internal.Gateway.Payloads.Outbound; 7 | 8 | /// 9 | /// Represents an Update Voice State gateway command. 10 | /// 11 | public sealed record DiscordUpdateVoiceStateEvent : IDiscordGatewayEvent 12 | { 13 | /// 14 | [JsonPropertyName("d")] 15 | public required UpdateVoiceStatePayload Data { get; set; } 16 | 17 | /// 18 | [JsonPropertyName("op")] 19 | public DiscordGatewayOpcode Opcode { get; set; } = DiscordGatewayOpcode.VoiceStateUpdate; 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Listeners/IListener.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Listeners; 2 | 3 | /// 4 | /// Represents a marker interface for listeners. 5 | /// 6 | public interface IListener 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Listeners/IListener`1.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Listeners; 2 | 3 | using System.Threading.Tasks; 4 | 5 | using Starnight.Internal.Gateway.Events; 6 | 7 | /// 8 | /// Represents a base interface for all listeners. 9 | /// 10 | /// The event type this listener handles. 11 | public interface IListener : IListener 12 | where TEvent : IGatewayEvent 13 | { 14 | /// 15 | /// Responds to the given gateway event. 16 | /// 17 | /// The event in question. 18 | public ValueTask ListenAsync(TEvent @event); 19 | } 20 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/GetGatewayBotResponsePayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the response payload to GET /gateway/bot. 8 | /// 9 | public sealed record GetGatewayBotResponsePayload 10 | { 11 | /// 12 | /// The WSS URL to be used for connecting to the gateway. 13 | /// 14 | [JsonPropertyName("url")] 15 | public required String Url { get; init; } 16 | 17 | /// 18 | /// The recommended number of shards to use when connecting. 19 | /// 20 | [JsonPropertyName("shards")] 21 | public required Int32 Shards { get; init; } 22 | 23 | /// 24 | /// Indicates session start limits for this bot. 25 | /// 26 | [JsonPropertyName("session_start_limit")] 27 | public required DiscordSessionStartLimit SessionStartLimit { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/AllMessageReactionsRemovedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload for an AllMessageReactionsRemoved event. 8 | /// 9 | public sealed record AllMessageReactionsRemovedPayload 10 | { 11 | /// 12 | /// The ID of the channel this occurred in. 13 | /// 14 | [JsonPropertyName("channel_id")] 15 | public required Int64 ChannelId { get; init; } 16 | 17 | /// 18 | /// The ID of the message whose reactions were cleared. 19 | /// 20 | [JsonPropertyName("message_id")] 21 | public required Int64 MessageId { get; init; } 22 | 23 | /// 24 | /// The ID of the guild this occurred in, if applicable. 25 | /// 26 | [JsonPropertyName("guild_id")] 27 | public Optional GuildId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/ChannelPinsUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to a ChannelPinsUpdated event. 8 | /// 9 | public sealed record ChannelPinsUpdatedPayload 10 | { 11 | /// 12 | /// The ID of the guild. 13 | /// 14 | [JsonPropertyName("guild_id")] 15 | public Optional GuildId { get; init; } 16 | 17 | /// 18 | /// The ID of the channel. 19 | /// 20 | [JsonPropertyName("channel_id")] 21 | public required Int64 ChannelId { get; init; } 22 | 23 | /// 24 | /// The time at which the most recent pin was pinned. 25 | /// 26 | [JsonPropertyName("last_pin_timestamp")] 27 | public Optional LastPinTimestamp { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildBanAddedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | 8 | /// 9 | /// Represents the payload of a GuildBanAdded event. 10 | /// 11 | public sealed record GuildBanAddedPayload 12 | { 13 | /// 14 | /// ID of the guild this ban was added in. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The newly banned user. 21 | /// 22 | [JsonPropertyName("user")] 23 | public required DiscordUser User { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildBanRemovedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | 8 | /// 9 | /// Represents the payload for a GuildBanRemoved event. 10 | /// 11 | public sealed record GuildBanRemovedPayload 12 | { 13 | /// 14 | /// Snowflake ID of the guild this ban was removed from. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The newly unbanned user. 21 | /// 22 | [JsonPropertyName("user")] 23 | public required DiscordUser User { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildEmojisUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | using Starnight.Internal.Entities.Guilds; 8 | 9 | /// 10 | /// Represents the payload of a GuildEmojisUpdated event. 11 | /// 12 | public sealed record GuildEmojisUpdatedPayload 13 | { 14 | /// 15 | /// Snowflake ID of the guild this is taking place in. 16 | /// 17 | [JsonPropertyName("guild_id")] 18 | public required Int64 GuildId { get; init; } 19 | 20 | /// 21 | /// The updated emojis. 22 | /// 23 | [JsonPropertyName("emojis")] 24 | public required IEnumerable Emojis { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildIntegrationsUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for the GuildIntegrationsUpdated event. 8 | /// 9 | public sealed record GuildIntegrationsUpdatedPayload 10 | { 11 | /// 12 | /// The ID of the guild whose integrations were updated. 13 | /// 14 | [JsonPropertyName("guild_id")] 15 | public required Int64 GuildId { get; init; } 16 | } 17 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildMemberRemovedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Users; 7 | 8 | /// 9 | /// Represents the payload for the GuildMemberRemoved event. 10 | /// 11 | public sealed record GuildMemberRemovedPayload 12 | { 13 | /// 14 | /// The ID of the guild this is taking place in. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The user who was removed from the guild. 21 | /// 22 | [JsonPropertyName("user")] 23 | public required DiscordUser User { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildRoleCreatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | 8 | /// 9 | /// Represents the payload for the GuildRoleCreated event. 10 | /// 11 | public sealed record GuildRoleCreatedPayload 12 | { 13 | /// 14 | /// The ID of the guild. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The newly created role. 21 | /// 22 | [JsonPropertyName("role")] 23 | public required DiscordRole Role { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildRoleDeletedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a GuildRoleDeleted event. 8 | /// 9 | public sealed record GuildRoleDeletedPayload 10 | { 11 | /// 12 | /// The ID of the guild this role was deleted in. 13 | /// 14 | [JsonPropertyName("guild_id")] 15 | public required Int64 GuildId { get; init; } 16 | 17 | /// 18 | /// The ID of the deleted role. 19 | /// 20 | [JsonPropertyName("role_id")] 21 | public required Int64 RoleId { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildRoleUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Guilds; 7 | 8 | /// 9 | /// Represents the payload for the GuildRoleUpdated event. 10 | /// 11 | public sealed record GuildRoleUpdatedPayload 12 | { 13 | /// 14 | /// The ID of the guild. 15 | /// 16 | [JsonPropertyName("guild_id")] 17 | public required Int64 GuildId { get; init; } 18 | 19 | /// 20 | /// The updated role. 21 | /// 22 | [JsonPropertyName("role")] 23 | public required DiscordRole Role { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/GuildStickersUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | using Starnight.Internal.Entities.Stickers; 8 | 9 | /// 10 | /// Represents the payload of the GuildStickersUpdated event. 11 | /// 12 | public sealed record GuildStickersUpdatedPayload 13 | { 14 | /// 15 | /// The ID of the guild this is taking place in. 16 | /// 17 | [JsonPropertyName("guild_id")] 18 | public required Int64 GuildId { get; init; } 19 | 20 | /// 21 | /// The new list of stickers for this guild. 22 | /// 23 | [JsonPropertyName("stickers")] 24 | public required IEnumerable Stickers { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/IntegrationDeletedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for an IntegrationDeleted event. 8 | /// 9 | public sealed record IntegrationDeletedPayload 10 | { 11 | /// 12 | /// The ID of the integration. 13 | /// 14 | [JsonPropertyName("id")] 15 | public required Int64 IntegrationId { get; init; } 16 | 17 | /// 18 | /// The ID of the guild this integration belongs to. 19 | /// 20 | [JsonPropertyName("guild_id")] 21 | public required Int64 GuildId { get; init; } 22 | 23 | /// 24 | /// The ID of the application for this integration. 25 | /// 26 | [JsonPropertyName("application_id")] 27 | public Optional ApplicationId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/InviteDeletedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload for an InviteDeleted event. 8 | /// 9 | public sealed record InviteDeletedPayload 10 | { 11 | /// 12 | /// The channel this invite pointed to. 13 | /// 14 | [JsonPropertyName("channel_id")] 15 | public required Int64 ChannelId { get; init; } 16 | 17 | /// 18 | /// The guild this invite pointed to. 19 | /// 20 | [JsonPropertyName("guild_id")] 21 | public Optional GuildId { get; init; } 22 | 23 | /// 24 | /// The invite code. 25 | /// 26 | [JsonPropertyName("code")] 27 | public required String Code { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/MessageDeletedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a MessageDeleted event. 8 | /// 9 | public sealed record MessageDeletedPayload 10 | { 11 | /// 12 | /// The ID of the message. 13 | /// 14 | [JsonPropertyName("id")] 15 | public required Int64 MessageId { get; init; } 16 | 17 | /// 18 | /// The ID of the channel. 19 | /// 20 | [JsonPropertyName("channel_id")] 21 | public required Int64 ChannelId { get; init; } 22 | 23 | /// 24 | /// The ID of the guild. 25 | /// 26 | [JsonPropertyName("guild_id")] 27 | public Optional GuildId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/MessagesBulkDeletedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents the payload for a MessagesBulkDeleted event. 9 | /// 10 | public sealed record MessagesBulkDeletedPayload 11 | { 12 | /// 13 | /// The IDs of the deleted messages. 14 | /// 15 | [JsonPropertyName("ids")] 16 | public required IEnumerable MessageIds { get; init; } 17 | 18 | /// 19 | /// The ID of the channel. 20 | /// 21 | [JsonPropertyName("channel_id")] 22 | public required Int64 ChannelId { get; init; } 23 | 24 | /// 25 | /// The ID of the guild. 26 | /// 27 | [JsonPropertyName("guild_id")] 28 | public Optional GuildId { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/ScheduledEventUserAddedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a GuildScheduledEventUserAdded event. 8 | /// 9 | public sealed record ScheduledEventUserAddedPayload 10 | { 11 | /// 12 | /// Snowflake ID of the scheduled event. 13 | /// 14 | [JsonPropertyName("guild_scheduled_event_id")] 15 | public required Int64 ScheduledEventId { get; init; } 16 | 17 | /// 18 | /// Snowflake ID of the user. 19 | /// 20 | [JsonPropertyName("user_id")] 21 | public required Int64 UserId { get; init; } 22 | 23 | /// 24 | /// Snowflake ID of the guild this took place in. 25 | /// 26 | [JsonPropertyName("guild_id")] 27 | public required Int64 GuildId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/ScheduledEventUserRemovedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a GuildScheduledEventUserRemoved event. 8 | /// 9 | public sealed record ScheduledEventUserRemovedPayload 10 | { 11 | /// 12 | /// Snowflake ID of the scheduled event. 13 | /// 14 | [JsonPropertyName("guild_scheduled_event_id")] 15 | public required Int64 ScheduledEventId { get; init; } 16 | 17 | /// 18 | /// Snowflake ID of the user. 19 | /// 20 | [JsonPropertyName("user_id")] 21 | public required Int64 UserId { get; init; } 22 | 23 | /// 24 | /// Snowflake ID of the guild this took place in. 25 | /// 26 | [JsonPropertyName("guild_id")] 27 | public required Int64 GuildId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/VoiceServerUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a VoiceServerUpdated event. 8 | /// 9 | public sealed record VoiceServerUpdatedPayload 10 | { 11 | /// 12 | /// Voice connection token. 13 | /// 14 | [JsonPropertyName("token")] 15 | public required String Token { get; init; } 16 | 17 | /// 18 | /// The guild this voice server updated event is for. 19 | /// 20 | [JsonPropertyName("guild_id")] 21 | public required Int64 GuildId { get; init; } 22 | 23 | /// 24 | /// The voice server host. 25 | /// 26 | [JsonPropertyName("endpoint")] 27 | public String? Endpoint { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/Dispatch/WebhooksUpdatedPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound.Dispatch; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload for a WebhooksUpdated event. 8 | /// 9 | public sealed record WebhooksUpdatedPayload 10 | { 11 | /// 12 | /// The ID of the guild this occurred in. 13 | /// 14 | [JsonPropertyName("guild_id")] 15 | public required Int64 GuildId { get; init; } 16 | 17 | /// 18 | /// The channel whose webhooks were updated. 19 | /// 20 | [JsonPropertyName("channel_id")] 21 | public required Int64 ChannelId { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Inbound/HelloPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Inbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the payload to a hello event 8 | /// 9 | public sealed record HelloPayload 10 | { 11 | /// 12 | /// The interval, in milliseconds, the client should heartbeat with. 13 | /// 14 | [JsonPropertyName("heartbeat_interval")] 15 | public required Int32 HeartbeatInterval { get; init; } 16 | } 17 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Outbound/DiscordIdentifyConnectionProperties.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Outbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents the inner connection properties object of a . 8 | /// 9 | public sealed record DiscordIdentifyConnectionProperties 10 | { 11 | /// 12 | /// The operating system the client runs on. 13 | /// 14 | [JsonPropertyName("os")] 15 | public required String OS { get; init; } 16 | 17 | /// 18 | /// The library name the client uses. 19 | /// 20 | [JsonPropertyName("browser")] 21 | public required String Browser { get; init; } 22 | 23 | /// 24 | /// Once again, the library name the client uses. 25 | /// 26 | [JsonPropertyName("device")] 27 | public required String Device { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/Payloads/Outbound/ResumePayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.Payloads.Outbound; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload for a command. 8 | /// 9 | public sealed record ResumePayload 10 | { 11 | /// 12 | /// Session token. 13 | /// 14 | [JsonPropertyName("token")] 15 | public required String Token { get; init; } 16 | 17 | /// 18 | /// Session ID. 19 | /// 20 | [JsonPropertyName("session_id")] 21 | public required String SessionId { get; init; } 22 | 23 | /// 24 | /// Last sequence number received. 25 | /// 26 | [JsonPropertyName("seq")] 27 | public required Int32 Sequence { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/State/DiscordGatewayClientState.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.State; 2 | 3 | /// 4 | /// Represents different possible states of the gateway client. 5 | /// 6 | public enum DiscordGatewayClientState 7 | { 8 | /// 9 | /// Disconnected, can connect. 10 | /// 11 | Disconnected, 12 | 13 | /// 14 | /// Connecting to Discord. 15 | /// 16 | Connecting, 17 | 18 | /// 19 | /// Identifying to the Discord gateway. 20 | /// 21 | Identifying, 22 | 23 | /// 24 | /// Connected to and able to interact with Discord. 25 | /// 26 | Connected, 27 | 28 | /// 29 | /// Disconnected, can resume. 30 | /// 31 | DisconnectedResumable, 32 | 33 | /// 34 | /// Resuming an existing session. 35 | /// 36 | Resuming, 37 | 38 | /// 39 | /// Zombied - Discord has failed to acknowledge several heartbeats. 40 | /// 41 | Zombied 42 | } 43 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Gateway/State/GatewayClientStateTracker.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Gateway.State; 2 | 3 | /// 4 | /// Tracks the state of the gateway. 5 | /// 6 | public record struct GatewayClientStateTracker 7 | { 8 | public DiscordGatewayClientState State { get; internal set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Models/Emojis/PartialEmoji.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Models.Emojis; 2 | 3 | /// 4 | /// Represents a partial emoji object. 5 | /// 6 | public record PartialEmoji 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Models/MessageComponents/AbstractComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Models.MessageComponents; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Entities; 6 | 7 | /// 8 | /// Represents any form of message component. 9 | /// 10 | [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] 11 | [JsonDerivedType(typeof(ActionRowComponent), 1)] 12 | [JsonDerivedType(typeof(ButtonComponent), 2)] 13 | [JsonDerivedType(typeof(TextSelectComponent), 3)] 14 | [JsonDerivedType(typeof(TextInputComponent), 4)] 15 | [JsonDerivedType(typeof(UserSelectComponent), 5)] 16 | [JsonDerivedType(typeof(RoleSelectComponent), 6)] 17 | [JsonDerivedType(typeof(MentionableSelectComponent), 7)] 18 | [JsonDerivedType(typeof(ChannelSelectComponent), 8)] 19 | public abstract record AbstractComponent 20 | { 21 | /// 22 | /// Contains the type of this component. 23 | /// 24 | public DiscordMessageComponentType Type { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Models/MessageComponents/AbstractInteractiveComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Models.MessageComponents; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | /// 6 | /// Represents any component that the end user can directly interact with, that is, all 7 | /// components save . 8 | /// 9 | [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] 10 | [JsonDerivedType(typeof(ButtonComponent), 2)] 11 | [JsonDerivedType(typeof(TextSelectComponent), 3)] 12 | [JsonDerivedType(typeof(TextInputComponent), 4)] 13 | [JsonDerivedType(typeof(UserSelectComponent), 5)] 14 | [JsonDerivedType(typeof(RoleSelectComponent), 6)] 15 | [JsonDerivedType(typeof(MentionableSelectComponent), 7)] 16 | [JsonDerivedType(typeof(ChannelSelectComponent), 8)] 17 | public abstract record AbstractInteractiveComponent : AbstractComponent 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Models/MessageComponents/ActionRowComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Models.MessageComponents; 2 | 3 | using System.Collections.Generic; 4 | 5 | using Starnight.Entities; 6 | 7 | /// 8 | /// Represents a container component for one or five other components, depending on their type. 9 | /// 10 | public sealed record ActionRowComponent : AbstractComponent 11 | { 12 | public ActionRowComponent() => this.Type = DiscordMessageComponentType.ActionRow; 13 | 14 | /// 15 | /// Contains the subcomponents of this action row. 16 | /// 17 | public required IReadOnlyList Components { get; init; } 18 | } 19 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Exceptions/GlobalRateLimitExceededException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Exceptions; 2 | 3 | using System; 4 | using System.Net.Http; 5 | 6 | public class GlobalRatelimitExceededException : Exception 7 | { 8 | public RatelimitBucket Bucket { get; init; } 9 | 10 | public HttpResponseMessage Response { get; init; } 11 | 12 | public GlobalRatelimitExceededException(String message, RatelimitBucket bucket, HttpResponseMessage response) : base(message) 13 | { 14 | this.Bucket = bucket; 15 | this.Response = response; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Exceptions/RateLimitExceededException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Exceptions; 2 | 3 | using System; 4 | using System.Net.Http; 5 | 6 | public class RatelimitExceededException : Exception 7 | { 8 | public RatelimitBucket Bucket { get; init; } 9 | 10 | public HttpResponseMessage Response { get; init; } 11 | 12 | public RatelimitExceededException(String message, RatelimitBucket bucket, HttpResponseMessage response) : base(message) 13 | { 14 | this.Bucket = bucket; 15 | this.Response = response; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/IRestRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Net.Http; 6 | 7 | using Polly; 8 | 9 | /// 10 | /// Represents a request contract for both kinds of rest requests (single-request and multipart request). 11 | /// 12 | public interface IRestRequest 13 | { 14 | public HttpMethod Method { get; } 15 | 16 | public String Url { get; } 17 | 18 | public Dictionary Headers { get; } 19 | 20 | public Context? Context { get; } 21 | 22 | public HttpRequestMessage Build(); 23 | } 24 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Channels/AddGroupDMRecipientRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Channels; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PUT /channel/:channel_id/recipients/:user_id. 8 | /// 9 | public sealed record AddGroupDMRecipientRequestPayload 10 | { 11 | /// 12 | /// Access token of the user, which must have granted you the gdm.join oauth scope. 13 | /// 14 | [JsonPropertyName("access_token")] 15 | public required String AccessToken { get; init; } 16 | 17 | /// 18 | /// Nickname of the user, to be given on join. 19 | /// 20 | [JsonPropertyName("nick")] 21 | public required String Nickname { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Channels/EditChannelPermissionsRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Channels; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | using Starnight.Entities; 6 | 7 | /// 8 | /// Represents a payload to PUT /channels/:channel_id/permissions/:overwrite_id. 9 | /// 10 | public sealed record EditChannelPermissionsRequestPayload 11 | { 12 | /// 13 | /// Overwrite type - either role or member. 14 | /// 15 | [JsonPropertyName("type")] 16 | public required DiscordChannelOverwriteType Type { get; init; } 17 | 18 | /// 19 | /// Granted permissions, by overwrite. 20 | /// 21 | [JsonPropertyName("allow")] 22 | public Optional Allow { get; init; } 23 | 24 | /// 25 | /// Denied permissions, by overwrite. 26 | /// 27 | [JsonPropertyName("deny")] 28 | public Optional Deny { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Channels/ModifyGroupDMRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Channels; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /channels/:channel_id, where the channel ID points to a group DM. 8 | /// 9 | public sealed record ModifyGroupDMRequestPayload 10 | { 11 | /// 12 | /// The new name for this channel. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// The new icon for this channel, as read from a png file. This cannot be base64-encoded. 19 | /// 20 | [JsonPropertyName("icon")] 21 | public Optional Icon { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Channels/StartThreadFromMessageRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Channels; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to POST /channels/:channel_id/messages/:message_id/threads 8 | /// 9 | public sealed record StartThreadFromMessageRequestPayload 10 | { 11 | /// 12 | /// 1-100 characters, channel name for this thread. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// Auto archive duration for this thread in minutes. 19 | /// 20 | [JsonPropertyName("auto_archive_duration")] 21 | public Optional AutoArchiveDuration { get; init; } 22 | 23 | /// 24 | /// Slowmode for users in seconds. 25 | /// 26 | [JsonPropertyName("rate_limit_per_user")] 27 | public Optional Slowmode { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/DiscordAttachmentFile.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.IO; 6 | 7 | /// 8 | /// Represents an attachment file stream. 9 | /// 10 | public record struct DiscordAttachmentFile 11 | { 12 | /// 13 | [SetsRequiredMembers] 14 | public DiscordAttachmentFile(Stream stream, String? filename, String? contentType) 15 | { 16 | this.FileStream = stream; 17 | this.Filename = filename ?? "file"; 18 | this.ContentType = contentType; 19 | } 20 | 21 | /// 22 | /// A stream to the file. 23 | /// 24 | public required Stream FileStream { get; set; } 25 | 26 | /// 27 | /// The file name as sent to Discord. 28 | /// 29 | public required String Filename { get; set; } 30 | 31 | /// 32 | /// Semi-optional content type for Discord. 33 | /// 34 | public String? ContentType { get; set; } 35 | } 36 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Emojis/CreateGuildEmojiRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Emojis; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents a payload to POST /guilds/:guild_id/emojis. 9 | /// 10 | public sealed record CreateGuildEmojiRequestPayload 11 | { 12 | /// 13 | /// Name of this emoji. 14 | /// 15 | [JsonPropertyName("name")] 16 | public required String Name { get; init; } 17 | 18 | /// 19 | /// Image data for this emoji. 20 | /// 21 | [JsonPropertyName("image")] 22 | public required String ImageData { get; init; } 23 | 24 | /// 25 | /// Array of snowflakes allowed to use this emoji. 26 | /// 27 | [JsonPropertyName("roles")] 28 | public Optional> Roles { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Emojis/ModifyGuildEmojiRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Emojis; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | /// 8 | /// Represents a payload to PATCH /guilds/:guild_id/emojis/:emoji_id 9 | /// 10 | public sealed record ModifyGuildEmojiRequestPayload 11 | { 12 | /// 13 | /// New name of this emoji. 14 | /// 15 | [JsonPropertyName("name")] 16 | public Optional Name { get; init; } 17 | 18 | /// 19 | /// New array of snowflakes allowed to use this emoji. 20 | /// 21 | [JsonPropertyName("roles")] 22 | public Optional?> Roles { get; init; } 23 | } 24 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/GuildTemplates/CreateGuildFromTemplateRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.GuildTemplates; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to POST /guilds/templates/:template_code 8 | /// 9 | public sealed record CreateGuildFromTemplateRequestPayload 10 | { 11 | /// 12 | /// The name of your guild. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// The 128x128 icon for this guild. 19 | /// 20 | [JsonPropertyName("icon")] 21 | public Optional Icon { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/GuildTemplates/CreateGuildTemplateRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.GuildTemplates; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to POST /guilds/:guild_id/templates 8 | /// 9 | public sealed record CreateGuildTemplateRequestPayload 10 | { 11 | /// 12 | /// The name of this template. 13 | /// 14 | [JsonPropertyName("name")] 15 | public required String Name { get; init; } 16 | 17 | /// 18 | /// Optional description for this template. 19 | /// 20 | [JsonPropertyName("description")] 21 | public Optional Description { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/GuildTemplates/ModifyGuildTemplateRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.GuildTemplates; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /guilds/:guild_id/templates/:template_code. 8 | /// 9 | public sealed record ModifyGuildTemplateRequestPayload 10 | { 11 | /// 12 | /// The name of this template. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// Optional description for this template. 19 | /// 20 | [JsonPropertyName("description")] 21 | public Optional Description { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Guilds/ListActiveThreadsResponsePayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Guilds; 2 | 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Channels; 7 | using Starnight.Internal.Entities.Channels.Threads; 8 | 9 | /// 10 | /// Represents a response payload from GET guilds/:guild_id/threads/active 11 | /// 12 | public sealed record ListActiveThreadsResponsePayload 13 | { 14 | /// 15 | /// All active threads in this guild the current user can access. 16 | /// 17 | [JsonPropertyName("threads")] 18 | public required IEnumerable Threads { get; init; } 19 | 20 | /// 21 | /// An array of thread member objects for each active thread the current user has joined. 22 | /// 23 | [JsonPropertyName("members")] 24 | public required IEnumerable MemberObjects { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Guilds/ModifyCurrentUserVoiceStateRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /guilds/:guild_id/voice-states/@me. 8 | /// 9 | public sealed record ModifyCurrentUserVoiceStateRequestPayload 10 | { 11 | /// 12 | /// Snowflake identifier of the channel this user is currently in. 13 | /// 14 | [JsonPropertyName("channel_id")] 15 | public required Int64 ChannelId { get; init; } 16 | 17 | /// 18 | /// Toggles this user's suppression state. 19 | /// 20 | [JsonPropertyName("suppress")] 21 | public Optional SuppressUser { get; init; } 22 | 23 | /// 24 | /// Sets this user's speaking request in a stage channel. 25 | /// 26 | [JsonPropertyName("request_to_speak_timestamp")] 27 | public Optional SpeakingRequestTimestamp { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Guilds/ModifyRolePositionRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /guilds/:guild_id/roles 8 | /// 9 | public sealed record ModifyRolePositionRequestPayload 10 | { 11 | /// 12 | /// Snowflake identifier of the role in question. 13 | /// 14 | [JsonPropertyName("id")] 15 | public required Int64 RoleId { get; init; } 16 | 17 | /// 18 | /// New position of the role in question. 19 | /// 20 | [JsonPropertyName("position")] 21 | public Optional Position { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Guilds/ModifyUserVoiceStateRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Guilds; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /guilds/:guild_id/voice-states/:user_id. 8 | /// 9 | public sealed record ModifyUserVoiceStateRequestPayload 10 | { 11 | /// 12 | /// Snowflake identifier of the channel this user is currently in. 13 | /// 14 | [JsonPropertyName("channel_id")] 15 | public required Int64 ChannelId { get; init; } 16 | 17 | /// 18 | /// Toggles this user's suppression state. 19 | /// 20 | [JsonPropertyName("suppress")] 21 | public Optional SuppressUser { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/StageInstances/ModifyStageInstanceRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.StageInstances; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Entities; 7 | 8 | /// 9 | /// Represents a payload to PATCH /stage-instances/:channel_id. 10 | /// 11 | public sealed record ModifyStageInstanceRequestPayload 12 | { 13 | /// 14 | /// The topic of the stage instance. 15 | /// 16 | [JsonPropertyName("topic")] 17 | public Optional Topic { get; init; } 18 | 19 | /// 20 | /// The privacy level of the stage instance. 21 | /// 22 | [JsonPropertyName("privacy_level")] 23 | public Optional PrivacyLevel { get; init; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Stickers/CreateGuildStickerRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Stickers; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents a payload to POST /guilds/:guild_id/stickers. 7 | /// 8 | public sealed record CreateGuildStickerRequestPayload 9 | { 10 | /// 11 | /// Name of this sticker. 12 | /// 13 | public required String Name { get; init; } 14 | 15 | /// 16 | /// Description of this sticker. 17 | /// 18 | public required String Description { get; init; } 19 | 20 | /// 21 | /// Autocomplete suggestion tags for this sticker. 22 | /// 23 | public required String Tags { get; init; } 24 | 25 | /// 26 | /// File contents of the sticker to upload. 27 | /// 28 | public required Memory File { get; init; } 29 | } 30 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Stickers/ListNitroStickerPacksResponsePayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Stickers; 2 | 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | using Starnight.Internal.Entities.Stickers; 7 | 8 | /// 9 | /// Represents a response payload from GET /sticker-packs. 10 | /// 11 | public sealed record ListNitroStickerPacksResponsePayload 12 | { 13 | /// 14 | /// The list of sticker packs available to nitro subscribers. 15 | /// 16 | [JsonPropertyName("sticker_packs")] 17 | public required IEnumerable Packs { get; init; } 18 | } 19 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Stickers/ModifyGuildStickerRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Stickers; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a payload to PATCH /guilds/:guild_id/stickers/:sticker_id. 8 | /// 9 | public sealed record ModifyGuildStickerRequestPayload 10 | { 11 | /// 12 | /// Name of the sticker. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// Description for the sticker. 19 | /// 20 | [JsonPropertyName("description")] 21 | public Optional Description { get; init; } 22 | 23 | /// 24 | /// Autocomplete and suggestion tags for the sticker. 25 | /// 26 | [JsonPropertyName("tags")] 27 | public Optional Tags { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Users/ModifyCurrentUserRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Users; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a request payload to PATCH /users/@me. 8 | /// 9 | public sealed record ModifyCurrentUserRequestPayload 10 | { 11 | /// 12 | /// The new username for this user. 13 | /// 14 | /// 15 | /// Changing the username may cause the user's discriminator to be randomized. 16 | /// 17 | [JsonPropertyName("username")] 18 | public Optional Username { get; init; } 19 | 20 | /// 21 | /// Image data string representing the user's avatar. 22 | /// 23 | [JsonPropertyName("avatar")] 24 | public Optional Avatar { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Webhooks/ModifyWebhookRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Webhooks; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a request payload to PATCH /webhooks/:webhook_id 8 | /// 9 | public sealed record ModifyWebhookRequestPayload 10 | { 11 | /// 12 | /// The new default name for this webhook. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// Image data for the new default webhook avatar. 19 | /// 20 | [JsonPropertyName("avatar")] 21 | public Optional Avatar { get; init; } 22 | 23 | /// 24 | /// The channel this webhook should be moved to. 25 | /// 26 | [JsonPropertyName("channel_id")] 27 | public Optional ParentChannelId { get; init; } 28 | } 29 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Payloads/Webhooks/ModifyWebhookWithTokenRequestPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Payloads.Webhooks; 2 | 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a request payload to PATCH /webhooks/:webhook_id/:webhook_token 8 | /// 9 | public sealed record ModifyWebhookWithTokenRequestPayload 10 | { 11 | /// 12 | /// The new default name for this webhook. 13 | /// 14 | [JsonPropertyName("name")] 15 | public Optional Name { get; init; } 16 | 17 | /// 18 | /// Image data for the new default webhook avatar. 19 | /// 20 | [JsonPropertyName("avatar")] 21 | public Optional Avatar { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/QueryBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | internal class QueryBuilder 8 | { 9 | private readonly List> parameters = new(); 10 | 11 | public String RootUri { get; set; } 12 | 13 | public QueryBuilder(String root) 14 | => this.RootUri = new(root); 15 | 16 | public QueryBuilder AddParameter(String key, String? value) 17 | { 18 | if(value is null) 19 | { 20 | return this; 21 | } 22 | 23 | if(value.ToLowerInvariant() == "null") 24 | { 25 | return this; 26 | } 27 | 28 | this.parameters.Add(new(key, value)); 29 | return this; 30 | } 31 | 32 | public String Build() 33 | => this.RootUri + String.Join("&", this.parameters.Select(e => Uri.EscapeDataString(e.Key) + '=' + Uri.EscapeDataString(e.Value))); 34 | } 35 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Resources/IDiscordVoiceRestResource.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Resources; 2 | 3 | using System.Collections.Generic; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | using Starnight.Internal.Entities.Voice; 8 | 9 | /// 10 | /// Represents a wrapper for all requests to discord's voice rest resource. 11 | /// 12 | public interface IDiscordVoiceRestResource 13 | { 14 | /// 15 | /// Returns an array of voice region objects. 16 | /// 17 | /// Cancellation token for this request. 18 | public ValueTask> ListVoiceRegionsAsync 19 | ( 20 | CancellationToken ct = default 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Resources/Implementation/AbstractRestResource.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Resources.Implementation; 2 | 3 | using Starnight.Caching.Providers.Abstractions; 4 | 5 | /// 6 | /// An abstract base class for all rest resources. 7 | /// 8 | public abstract class AbstractRestResource 9 | { 10 | /// 11 | /// MemoryCache holding all ratelimit buckets currently in use. 12 | /// 13 | public ICacheProvider RatelimitBucketCache { get; internal set; } 14 | 15 | /// 16 | public AbstractRestResource 17 | ( 18 | ICacheProvider ratelimitBucketCache 19 | ) 20 | => this.RatelimitBucketCache = ratelimitBucketCache; 21 | } 22 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/Resources/Implementation/RestResourceTemplate.txt: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest.Resources.Implementation; 2 | 3 | using Starnight.Caching.Providers.Abstractions; 4 | 5 | public sealed class TemplateRestResource 6 | : AbstractRestResource 7 | { 8 | private readonly RestClient restClient; 9 | 10 | public TemplateRestResource 11 | ( 12 | RestClient client, 13 | ICacheProvider cache 14 | ) 15 | : base(cache) 16 | => this.restClient = client; 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Internal/Rest/RestClientOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal.Rest; 2 | 3 | using System; 4 | 5 | /// 6 | /// Holds options for the Starnight rest client, as far as it is configurable. 7 | /// 8 | public class RestClientOptions 9 | { 10 | /// 11 | /// Median delay before a rest request is retried the first time. 12 | /// 13 | public TimeSpan MedianFirstRequestRetryDelay { get; set; } 14 | 15 | /// 16 | /// Amount of retries before a non-429 request is dropped entirely. 17 | /// 18 | public Int32 RetryCount { get; set; } 19 | 20 | /// 21 | /// Amount of retries before a 429 request is dropped entirely. 22 | /// 23 | public Int32 RatelimitedRetryCount { get; set; } 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Internal/TokenContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Internal; 2 | 3 | using System; 4 | 5 | using Microsoft.Extensions.Options; 6 | 7 | /// 8 | /// Represents a container for the bot token in use. 9 | /// 10 | public class TokenContainer : IOptions 11 | { 12 | public TokenContainer Value => this; 13 | 14 | public String Token { get; set; } = null!; 15 | } 16 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Channels/DiscordChannelFlags.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents flags added to a channel object. 5 | /// 6 | public enum DiscordChannelFlags 7 | { 8 | /// 9 | /// Indicates that this thread channel is pinned to the top of its parent forum channel. 10 | /// 11 | Pinned = 1 << 1, 12 | 13 | /// 14 | /// Indicates whether a tag is required to be specified when creating a thread. 15 | /// 16 | RequireTag = 1 << 4 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Channels/DiscordChannelOverwriteType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the two different channel overwrite types. 5 | /// 6 | public enum DiscordChannelOverwriteType 7 | { 8 | /// 9 | /// Indicates this overwrite targets a role. 10 | /// 11 | Role, 12 | 13 | /// 14 | /// Indicates this overwrite targets a member. 15 | /// 16 | Member 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Channels/DiscordDefaultThreadSortOrder.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different ways forum posts can be sorted in. 5 | /// 6 | public enum DiscordDefaultThreadSortOrder 7 | { 8 | /// 9 | /// Sort forum posts by activity. 10 | /// 11 | LatestActivity, 12 | 13 | /// 14 | /// Sort forum posts by creation date. 15 | /// 16 | CreationDate 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Channels/DiscordVideoQualityMode.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Different video quality modes for live-streams in voice channels. 5 | /// 6 | public enum DiscordVideoQualityMode 7 | { 8 | /// 9 | /// Discord chooses the quality. 10 | /// 11 | Auto = 1, 12 | 13 | /// 14 | /// 720p. 15 | /// 16 | Full 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Channels/DiscordWebhookType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different types for webhooks. 5 | /// 6 | public enum DiscordWebhookType 7 | { 8 | /// 9 | /// Represents a standard incoming webhook. 10 | /// 11 | Incoming = 1, 12 | 13 | /// 14 | /// Represents a channel following webhook. 15 | /// 16 | Follower, 17 | 18 | /// 19 | /// Represents an interaction webhook. 20 | /// 21 | Application 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordAuditLogEntryOptionalDataType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Enumerates the different types of audit log data objects. 5 | /// 6 | public enum DiscordAuditLogEntryOptionalDataType 7 | { 8 | /// 9 | /// This targets a role. 10 | /// 11 | Role, 12 | 13 | /// 14 | /// This targets a member. 15 | /// 16 | Member 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordAutoModerationActionType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different actions the auto moderation can take if a rule violation is detected. 5 | /// 6 | public enum DiscordAutoModerationActionType 7 | { 8 | /// 9 | /// Blocks the message from being sent. 10 | /// 11 | BlockMessage = 1, 12 | 13 | /// 14 | /// Logs the message to a channel specified in the action metadata. 15 | /// 16 | SendAlertMessage, 17 | 18 | /// 19 | /// Times the user out for a specified duration. 20 | /// 21 | /// 22 | /// This action type is only valid on and 23 | /// rules. 24 | /// 25 | Timeout 26 | } 27 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordAutoModerationEventType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Indicates in what context a rule should be checked 5 | /// 6 | public enum DiscordAutoModerationEventType 7 | { 8 | /// 9 | /// When a member sends or edits a message in the guild. 10 | /// 11 | MessageSend = 1 12 | } 13 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordAutoModerationKeywordPresetType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different keyword presets provided by Discord. 5 | /// 6 | public enum DiscordAutoModerationKeywordPresetType 7 | { 8 | /// 9 | /// Contains words that may be considered forms of swearing or cursing. 10 | /// 11 | Profanity = 1, 12 | 13 | /// 14 | /// Contains words that refer to sexually explicit behaviour or activity. 15 | /// 16 | SexualContent, 17 | 18 | /// 19 | /// Contains personal insult and terms that may be considered hate speech. 20 | /// 21 | Slurs 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildBoostLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different boost levels. 5 | /// 6 | public enum DiscordGuildBoostLevel 7 | { 8 | None, 9 | Tier1, 10 | Tier2, 11 | Tier3 12 | } 13 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildExplicitContentFilterLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different severity levels of the explicit content filter. 5 | /// 6 | public enum DiscordGuildExplicitContentFilterLevel 7 | { 8 | /// 9 | /// Nothing will be scanned. 10 | /// 11 | Disabled, 12 | 13 | /// 14 | /// Messages by members without roles will be scanned. 15 | /// 16 | MembersWithoutRoles, 17 | 18 | /// 19 | /// Everything will be scanned. 20 | /// 21 | AllMembers 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildIntegrationExpireBehaviour.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Holds the possible integration expiration behaviour values. 5 | /// 6 | public enum DiscordGuildIntegrationExpireBehaviour 7 | { 8 | /// 9 | /// Once the integration expires, the role(s) will be removed. 10 | /// 11 | RemoveRole, 12 | 13 | /// 14 | /// Once the integration expires, the user will be kicked. 15 | /// 16 | Kick 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildMessageNotificationsLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different possible standard notification levels. 5 | /// 6 | public enum DiscordGuildMessageNotificationsLevel 7 | { 8 | /// 9 | /// Members will receive notifications for all messages. 10 | /// 11 | AllMessages, 12 | 13 | /// 14 | /// Members will only receive notifications for messages mentioning them. 15 | /// 16 | OnlyMentions 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildMultiFactorAuthLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different levels of guild moderation Multi-Factor Auth. 5 | /// 6 | public enum DiscordGuildMultiFactorAuthLevel 7 | { 8 | /// 9 | /// No MFA requirements for moderation actions. 10 | /// 11 | None, 12 | 13 | /// 14 | /// >= 2 factor auth is required for moderation actions. 15 | /// 16 | Elevated 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildNsfwLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different possible NSFW levels. 5 | /// 6 | public enum DiscordGuildNsfwLevel 7 | { 8 | Default, 9 | Explicit, 10 | Safe, 11 | AgeRestricted 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildOnboardingPromptType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// The type of a given guild onboarding prompt. 5 | /// 6 | public enum DiscordGuildOnboardingPromptType 7 | { 8 | MultipleChoice, 9 | Dropdown 10 | } 11 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordGuildVerificationLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different possible verification levels for a guild. 5 | /// 6 | public enum DiscordGuildVerificationLevel 7 | { 8 | /// 9 | /// Unrestricted. 10 | /// 11 | None, 12 | 13 | /// 14 | /// Must have a verified email address. 15 | /// 16 | Low, 17 | 18 | /// 19 | /// Must be registered on Discord for over 5 minutes. 20 | /// 21 | Medium, 22 | 23 | /// 24 | /// Must be a member of the guild for over 10 minutes. 25 | /// 26 | High, 27 | 28 | /// 29 | /// Must have a verified phone number. 30 | /// 31 | VeryHigh 32 | } 33 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordScheduledEventPrivacyLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the privacy level of a scheduled event. 5 | /// 6 | public enum DiscordScheduledEventPrivacyLevel 7 | { 8 | /// 9 | /// This scheduled event is only accessible to guild members. 10 | /// 11 | GuildOnly = 2 12 | } 13 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordScheduledEventType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different types of scheduled events. 5 | /// 6 | public enum DiscordScheduledEventType 7 | { 8 | StageInstance = 1, 9 | Voice, 10 | External 11 | } 12 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Guilds/DiscordVoiceInviteTargetType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different targets for a voice channel invite. 5 | /// 6 | public enum DiscordVoiceInviteTargetType 7 | { 8 | Stream = 1, 9 | EmbeddedApplication 10 | } 11 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordApplicationCommandOptionType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Enumerates the different types an application command option can take. 5 | /// 6 | public enum DiscordApplicationCommandOptionType 7 | { 8 | SubCommand = 1, 9 | SubCommandGroup, 10 | String, 11 | 12 | /// 13 | /// Any integer between 2^53 and -2^53. 14 | /// 15 | Integer, 16 | Boolean, 17 | User, 18 | 19 | /// 20 | /// Includes all channel types, even categories, by default. May be restricted to specific channel types. 21 | /// 22 | Channel, 23 | Role, 24 | 25 | /// 26 | /// Includes users and roles. 27 | /// 28 | Mentionable, 29 | 30 | /// 31 | /// Any decimal number between 2^53 and -2^53. 32 | /// 33 | Decimal, 34 | Attachment 35 | } 36 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordApplicationCommandPermissionType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Enumerates the different possible targets for an application command permission object. 5 | /// 6 | public enum DiscordApplicationCommandPermissionType 7 | { 8 | Role = 1, 9 | User, 10 | Channel 11 | } 12 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordApplicationCommandType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Enumerates the different kinds of application commands. 5 | /// 6 | public enum DiscordApplicationCommandType 7 | { 8 | /// 9 | /// Slash commands, displayed up above the chat bar when typing a '/'. 10 | /// 11 | ChatInput = 1, 12 | 13 | /// 14 | /// Right-click commands on a user. 15 | /// 16 | User, 17 | 18 | /// 19 | /// Right-click commands on a message. 20 | /// 21 | Message 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordButtonStyle.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different allowed button styles. 5 | /// 6 | public enum DiscordButtonStyle 7 | { 8 | /// 9 | /// blurple 10 | /// 11 | Primary = 1, 12 | 13 | /// 14 | /// grey 15 | /// 16 | Secondary, 17 | 18 | /// 19 | /// green 20 | /// 21 | Success, 22 | 23 | /// 24 | /// red 25 | /// 26 | Danger, 27 | 28 | /// 29 | /// grey but url 30 | /// 31 | Link 32 | } 33 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordInteractionType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different interaction types. 5 | /// 6 | public enum DiscordInteractionType 7 | { 8 | Ping = 1, 9 | ApplicationCommand, 10 | MessageComponent, 11 | ApplicationCommandAutocomplete, 12 | ModalSubmitted 13 | } 14 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Interactions/DiscordTextInputStyle.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different accepted modal input styles. 5 | /// 6 | public enum DiscordTextInputStyle 7 | { 8 | /// 9 | /// A single-line input. 10 | /// 11 | Short = 1, 12 | 13 | /// 14 | /// A multi-line input. 15 | /// 16 | Paragraph 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Messages/DiscordMessageActivityType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different discord message activity types. 5 | /// 6 | /// 7 | /// Documentation for the different fields is missing: where the names are not self explanatory you are on your own. 8 | /// Feel free to PR documentation. Additionally, instead of attempting to use more sane names than discord uses, 9 | /// these names are only changed inasmuch from the discord docs as to conform with the C# naming rules. 10 | /// 11 | public enum DiscordMessageActivityType 12 | { 13 | Join = 1, 14 | Spectate, 15 | Listen, 16 | JoinRequest = 5 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Stickers/DiscordStickerFormatType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different types of sticker formats. 5 | /// 6 | public enum DiscordStickerFormatType 7 | { 8 | PNG = 1, 9 | APNG, 10 | LOTTIE 11 | } 12 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Stickers/DiscordStickerType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different types a sticker can take. 5 | /// 6 | public enum DiscordStickerType 7 | { 8 | /// 9 | /// This is a standard sticker - from a pack, nitro or a removed, formerly purchasable pack. 10 | /// 11 | Standard = 1, 12 | 13 | /// 14 | /// This is a guild sticker. 15 | /// 16 | Guild 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Teams/DiscordApplicationFlags.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | using System; 4 | 5 | /// 6 | /// Represents flags for an application. 7 | /// 8 | /// 9 | /// Documentation for the different fields is missing: where the names are not self explanatory you are on your own. 10 | /// Feel free to PR documentation. Additionally, instead of attempting to use more sane names than discord uses, 11 | /// these names are only changed inasmuch from the discord docs as to conform with the C# naming rules. 12 | /// 13 | [Flags] 14 | public enum DiscordApplicationFlags 15 | { 16 | GatewayPresence = 1 << 12, 17 | GatewayPresenceLimited = 1 << 13, 18 | GatewayGuildMembers = 1 << 14, 19 | GatewayGuildMembersLimited = 1 << 15, 20 | VerificationPendingGuildLimit = 1 << 16, 21 | Embedded = 1 << 17, 22 | GatewayMessageContent = 1 << 18, 23 | GatewayMessageContentLimited = 1 << 19 24 | } 25 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Teams/DiscordTeamMembershipState.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different membership states for each team member. 5 | /// 6 | public enum DiscordTeamMembershipState 7 | { 8 | /// 9 | /// Invited, pending acceptance. 10 | /// 11 | Invited = 1, 12 | 13 | /// 14 | /// Accepted. 15 | /// 16 | Accepted 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Users/DiscordActivityFlags.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | using System; 4 | 5 | /// 6 | /// Flags holding activity data. 7 | /// 8 | [Flags] 9 | public enum DiscordActivityFlags 10 | { 11 | Instance = 1 << 0, 12 | Join = 1 << 1, 13 | Spectate = 1 << 2, 14 | JoinRequest = 1 << 3, 15 | Sync = 1 << 4, 16 | Play = 1 << 5, 17 | PartyPrivacyFriends = 1 << 6, 18 | PartyPrivacyVoiceChannel = 1 << 7, 19 | Embedded = 1 << 8 20 | } 21 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Users/DiscordActivityType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Represents the different activity types. 5 | /// 6 | public enum DiscordActivityType 7 | { 8 | Game, 9 | Streaming, 10 | Listening, 11 | Watching, 12 | Custom, 13 | Competing 14 | } 15 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Users/DiscordPremiumType.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Enum holding the three possible Nitro subscription types 5 | /// 6 | public enum DiscordPremiumType 7 | { 8 | /// 9 | /// No nitro subscription. 10 | /// 11 | None, 12 | 13 | /// 14 | /// Nitro Classic subscription. 15 | /// 16 | Classic, 17 | 18 | /// 19 | /// Full Nitro subscription. 20 | /// 21 | Nitro, 22 | 23 | /// 24 | /// Nitro Basic subscription. 25 | /// 26 | Basic 27 | } 28 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Users/DiscordUserConnectionVisibility.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Holds the visibility status of Discord User connections. 5 | /// 6 | public enum DiscordUserConnectionVisibility 7 | { 8 | /// 9 | /// Invisible to everyone save the applicable user themselves. 10 | /// 11 | None, 12 | 13 | /// 14 | /// Visible to everyone. 15 | /// 16 | Everyone 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Entities/_Voice/DiscordStagePrivacyLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | /// 3 | /// Represents the different stage privacy levels. 4 | /// 5 | public enum DiscordStagePrivacyLevel 6 | { 7 | /// 8 | /// This stage is visible exclusively to guild members. 9 | /// 10 | GuildOnly = 2 11 | } 12 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Exceptions/AbstractStarnightException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | 5 | /// 6 | /// A base class for all Starnight-thrown exceptions. 7 | /// 8 | public abstract class AbstractStarnightException : Exception 9 | { 10 | /// 11 | /// Fully qualified name of the calling method. 12 | /// 13 | public String Caller { get; private set; } 14 | 15 | /// 16 | public AbstractStarnightException(String message, String caller) : base(message) 17 | => this.Caller = caller; 18 | } 19 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Exceptions/StarnightInvalidConnectionException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Runtime.CompilerServices; 6 | 7 | /// 8 | /// Thrown if any connection information was invalid. 9 | /// 10 | public class StarnightInvalidConnectionException : AbstractStarnightException 11 | { 12 | [SetsRequiredMembers] 13 | public StarnightInvalidConnectionException 14 | ( 15 | String message, 16 | 17 | [CallerMemberName] 18 | String caller = "" 19 | ) 20 | : base(message, caller) 21 | { } 22 | } 23 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Exceptions/StarnightSharedRatelimitHitException.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Exceptions; 2 | 3 | using System; 4 | 5 | /// 6 | /// Thrown if a request hits the resource shared ratelimit. 7 | /// 8 | public class StarnightSharedRatelimitHitException : AbstractStarnightException 9 | { 10 | public StarnightSharedRatelimitHitException(String message, String caller) 11 | : base(message, caller) 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Starnight.Shared/Starnight.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shared type library for Starnight assemblies 5 | 0.1.0 6 | Starnight 7 | disable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Starnight.Shared/readme.md: -------------------------------------------------------------------------------- 1 | # The Starnight Shared Type Library 2 | 3 | This contains types used by Starnight.Internal that need to be exposed in Starnight. 4 | 5 | This needs to exist because type-forwards don't actually expose the type if the dependency is included as a private asset. Don't include 6 | this directly, ever. 7 | -------------------------------------------------------------------------------- /src/Starnight/Entities/IStarnightEntity.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Entities; 2 | 3 | /// 4 | /// Marker interface for internal handling. 5 | /// 6 | public interface IStarnightEntity 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/Starnight/Infrastructure/TransformationServices/DisableCollectionTransformationAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Infrastructure.TransformationServices; 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 7 | internal class DisableCollectionTransformationAttribute : Attribute 8 | { 9 | public required String CollectionName { get; init; } 10 | 11 | [SetsRequiredMembers] 12 | public DisableCollectionTransformationAttribute 13 | ( 14 | String collectionName 15 | ) 16 | => this.CollectionName = collectionName; 17 | } 18 | -------------------------------------------------------------------------------- /src/Starnight/Infrastructure/TransformationServices/GenerateInterfaceImplementationAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Infrastructure.TransformationServices; 2 | 3 | using System; 4 | 5 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 6 | internal class GenerateInterfaceImplementationAttribute : Attribute 7 | { 8 | public Boolean GenerateInterfaceImplementation { get; set; } 9 | 10 | public GenerateInterfaceImplementationAttribute 11 | ( 12 | Boolean generateImplementation 13 | ) 14 | => this.GenerateInterfaceImplementation = generateImplementation; 15 | } 16 | -------------------------------------------------------------------------------- /src/Starnight/Infrastructure/TransformationServices/RenameTransformedPropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Infrastructure.TransformationServices; 2 | 3 | using System; 4 | 5 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 6 | internal class RenameTransformedPropertyAttribute : Attribute 7 | { 8 | public required String InternalName { get; init; } 9 | 10 | public required String WrapperName { get; init; } 11 | 12 | public RenameTransformedPropertyAttribute 13 | ( 14 | String internalName, 15 | String wrapperName 16 | ) 17 | { 18 | this.InternalName = internalName; 19 | this.WrapperName = wrapperName; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Starnight/StarnightClient.Miscellaneous.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight; 2 | 3 | using Starnight.Infrastructure.TransformationServices; 4 | 5 | // here, we hold all those members that are too disconnected from anything else to be 6 | // realistically grouped into logical units. 7 | public partial class StarnightClient 8 | { 9 | /// 10 | /// Gets the configured collection transformer for this client. 11 | /// 12 | internal ICollectionTransformerService CollectionTransformer { get; } 13 | } 14 | -------------------------------------------------------------------------------- /test/Starnight.TestBot/Starnight.TestBot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/Starnight.TestBot/TestListener.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.TestBot; 2 | 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | using Starnight.Internal.Gateway.Events.Inbound; 7 | using Starnight.Internal.Gateway.Events.Inbound.Dispatch; 8 | using Starnight.Internal.Gateway.Listeners; 9 | 10 | internal class TestListener : IListener, IListener 11 | { 12 | public ValueTask ListenAsync(DiscordConnectedEvent @event) 13 | { 14 | Console.WriteLine("received!"); 15 | 16 | return ValueTask.CompletedTask; 17 | } 18 | 19 | public ValueTask ListenAsync(DiscordGuildCreatedEvent @event) 20 | { 21 | Console.WriteLine("received a guild!!1!"); 22 | 23 | return ValueTask.CompletedTask; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tools/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | enable 5 | Preview 6 | False 7 | Starnight Contributors 8 | Starnight Contributors 9 | CS1591 10 | True 11 | True 12 | True 13 | 14 | 15 | -------------------------------------------------------------------------------- /tools/generators/Starnight.Generators.GenerateInternalEvents/GeneratorMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Generators.GenerateInternalEvents; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | internal sealed record GeneratorMetadata 7 | { 8 | public required List Metadata { get; init; } 9 | 10 | public required List Namespaces { get; init; } 11 | } 12 | -------------------------------------------------------------------------------- /tools/generators/Starnight.Generators.GenerateInternalEvents/GeneratorMetadataEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Starnight.Generators.GenerateInternalEvents; 2 | 3 | using System; 4 | 5 | internal readonly record struct GeneratorMetadataEntry 6 | { 7 | public readonly String Event { get; init; } 8 | 9 | public readonly String EventName { get; init; } 10 | 11 | // payload, without namespace name 12 | public readonly String Payload { get; init; } 13 | } 14 | -------------------------------------------------------------------------------- /tools/generators/Starnight.Generators.GenerateInternalEvents/Starnight.Generators.GenerateInternalEvents.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------