Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions src/drivers/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
export class DiscordDriver extends Oauth2Driver<DiscordToken, DiscordScopes> {
protected accessTokenUrl = 'https://discord.com/api/oauth2/token'
protected authorizeUrl = 'https://discord.com/oauth2/authorize'
protected userInfoUrl = 'https://discord.com/api/users/@me'
protected userInfoUrl = 'https://discord.com/oauth2/@me'

/**
* The param name for the authorization code
Expand Down Expand Up @@ -75,29 +75,24 @@
* Configuring the redirect request with defaults
*/
protected configureRedirectRequest(request: RedirectRequestContract<DiscordScopes>) {
request.param('response_type', 'code')

/**
* Define user defined scopes or the default one's
*/
request.scopes(this.config.scopes || ['identify', 'email'])

request.param('response_type', 'code')
request.param('grant_type', 'authorization_code')

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (lts/jod)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (lts/iron)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (latest)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (lts/iron)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (latest)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / lint / lint (latest)

Delete `····`

Check failure on line 84 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (lts/jod)

Delete `····`
// User installation: the application will be authorized for installation to a user,

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (lts/jod)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (lts/iron)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (latest)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_windows (lts/iron)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (latest)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / lint / lint (latest)

Delete `·`

Check failure on line 85 in src/drivers/discord.ts

View workflow job for this annotation

GitHub Actions / test / test_linux (lts/jod)

Delete `·`
// not an entire guild.
request.param('integration_type', 1)

/**
* Define params based upon user config
*/
if (this.config.prompt) {
request.param('prompt', this.config.prompt)
}
if (this.config.guildId) {
request.param('guild_id', this.config.guildId)
}
if (this.config.disableGuildSelect !== undefined) {
request.param('disable_guild_select', this.config.disableGuildSelect)
}
if (this.config.permissions !== undefined) {
request.param('permissions', this.config.permissions)
} else {
request.param('prompt', 'consent')
}
}

Expand Down Expand Up @@ -136,18 +131,18 @@

const body = await request.get()
return {
id: body.id,
name: `${body.username}#${body.discriminator}`,
nickName: body.username,
avatarUrl: body.avatar
? `https://cdn.discordapp.com/avatars/${body.id}/${body.avatar}.${
body.avatar.startsWith('a_') ? 'gif' : 'png'
id: body.user.id,
name: `${body.user.username}#${body.user.discriminator}`,
nickName: body.user.username,
avatarUrl: body.user.avatar
? `https://cdn.discordapp.com/avatars/${body.user.id}/${body.user.avatar}.${
body.user.avatar.startsWith('a_') ? 'gif' : 'png'
}`
: `https://cdn.discordapp.com/embed/avatars/${body.discriminator % 5}.png`,
email: body.email, // May not always be there (requires email scope)
: `https://cdn.discordapp.com/embed/avatars/${body.user.discriminator % 5}.png`,
email: body.user.email, // May not always be there (requires email scope)
emailVerificationState:
'verified' in body
? body.verified
? body.user.verified
? ('verified' as const)
: ('unverified' as const)
: ('unsupported' as const),
Expand Down
Loading