-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScopesBuilder.cs
89 lines (74 loc) · 2.52 KB
/
ScopesBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using x3rt.DiscordOAuth2.Entities.Enums;
namespace x3rt.DiscordOAuth2;
public class ScopesBuilder
{
List<OAuthScope> _scopes = new List<OAuthScope>();
public ScopesBuilder()
{
}
public ScopesBuilder(OAuthScope scope)
{
_scopes.Add(scope);
}
public ScopesBuilder(IEnumerable<OAuthScope> scopes)
{
_scopes.AddRange(scopes);
}
public ScopesBuilder(params OAuthScope[] scopes)
{
_scopes.AddRange(scopes);
}
public ScopesBuilder AddScope(OAuthScope scope)
{
_scopes.Add(scope);
return this;
}
public ScopesBuilder AddScopes(IEnumerable<OAuthScope> scopes)
{
_scopes.AddRange(scopes);
return this;
}
public ScopesBuilder AddScopes(params OAuthScope[] scopes)
{
_scopes.AddRange(scopes);
return this;
}
public string Build()
{
return string.Join(" ", _scopes.Select(TranslateOAuthScope));
}
public override string ToString()
{
return Build();
}
private string? TranslateOAuthScope(OAuthScope scope)
{
return scope switch
{
OAuthScope.Identify => "identify",
OAuthScope.Email => "email",
OAuthScope.Connections => "connections",
OAuthScope.Guilds => "guilds",
OAuthScope.GuildsJoin => "guilds.join",
OAuthScope.GuildsMembersRead => "guilds.members.read",
OAuthScope.GdmJoin => "gdm.join",
OAuthScope.Rpc => "rpc",
OAuthScope.RpcNotificationsRead => "rpc.notifications.read",
OAuthScope.RpcVoiceRead => "rpc.voice.read",
OAuthScope.RpcVoiceWrite => "rpc.voice.write",
OAuthScope.RpcActivitiesWrite => "rpc.activities.write",
OAuthScope.Bot => "bot",
OAuthScope.WebhookIncoming => "webhook.incoming",
OAuthScope.MessagesRead => "messages.read",
OAuthScope.ApplicationsBuildsUpload => "applications.builds.upload",
OAuthScope.ApplicationsBuildsRead => "applications.builds.read",
OAuthScope.ApplicationsCommands => "applications.commands",
OAuthScope.ApplicationsStoreUpdate => "applications.store.update",
OAuthScope.ApplicationsEntitlements => "applications.entitlements",
OAuthScope.ActivitiesRead => "activities.read",
OAuthScope.ActivitiesWrite => "activities.write",
OAuthScope.RelationshipsRead => "relationships.read",
_ => null
};
}
}