Skip to content

Commit

Permalink
Merge pull request #714 from nyxx-discord/main
Browse files Browse the repository at this point in the history
Merge back main into next
  • Loading branch information
l7ssha authored Oct 10, 2024
2 parents 18bca4a + bcba971 commit a11bc80
Show file tree
Hide file tree
Showing 180 changed files with 6,598 additions and 2,163 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ Please delete options that are not relevant.
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have checked my changes haven't lowered code coverage
485 changes: 310 additions & 175 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

A complete, robust and efficient wrapper around Discord's API for bots & applications.

To get started using nyxx, follow our [getting started guide](https://nyxx.l7ssha.xyz/docs/guides/writing_your_first_bot) to write your first bot.
To get started using nyxx, follow our [getting started guide](https://nyxx.l7ssha.xyz/docs/tutorials/writing_your_first_bot) to write your first bot.

If you're already familiar with Discord's API, here's a quick example to get you started:
```dart
Expand All @@ -31,9 +31,8 @@ void main() async {
## Other nyxx packages

- [nyxx_commands](https://pub.dev/packages/nyxx_commands): A command framework for handling both simple & complex commands.
- [nyxx_pagination](https://pub.dev/packages/nyxx_pagination): Pagination support for nyxx.
- [nyxx_extensions](https://pub.dev/packages/nyxx_extensions): Pagination, emoji utilities and other miscellaneous helpers for developing bots using nyxx.
- [nyxx_lavalink](https://pub.dev/packages/nyxx_lavalink): Lavalink support for playing audio in voice channels.
- [nyxx_extensions](https://pub.dev/packages/nyxx_extensions): Miscellaneous helpers for common situations when developing bots.

## More examples

Expand Down
4 changes: 4 additions & 0 deletions dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dartdoc:
linkToSource:
root: .
uriTemplate: 'https://github.com/nyxx-discord/nyxx/blob/main/%f%#L%l%'
2 changes: 1 addition & 1 deletion example/simple_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() async {
// we received.
await event.message.channel.sendMessage(MessageBuilder(
content: 'Pong!',
replyId: event.message.id,
referencedMessage: MessageReferenceBuilder.reply(messageId: event.message.id),
));
}
});
Expand Down
99 changes: 76 additions & 23 deletions lib/nyxx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ export 'src/errors.dart'
OutOfRemainingSessionsError,
IntegrationNotFoundException,
AlreadyAcknowledgedError,
AlreadyRespondedError;
AlreadyRespondedError,
PluginError,
ClientClosedError,
SkuNotFoundException;

export 'src/builders/builder.dart' show Builder, CreateBuilder, UpdateBuilder;
export 'src/builders/image.dart' show ImageBuilder;
export 'src/builders/user.dart' show UserUpdateBuilder;
export 'src/builders/permission_overwrite.dart' show PermissionOverwriteBuilder;
export 'src/builders/channel/channel_position.dart' show ChannelPositionBuilder;
export 'src/builders/channel/forum_tag.dart' show ForumTagBuilder;
export 'src/builders/channel/group_dm.dart' show GroupDmUpdateBuilder;
export 'src/builders/channel/group_dm.dart' show GroupDmUpdateBuilder, DmRecipientBuilder;
export 'src/builders/channel/guild_channel.dart'
show
ForumChannelUpdateBuilder,
Expand All @@ -43,32 +46,35 @@ export 'src/builders/channel/thread.dart' show ThreadUpdateBuilder, ForumThreadB
export 'src/builders/message/allowed_mentions.dart' show AllowedMentions;
export 'src/builders/message/attachment.dart' show AttachmentBuilder;
export 'src/builders/message/embed.dart' show EmbedBuilder, EmbedAuthorBuilder, EmbedFieldBuilder, EmbedFooterBuilder, EmbedImageBuilder, EmbedThumbnailBuilder;
export 'src/builders/message/message.dart' show MessageBuilder, MessageUpdateBuilder;
export 'src/builders/message/message.dart' show MessageBuilder, MessageUpdateBuilder, MessageReferenceBuilder;
export 'src/builders/message/component.dart'
show ActionRowBuilder, ButtonBuilder, MessageComponentBuilder, SelectMenuBuilder, SelectMenuOptionBuilder, TextInputBuilder;
show ActionRowBuilder, ButtonBuilder, MessageComponentBuilder, SelectMenuBuilder, SelectMenuOptionBuilder, TextInputBuilder, DefaultValue;
export 'src/builders/message/poll.dart' show PollAnswerBuilder, PollBuilder, PollMediaBuilder;
export 'src/builders/webhook.dart' show WebhookBuilder, WebhookUpdateBuilder;
export 'src/builders/guild/guild.dart' show GuildBuilder, GuildUpdateBuilder;
export 'src/builders/guild/member.dart' show CurrentMemberUpdateBuilder, MemberBuilder, MemberUpdateBuilder;
export 'src/builders/guild/welcome_screen.dart' show WelcomeScreenUpdateBuilder;
export 'src/builders/guild/widget.dart' show WidgetSettingsUpdateBuilder;
export 'src/builders/guild/scheduled_event.dart' show ScheduledEventBuilder, ScheduledEventUpdateBuilder;
export 'src/builders/guild/scheduled_event.dart' show ScheduledEventBuilder, ScheduledEventUpdateBuilder, RecurrenceRuleBuilder;
export 'src/builders/guild/template.dart' show GuildTemplateBuilder, GuildTemplateUpdateBuilder;
export 'src/builders/guild/auto_moderation.dart' show AutoModerationRuleBuilder, AutoModerationRuleUpdateBuilder;
export 'src/builders/guild/auto_moderation.dart'
show AutoModerationRuleBuilder, AutoModerationRuleUpdateBuilder, ActionMetadataBuilder, AutoModerationActionBuilder, TriggerMetadataBuilder;
export 'src/builders/guild/onboarding.dart' show OnboardingPromptBuilder, OnboardingPromptOptionBuilder, OnboardingUpdateBuilder;
export 'src/builders/role.dart' show RoleBuilder, RoleUpdateBuilder;
export 'src/builders/voice.dart' show CurrentUserVoiceStateUpdateBuilder, VoiceStateUpdateBuilder, GatewayVoiceStateBuilder;
export 'src/builders/presence.dart' show PresenceBuilder, CurrentUserStatus, ActivityBuilder;
export 'src/builders/application_role_connection.dart' show ApplicationRoleConnectionUpdateBuilder;
export 'src/builders/emoji/emoji.dart' show EmojiBuilder, EmojiUpdateBuilder;
export 'src/builders/emoji/emoji.dart' show EmojiBuilder, EmojiUpdateBuilder, ApplicationEmojiBuilder, ApplicationEmojiUpdateBuilder;
export 'src/builders/emoji/reaction.dart' show ReactionBuilder;
export 'src/builders/invite.dart' show InviteBuilder;
export 'src/builders/sticker.dart' show StickerBuilder, StickerUpdateBuilder;
export 'src/builders/application_command.dart'
show ApplicationCommandBuilder, ApplicationCommandUpdateBuilder, CommandOptionBuilder, CommandOptionChoiceBuilder;
export 'src/builders/interaction_response.dart' show InteractionResponseBuilder, ModalBuilder, InteractionCallbackType;
export 'src/builders/entitlement.dart' show TestEntitlementBuilder, TestEntitlementType;
export 'src/builders/application.dart' show ApplicationUpdateBuilder;
export 'src/builders/application.dart' show ApplicationUpdateBuilder, ApplicationIntegrationTypeConfigurationBuilder;

export 'src/cache/cache.dart' show Cache, CacheConfig;
export 'src/cache/cache.dart' show Cache, CacheConfig, CacheManager;

export 'src/http/bucket.dart' show HttpBucket;
export 'src/http/handler.dart' show HttpHandler, Oauth2HttpHandler, RateLimitInfo;
Expand All @@ -92,15 +98,20 @@ export 'src/http/managers/gateway_manager.dart' show GatewayManager;
export 'src/http/managers/scheduled_event_manager.dart' show ScheduledEventManager;
export 'src/http/managers/auto_moderation_manager.dart' show AutoModerationManager;
export 'src/http/managers/integration_manager.dart' show IntegrationManager;
export 'src/http/managers/emoji_manager.dart' show EmojiManager;
export 'src/http/managers/emoji_manager.dart' show EmojiManager, ApplicationEmojiManager, GuildEmojiManager;
export 'src/http/managers/audit_log_manager.dart' show AuditLogManager;
export 'src/http/managers/sticker_manager.dart' show GuildStickerManager, GlobalStickerManager;
export 'src/http/managers/application_command_manager.dart' show ApplicationCommandManager, GlobalApplicationCommandManager, GuildApplicationCommandManager;
export 'src/http/managers/interaction_manager.dart' show InteractionManager;
export 'src/http/managers/entitlement_manager.dart' show EntitlementManager;
export 'src/http/managers/sku_manager.dart' show SkuManager;
export 'src/http/managers/subscription_manager.dart' show SubscriptionManager;

export 'src/gateway/gateway.dart' show Gateway;
export 'src/gateway/message.dart' show Disconnecting, Dispose, ErrorReceived, EventReceived, GatewayMessage, Send, ShardData, ShardMessage;
export 'src/gateway/event_parser.dart' show EventParser;
export 'src/gateway/shard_runner.dart' show ShardRunner, ShardConnection;
export 'src/gateway/message.dart'
show Disconnecting, Dispose, ErrorReceived, EventReceived, GatewayMessage, Send, Sent, ShardData, ShardMessage, Identify, RequestingIdentify, StartShard;
export 'src/gateway/shard.dart' show Shard;

export 'src/models/discord_color.dart' show DiscordColor;
Expand Down Expand Up @@ -139,10 +150,22 @@ export 'src/models/message/activity.dart' show MessageActivity, MessageActivityT
export 'src/models/message/attachment.dart' show Attachment, AttachmentFlags;
export 'src/models/message/author.dart' show MessageAuthor;
export 'src/models/message/channel_mention.dart' show ChannelMention;
export 'src/models/message/embed.dart' show Embed, EmbedAuthor, EmbedField, EmbedFooter, EmbedImage, EmbedProvider, EmbedThumbnail, EmbedVideo;
export 'src/models/message/message.dart' show Message, MessageFlags, PartialMessage, MessageType, MessageInteraction;
export 'src/models/message/embed.dart' show Embed, EmbedAuthor, EmbedField, EmbedFooter, EmbedImage, EmbedProvider, EmbedThumbnail, EmbedVideo, EmbedType;

export 'src/models/message/message.dart'
show
Message,
MessageFlags,
PartialMessage,
MessageType,
// ignore: deprecated_member_use_from_same_package
MessageInteraction,
MessageInteractionMetadata,
MessageSnapshot,
MessageCall;
export 'src/models/message/poll.dart' show Poll, PollAnswer, PollAnswerCount, PollMedia, PollResults, PollLayoutType;
export 'src/models/message/reaction.dart' show Reaction, ReactionCountDetails;
export 'src/models/message/reference.dart' show MessageReference;
export 'src/models/message/reference.dart' show MessageReference, MessageReferenceType;
export 'src/models/message/role_subscription_data.dart' show RoleSubscriptionData;
export 'src/models/message/component.dart'
show
Expand All @@ -151,14 +174,16 @@ export 'src/models/message/component.dart'
MessageComponent,
SelectMenuComponent,
SelectMenuOption,
SelectMenuDefaultValue,
SelectMenuDefaultValueType,
TextInputComponent,
ButtonStyle,
MessageComponentType,
TextInputStyle;
export 'src/models/invite/invite.dart' show Invite, TargetType;
export 'src/models/invite/invite.dart' show Invite, TargetType, InviteType;
export 'src/models/invite/invite_metadata.dart' show InviteWithMetadata;
export 'src/models/webhook.dart' show PartialWebhook, Webhook, WebhookType, WebhookAuthor;
export 'src/models/guild/ban.dart' show Ban;
export 'src/models/guild/ban.dart' show Ban, BulkBanResponse;
export 'src/models/guild/guild_preview.dart' show GuildPreview;
export 'src/models/guild/guild_widget.dart' show GuildWidget, WidgetSettings, WidgetImageStyle;
export 'src/models/guild/guild.dart'
Expand All @@ -172,15 +197,36 @@ export 'src/models/guild/guild.dart'
MfaLevel,
NsfwLevel,
PremiumTier,
VerificationLevel;
VerificationLevel,
UserGuild;
export 'src/models/guild/integration.dart' show PartialIntegration, Integration, IntegrationAccount, IntegrationApplication, IntegrationExpireBehavior;
export 'src/models/guild/member.dart' show Member, MemberFlags, PartialMember;
export 'src/models/guild/onboarding.dart' show Onboarding, OnboardingPrompt, OnboardingPromptOption, OnboardingPromptType;
export 'src/models/guild/onboarding.dart' show Onboarding, OnboardingPrompt, OnboardingPromptOption, OnboardingPromptType, OnboardingMode;
export 'src/models/guild/welcome_screen.dart' show WelcomeScreen, WelcomeScreenChannel;
export 'src/models/guild/scheduled_event.dart' show EntityMetadata, PartialScheduledEvent, ScheduledEvent, ScheduledEventUser, EventStatus, ScheduledEntityType;
export 'src/models/guild/scheduled_event.dart'
show
EntityMetadata,
PartialScheduledEvent,
ScheduledEvent,
ScheduledEventUser,
EventStatus,
ScheduledEntityType,
RecurrenceRule,
RecurrenceRuleFrequency,
RecurrenceRuleMonth,
RecurrenceRuleNWeekday,
RecurrenceRuleWeekday;
export 'src/models/guild/audit_log.dart' show AuditLogChange, AuditLogEntry, AuditLogEntryInfo, PartialAuditLogEntry, AuditLogEvent;
export 'src/models/application.dart'
show Application, ApplicationFlags, InstallationParameters, PartialApplication, ApplicationRoleConnectionMetadata, ConnectionMetadataType;
show
Application,
ApplicationFlags,
InstallationParameters,
PartialApplication,
ApplicationRoleConnectionMetadata,
ConnectionMetadataType,
ApplicationIntegrationType,
ApplicationIntegrationTypeConfiguration;
export 'src/models/guild/template.dart' show GuildTemplate;
export 'src/models/guild/auto_moderation.dart'
show
Expand Down Expand Up @@ -260,7 +306,9 @@ export 'src/models/gateway/events/message.dart'
MessageReactionRemoveAllEvent,
MessageReactionRemoveEmojiEvent,
MessageReactionRemoveEvent,
MessageUpdateEvent;
MessageUpdateEvent,
MessagePollVoteAddEvent,
MessagePollVoteRemoveEvent;
export 'src/models/gateway/events/presence.dart' show PresenceUpdateEvent, TypingStartEvent, UserUpdateEvent;
export 'src/models/gateway/events/ready.dart' show ReadyEvent, ResumedEvent;
export 'src/models/gateway/events/stage_instance.dart' show StageInstanceCreateEvent, StageInstanceDeleteEvent, StageInstanceUpdateEvent;
Expand Down Expand Up @@ -293,11 +341,15 @@ export 'src/models/interaction.dart'
ApplicationCommandInteraction,
MessageComponentInteraction,
ModalSubmitInteraction,
PingInteraction;
PingInteraction,
InteractionContextType;
export 'src/models/entitlement.dart' show Entitlement, PartialEntitlement, EntitlementType;
export 'src/models/sku.dart' show Sku, SkuType;
export 'src/models/sku.dart' show Sku, SkuType, SkuFlags, PartialSku;
export 'src/models/oauth2.dart' show OAuth2Information;
export 'src/models/subscription.dart' show PartialSubscription, Subscription, SubscriptionStatus;

export 'src/utils/flags.dart' show Flag, Flags;
export 'src/utils/enum_like.dart' show EnumLike;
export 'src/intents.dart' show GatewayIntents;

export 'src/plugin/plugin.dart' show NyxxPlugin, NyxxPluginState;
Expand All @@ -316,3 +368,4 @@ export 'package:http/http.dart'
StreamedResponse;
export 'package:logging/logging.dart' show Logger, Level;
export 'package:runtime_type/runtime_type.dart' show RuntimeType;
export 'package:oauth2/oauth2.dart' show Credentials;
4 changes: 2 additions & 2 deletions lib/src/api_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:oauth2/oauth2.dart';
/// Options for connecting to the Discord API.
abstract class ApiOptions {
/// The version of nyxx used in [defaultUserAgent].
static const nyxxVersion = '6.0.0';
static const nyxxVersion = '6.4.3';

/// The URL to the nyxx repository used in [defaultUserAgent].
static const nyxxRepositoryUrl = 'https://github.com/nyxx-discord/nyxx';

/// The default value for the `User-Agent` header for bots made with nyxx.
static const defaultUserAgent = 'Nyxx ($nyxxRepositoryUrl, $nyxxVersion)';
static const defaultUserAgent = 'DiscordBot ($nyxxRepositoryUrl, $nyxxVersion)';

/// The host at which the API can be found.
///
Expand Down
32 changes: 28 additions & 4 deletions lib/src/builders/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ import 'package:nyxx/src/builders/sentinels.dart';
import 'package:nyxx/src/models/application.dart';
import 'package:nyxx/src/utils/flags.dart';

class ApplicationIntegrationTypeConfigurationBuilder extends CreateBuilder<ApplicationIntegrationTypeConfiguration> {
/// Install params for each installation context's default in-app authorization link.
final InstallationParameters? oauth2InstallParameters;

ApplicationIntegrationTypeConfigurationBuilder({this.oauth2InstallParameters});

@override
Map<String, Object?> build() => {
if (oauth2InstallParameters != null)
'oauth2_install_params': {
'scopes': oauth2InstallParameters!.scopes,
'permissions': oauth2InstallParameters!.permissions.value.toString(),
},
};
}

class ApplicationUpdateBuilder extends UpdateBuilder<Application> {
Uri? customInstallUrl;

Expand All @@ -23,31 +39,39 @@ class ApplicationUpdateBuilder extends UpdateBuilder<Application> {

List<String>? tags;

Map<ApplicationIntegrationType, ApplicationIntegrationTypeConfigurationBuilder>? integrationTypesConfig;

ApplicationUpdateBuilder({
this.customInstallUrl,
this.description,
this.roleConnectionsVerificationUrl,
this.roleConnectionsVerificationUrl = sentinelUri,
this.installationParameters,
this.flags,
this.icon = sentinelImageBuilder,
this.coverImage = sentinelImageBuilder,
this.interactionsEndpointUrl,
this.interactionsEndpointUrl = sentinelUri,
this.tags,
this.integrationTypesConfig,
});

@override
Map<String, Object?> build() => {
if (customInstallUrl != null) 'custom_install_url': customInstallUrl!.toString(),
if (description != null) 'description': description,
if (roleConnectionsVerificationUrl != null) 'role_connections_verification_url': roleConnectionsVerificationUrl!.toString(),
if (!identical(roleConnectionsVerificationUrl, sentinelUri)) 'role_connections_verification_url': roleConnectionsVerificationUrl?.toString(),
if (installationParameters != null)
'install_params': {
'scopes': installationParameters!.scopes,
'permissions': installationParameters!.permissions.toString(),
'permissions': installationParameters!.permissions.value.toString(),
},
if (integrationTypesConfig != null)
'integration_types_config': {
for (final MapEntry(:key, :value) in integrationTypesConfig!.entries) key.value.toString(): value.build(),
},
if (flags != null) 'flags': flags!.value,
if (!identical(icon, sentinelImageBuilder)) 'icon': icon?.buildDataString(),
if (!identical(coverImage, sentinelImageBuilder)) 'cover_image': coverImage?.buildDataString(),
if (!identical(interactionsEndpointUrl, sentinelUri)) 'interactions_endpoint_url': interactionsEndpointUrl?.toString(),
if (tags != null) 'tags': tags,
};
}
Loading

0 comments on commit a11bc80

Please sign in to comment.