Skip to content

Commit

Permalink
Fixed oauth redirect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AveryYay committed Nov 24, 2024
1 parent ba84a25 commit 67c55ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions camel/bots/discord/discord_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def run(self) -> None:
self._client.run(self.token) # type: ignore[arg-type]

def get_oauth_url(
self, session_id: Optional[str] = None, permissions: Optional[int] = 8
self,
session_id: str,
permissions: Optional[int] = 8,
redirect: Optional[bool] = True
) -> str:
r"""Generate an OAuth URL to invite the bot to a Discord server.
Expand All @@ -128,11 +131,11 @@ def get_oauth_url(
"""
invite_url = (
f"https://discord.com/oauth2/authorize?client_id"
f"={self.client_id}&"
f"permissions={permissions}&scope=bot&response_type=code"
f"={self.client_id}&permissions={permissions}&"
f"scope=bot&response_type=code&state={session_id}"
)
if session_id is not None:
invite_url += f"&state={session_id}"
if redirect:
invite_url += f"&redirect_uri={self.redirect_uri}"
return invite_url

async def on_ready(self) -> None:
Expand Down

0 comments on commit 67c55ed

Please sign in to comment.