@@ -4,26 +4,88 @@ import 'discord_team.dart';
4
4
import 'discord_user.dart' ;
5
5
6
6
class DiscordApplication {
7
+ /// the id of the app
7
8
final DiscordSnowflake id;
8
9
10
+ /// the name of the app
9
11
final String name;
12
+
13
+ /// the [icon hash] (https://discord.com/developers/docs/reference#image-formatting) of the app
14
+ ///
15
+ /// is always returned, but can be null
10
16
final String ? icon;
17
+
18
+ /// the description of the app
11
19
final String description;
12
20
21
+ /// an array of rpc origin urls, if rpc is enabled
22
+ ///
23
+ /// is not always returned, hence the nullable property
13
24
final List <String >? rpcOrigins;
25
+
26
+ /// when false only app owner can join the app's bot to guilds
14
27
final bool botPublic;
28
+
29
+ /// when true the app's bot will only join upon completion of the full oauth2
30
+ /// code grant flow
15
31
final bool botRequireCodeGrant;
32
+
33
+ /// the url of the app's terms of service
34
+ ///
35
+ /// is not always returned, hence the nullable property
16
36
final String ? termsOfServiceUrl;
37
+
38
+ /// the url of the app's privacy policy
39
+ ///
40
+ /// is not always returned, hence the nullable property
17
41
final String ? privacyPolicyUrl;
42
+
43
+ /// partial user object containing info on the owner of the application
44
+ ///
45
+ /// is not always returned, hence the nullable property
18
46
final DiscordUser ? owner;
47
+
48
+ /// if this application is a game sold on Discord,
49
+ /// this field will be the summary field for the store page of its primary sku
19
50
final String summary;
51
+
52
+ /// the hex encoded key for verification in interactions and the
53
+ /// GameSDK's [GetTicket] (https://discord.com/developers/docs/game-sdk/applications#getticket)
20
54
final String verifyKey;
55
+
56
+ /// if the application belongs to a team, this will be a list of the members of that team
57
+ ///
58
+ /// is always returned, but can be null
21
59
final DiscordTeam ? team;
60
+
61
+ /// if this application is a game sold on Discord, this field
62
+ /// will be the guild to which it has been linked
63
+ ///
64
+ /// is not always returned, hence the nullable property
22
65
final DiscordSnowflake ? guildId;
66
+
67
+ /// if this application is a game sold on Discord, this field
68
+ /// will be the id of the "Game SKU" that is created, if exists
69
+ ///
70
+ /// is not always returned, hence the nullable property
23
71
final DiscordSnowflake ? primarySkuId;
72
+
73
+ /// if this application is a game sold on Discord, this field
74
+ /// will be the URL slug that links to the store page
75
+ ///
76
+ /// is not always returned, hence the nullable property
24
77
final String ? slug;
78
+
79
+ /// the application's default rich presence invite [cover image hash] (https://discord.com/developers/docs/reference#image-formatting)
80
+ ///
81
+ /// is not always returned, hence the nullable property
25
82
final String ? coverImage;
83
+
84
+ /// the application's public [flags] (https://discord.com/developers/docs/resources/application#application-object-application-flags)
85
+ ///
86
+ /// is not always returned, hence the nullable property
26
87
final int ? flags;
88
+
27
89
late final List <DiscordApplicationFlag >? _flagsAsEnum;
28
90
29
91
static const idEntry = 'id' ;
@@ -66,37 +128,8 @@ class DiscordApplication {
66
128
this .flags,
67
129
});
68
130
69
- void _addFlagAsEnum (String r, int index, DiscordApplicationFlag flag) {
70
- if (r.length >= index + 1 && r.substring (index, index + 1 ) == '1' ) {
71
- _flagsAsEnum! .add (flag);
72
- }
73
- }
74
-
75
- List <DiscordApplicationFlag > get flagsAsEnum {
76
- if (flags == null ) {
77
- return < DiscordApplicationFlag > [];
78
- }
79
- if (_flagsAsEnum != null ) {
80
- return _flagsAsEnum! ;
81
- }
82
- _flagsAsEnum = < DiscordApplicationFlag > [];
83
- final radixString =
84
- String .fromCharCodes (flags! .toRadixString (2 ).runes.toList ().reversed);
85
- _addFlagAsEnum (radixString, 12 , DiscordApplicationFlag .gatewayPresence);
86
- _addFlagAsEnum (
87
- radixString, 13 , DiscordApplicationFlag .gatewayPresenceLimited);
88
- _addFlagAsEnum (radixString, 14 , DiscordApplicationFlag .gatewayGuildMembers);
89
- _addFlagAsEnum (
90
- radixString, 15 , DiscordApplicationFlag .gatewayGuildMembersLimited);
91
- _addFlagAsEnum (
92
- radixString, 16 , DiscordApplicationFlag .verificationPendingGuildLimit);
93
- _addFlagAsEnum (radixString, 17 , DiscordApplicationFlag .embedded);
94
- _addFlagAsEnum (
95
- radixString, 18 , DiscordApplicationFlag .gatewayMessageContent);
96
- _addFlagAsEnum (
97
- radixString, 19 , DiscordApplicationFlag .gatewayMessageContentLimited);
98
- return _flagsAsEnum! ;
99
- }
131
+ List <DiscordApplicationFlag > get flagsAsEnum =>
132
+ _flagsAsEnum ?? = discordApplicationFlagsAsEnum (flags);
100
133
101
134
factory DiscordApplication .fromJson (Map <String , dynamic > json) =>
102
135
DiscordApplication (
0 commit comments