Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2API.generateAuthorizationURL type error when generating bot installation URL #10507

Closed
boylett opened this issue Sep 14, 2024 · 3 comments

Comments

@boylett
Copy link

boylett commented Sep 14, 2024

Which package is this bug report for?

core

Issue description

  1. Create REST instance and set bot token
  2. Create OAuth2API instance and provide rest instance
  3. Call generateAuthorizationURL on the OAuth2API instance, supplying a permissions parameter for bot installation
  4. Observe TypeScript error:
    Object literal may only specify known properties, and 'permissions' does not exist in type 'RESTOAuth2AuthorizationQuery'.

Additionally, RESTOAuth2BotAuthorizationQuery is available in the documentation, but is not exported by rest/v10/oauth2.ts.

Code sample

import { OAuth2API } from "@discordjs/core";
import { REST } from "@discordjs/rest";

// Set up the Discord REST client
const rest = discord_bot_token && (
  new REST().setToken(discord_bot_token)
);

// Bot installation link
const bot_install_url = rest && (
  new OAuth2API(rest).generateAuthorizationURL({
    permissions: "8", // TypeError: Object literal may only specify known properties, and 'permissions' does not exist in type 'RESTOAuth2AuthorizationQuery'.
    client_id: discord_client_id || "",
    response_type: "code",
    scope: [
      "bot",
      "guilds",
      "guilds.members.read",
      "identify",
      "messages.read",
    ].join(" "),
  })
);

Versions

  • @discordjs/core: 2.0.0
  • @discordjs/rest: 2.4.0

Issue priority

Low (slightly annoying)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

No Intents

I have tested this issue on a development release

  • @discordjs/core 2.0.1-dev.1726186279-495bc6034
  • @discordjs/rest 2.4.1-dev.1726186275-495bc6034
@Jiralite
Copy link
Member

Jiralite commented Sep 14, 2024

The method you are using is generating an authorisation URL (code grant) which you can see by visiting the documentation associated with the method.

It seems what you want is an application invite URL. That is governed by the RESTOAuth2BotAuthorizationQuery type and is not in the core package as it is not an API method.

@Jiralite Jiralite closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
@Jiralite Jiralite reopened this Sep 14, 2024
@Jiralite
Copy link
Member

Jiralite commented Sep 14, 2024

Sorry—closed by accident. Leaving open to see if anyone else has any thoughts just in case.

@boylett
Copy link
Author

boylett commented Oct 24, 2024

I made a mistake here so happy to close this issue. Sorry to waste your time.

FFR:
To generate an authorization URL we should create it manually as per documentation. (Docs for bot link generation)

@boylett boylett closed this as completed Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants