Skip to content

Commit eb2e35a

Browse files
authored
feat: ✨ Allow changing base url with Route.API_BASE_URL (#2714)
* ✨ Refactor API base URL handling in Route class * 📝 CHANGELOG.md
1 parent f75b7f1 commit eb2e35a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ These changes are available on the `master` branch, but have not yet been releas
4949
([#2579](https://github.com/Pycord-Development/pycord/pull/2579))
5050
- Added new `Subscription` object and related methods/events.
5151
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
52+
- Added ability to change the API's base URL with `Route.API_BASE_URL`.
53+
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
5254

5355
### Fixed
5456

discord/http.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ async def json_or_text(response: aiohttp.ClientResponse) -> dict[str, Any] | str
106106

107107

108108
class Route:
109+
API_BASE_URL: str = "https://discord.com/api/v{API_VERSION}"
110+
109111
def __init__(self, method: str, path: str, **parameters: Any) -> None:
110112
self.path: str = path
111113
self.method: str = method
@@ -127,7 +129,7 @@ def __init__(self, method: str, path: str, **parameters: Any) -> None:
127129

128130
@property
129131
def base(self) -> str:
130-
return f"https://discord.com/api/v{API_VERSION}"
132+
return self.API_BASE_URL.format(API_VERSION=API_VERSION)
131133

132134
@property
133135
def bucket(self) -> str:

0 commit comments

Comments
 (0)