serenity/model/application/
oauth.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5/// The available OAuth2 Scopes.
6///
7/// [Discord docs](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes).
8#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
9#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
10#[non_exhaustive]
11pub enum Scope {
12    /// For oauth2 bots, this puts the bot in the user's selected guild by default.
13    #[serde(rename = "bot")]
14    Bot,
15    /// Allows your app to use Slash Commands in a guild.
16    #[serde(rename = "applications.commands")]
17    ApplicationsCommands,
18    /// Allows your app to update its Slash Commands via this bearer token - client credentials
19    /// grant only.
20    #[serde(rename = "applications.commands.update")]
21    ApplicationsCommandsUpdate,
22    /// Allows your app to update permissions for its commands in a guild a user has permissions
23    /// to.
24    #[serde(rename = "applications.commands.permissions.update")]
25    ApplicationsCommandsPermissionsUpdate,
26    /// Allows `/users/@me` without [`Self::Email`].
27    #[serde(rename = "identify")]
28    Identify,
29    /// Enables `/users/@me` to return an `email` field.
30    #[serde(rename = "email")]
31    Email,
32    /// Allows `/users/@me/connections` to return linked third-party accounts.
33    #[serde(rename = "connections")]
34    Connections,
35    /// Allows `/users/@me/guilds` to return basic information about all of a user's guilds.
36    #[serde(rename = "guilds")]
37    Guilds,
38    /// Allows `/guilds/{guild.id}/members/{user.id}` to be used for joining users to a guild.
39    #[serde(rename = "guilds.join")]
40    GuildsJoin,
41    /// Allows `/users/@me/guilds/{guild.id}/member` to return a user's member information in a
42    /// guild.
43    #[serde(rename = "guilds.members.read")]
44    GuildsMembersRead,
45    /// Allows your app to join users to a group dm.
46    #[serde(rename = "gdm.join")]
47    GdmJoin,
48    /// For local rpc server access, this allows you to control a user's local Discord client -
49    /// requires Discord approval.
50    #[serde(rename = "rpc")]
51    Rpc,
52    /// For local rpc server api access, this allows you to receive notifications pushed out to the
53    /// user - requires Discord approval.
54    #[serde(rename = "rpc.notifications.read")]
55    RpcNotificationsRead,
56    #[serde(rename = "rpc.voice.read")]
57    RpcVoiceRead,
58    #[serde(rename = "rpc.voice.write")]
59    RpcVoiceWrite,
60    #[serde(rename = "rpc.activities.write")]
61    RpcActivitiesWrite,
62    /// This generates a webhook that is returned in the oauth token response for authorization
63    /// code grants.
64    #[serde(rename = "webhook.incoming")]
65    WebhookIncoming,
66    /// For local rpc server api access, this allows you to read messages from all client channels
67    /// (otherwise restricted to channels/guilds your app creates).
68    #[serde(rename = "messages.read")]
69    MessagesRead,
70    /// Allows your app to upload/update builds for a user's applications - requires Discord
71    /// approval.
72    #[serde(rename = "applications.builds.upload")]
73    ApplicationsBuildsUpload,
74    /// Allows your app to read build data for a user's applications.
75    #[serde(rename = "applications.builds.read")]
76    ApplicationsBuildsRead,
77    /// Allows your app to read and update store data (SKUs, store listings, achievements, etc.)
78    /// for a user's applications.
79    #[serde(rename = "applications.store.update")]
80    ApplicationsStoreUpdate,
81    /// Allows your app to read entitlements for a user's applications.
82    #[serde(rename = "applications.entitlements")]
83    ApplicationsEntitlements,
84    /// Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires
85    /// Discord approval.
86    #[serde(rename = "activities.read")]
87    ActivitiesRead,
88    /// Allows your app to update a user's activity - requires Discord approval (Not required for
89    /// gamesdk activity manager!).
90    #[serde(rename = "activities.write")]
91    ActivitiesWrite,
92    /// Allows your app to know a user's friends and implicit relationships - requires Discord
93    /// approval.
94    #[serde(rename = "relationships.read")]
95    RelationshipsRead,
96    /// Allows your app to see information about the user's DMs and group DMs - requires Discord
97    /// approval.
98    #[serde(rename = "dm_channels.read")]
99    DmChannelsRead,
100    /// Allows your app to connect to voice on user's behalf and see all the voice members -
101    /// requires Discord approval.
102    #[serde(rename = "voice")]
103    Voice,
104    /// Allows your app to update a user's connection and metadata for the app.
105    #[serde(rename = "role_connections.write")]
106    RoleConnectionsWrite,
107}
108
109impl fmt::Display for Scope {
110    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
111        self.serialize(f)
112    }
113}