@@ -21,23 +21,23 @@ const (
2121)
2222
2323const (
24- // allows /users/@me without email
24+ // ScopeIdentify allows /users/@me without email
2525 ScopeIdentify string = "identify"
26- // enables /users/@me to return an email
26+ // ScopeEmail enables /users/@me to return an email
2727 ScopeEmail string = "email"
28- // allows /users/@me/connections to return linked Twitch and YouTube accounts
28+ // ScopeConnections allows /users/@me/connections to return linked Twitch and YouTube accounts
2929 ScopeConnections string = "connections"
30- // allows /users/@me/guilds to return basic information about all of a user's guilds
30+ // ScopeGuilds allows /users/@me/guilds to return basic information about all of a user's guilds
3131 ScopeGuilds string = "guilds"
32- // allows /invites/{invite.id} to be used for joining a user's guild
32+ // ScopeJoinGuild allows /invites/{invite.id} to be used for joining a user's guild
3333 ScopeJoinGuild string = "guilds.join"
34- // allows your app to join users to a group dm
34+ // ScopeGroupDMjoin allows your app to join users to a group dm
3535 ScopeGroupDMjoin string = "gdm.join"
36- // for oauth2 bots, this puts the bot in the user's selected guild by default
36+ // ScopeBot is for oauth2 bots, this puts the bot in the user's selected guild by default
3737 ScopeBot string = "bot"
38- // this generates a webhook that is returned in the oauth token response for authorization code grants
38+ // ScopeWebhook generates a webhook that is returned in the oauth token response for authorization code grants
3939 ScopeWebhook string = "webhook.incoming"
40- // allows /users/@me/guilds/{guild.id}/member to return a user's member information in a guild
40+ // ScopeReadGuilds allows /users/@me/guilds/{guild.id}/member to return a user's member information in a guild
4141 ScopeReadGuilds string = "guilds.members.read"
4242)
4343
@@ -63,6 +63,7 @@ type Provider struct {
6363 HTTPClient * http.Client
6464 config * oauth2.Config
6565 providerName string
66+ permissions string
6667}
6768
6869// Name gets the name used to retrieve this provider.
@@ -75,6 +76,11 @@ func (p *Provider) SetName(name string) {
7576 p .providerName = name
7677}
7778
79+ // SetPermissions is to update the bot permissions (used for when ScopeBot is set)
80+ func (p * Provider ) SetPermissions (permissions string ) {
81+ p .permissions = permissions
82+ }
83+
7884func (p * Provider ) Client () * http.Client {
7985 return goth .HTTPClientWithFallBack (p .HTTPClient )
8086}
@@ -84,11 +90,17 @@ func (p *Provider) Debug(debug bool) {}
8490
8591// BeginAuth asks Discord for an authentication end-point.
8692func (p * Provider ) BeginAuth (state string ) (goth.Session , error ) {
87- url := p . config . AuthCodeURL (
88- state ,
93+
94+ opts := []oauth2. AuthCodeOption {
8995 oauth2 .AccessTypeOnline ,
9096 oauth2 .SetAuthURLParam ("prompt" , "none" ),
91- )
97+ }
98+
99+ if p .permissions != "" {
100+ opts = append (opts , oauth2 .SetAuthURLParam ("permissions" , p .permissions ))
101+ }
102+
103+ url := p .config .AuthCodeURL (state , opts ... )
92104
93105 s := & Session {
94106 AuthURL : url ,
0 commit comments