-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
OAuth.cs
102 lines (86 loc) · 2.44 KB
/
OAuth.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ReSharper disable InconsistentNaming
namespace DisCatSharp.Enums;
/// <summary>
/// The oauth scopes.
/// </summary>
public static class OAuth
{
/// <summary>
/// The default scopes for bots.
/// </summary>
private const string BOT_DEFAULT = "bot applications.commands"; // applications.commands.permissions.update
/// <summary>
/// The bot minimal scopes.
/// </summary>
private const string BOT_MINIMAL = "bot applications.commands";
/// <summary>
/// The bot only scope.
/// </summary>
private const string BOT_ONLY = "bot";
/// <summary>
/// The basic identify scopes.
/// </summary>
private const string IDENTIFY_BASIC = "identify email";
/// <summary>
/// The extended identify scopes.
/// </summary>
private const string IDENTIFY_EXTENDED = "identify email guilds guilds.members.read connections";
/// <summary>
/// The role connection scope.
/// </summary>
private const string ROLE_CONNECTIONS_WRITE = "role_connections.write";
/// <summary>
/// All scopes for bots and identify.
/// </summary>
private const string ALL = BOT_DEFAULT + " " + IDENTIFY_EXTENDED + " " + ROLE_CONNECTIONS_WRITE;
/// <summary>
/// Resolves the scopes.
/// </summary>
/// <param name="scope">The scope.</param>
/// <returns>A string representing the scopes.</returns>
public static string ResolveScopes(OAuthScopes scope) =>
scope switch
{
OAuthScopes.BOT_DEFAULT => BOT_DEFAULT,
OAuthScopes.BOT_MINIMAL => BOT_MINIMAL,
OAuthScopes.BOT_ONLY => BOT_ONLY,
OAuthScopes.IDENTIFY_BASIC => IDENTIFY_BASIC,
OAuthScopes.IDENTIFY_EXTENDED => IDENTIFY_EXTENDED,
OAuthScopes.ALL => ALL,
_ => BOT_DEFAULT
};
}
/// <summary>
/// The oauth scopes.
/// </summary>
public enum OAuthScopes
{
/// <summary>
/// Scopes: bot applications.commands (Excluding applications.commands.permissions.update for now)
/// </summary>
BOT_DEFAULT = 0,
/// <summary>
/// Scopes: bot applications.commands
/// </summary>
BOT_MINIMAL = 1,
/// <summary>
/// Scopes: bot
/// </summary>
BOT_ONLY = 2,
/// <summary>
/// Scopes: identify email
/// </summary>
IDENTIFY_BASIC = 3,
/// <summary>
/// Scopes: identify email guilds connections
/// </summary>
IDENTIFY_EXTENDED = 4,
/// <summary>
/// Scopes: bot applications.commands applications.commands.permissions.update identify email guilds connections role_connections.write
/// </summary>
ALL = 5,
/// <summary>
/// Scopes: role_connections.write
/// </summary>
ROLE_CONNECTIONS_WRITE = 6
}