Skip to content

Commit

Permalink
Merge branch 'dev' into feat/partial-list
Browse files Browse the repository at this point in the history
  • Loading branch information
abitofevrything authored Sep 23, 2024
2 parents 840a0cd + 2d9b97a commit 9e9c909
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/nyxx_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ export 'src/extensions/scheduled_event.dart';
export 'src/extensions/snowflake_entity.dart';
export 'src/extensions/user.dart';
export 'src/extensions/list.dart';
export 'src/extensions/application.dart';
23 changes: 23 additions & 0 deletions lib/src/extensions/application.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:nyxx/nyxx.dart';

/// Extensions on [PartialApplication]s.
extension ApplicationExtensions on PartialApplication {
/// Get a URL users can visit to add this bot to a guild.
Uri getInviteUri({
List<String> scopes = const ['bot', 'application.commands'],
Flags<Permissions>? permissions,
Snowflake? guildId,
bool? disableGuildSelect,
}) =>
Uri.https(
'discord.com',
'/oauth2/authorize',
{
'client_id': id.toString(),
'scope': scopes.join(' '),
if (permissions != null) 'permissions': permissions.value.toString(),
if (guildId != null) 'guild_id': guildId.toString(),
if (disableGuildSelect != null) 'disable_guild_select': disableGuildSelect,
},
);
}

0 comments on commit 9e9c909

Please sign in to comment.