mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
✔ Use the already implemented bot_request
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
from .. import configs
|
from .. import configs
|
||||||
|
|
||||||
from .guild import Guild
|
from .guild import Guild
|
||||||
|
from .. import exceptions
|
||||||
from .base import DiscordModelsBase
|
from .base import DiscordModelsBase
|
||||||
from flask import current_app, session
|
|
||||||
from .connections import UserConnection
|
from .connections import UserConnection
|
||||||
|
|
||||||
|
from flask import current_app, session
|
||||||
|
|
||||||
|
|
||||||
class User(DiscordModelsBase):
|
class User(DiscordModelsBase):
|
||||||
"""Class representing Discord User.
|
"""Class representing Discord User.
|
||||||
@@ -186,11 +188,11 @@ class User(DiscordModelsBase):
|
|||||||
Raises :py:class:`flask_discord.Unauthorized` if current user is not authorized.
|
Raises :py:class:`flask_discord.Unauthorized` if current user is not authorized.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
data = {"access_token": session["DISCORD_OAUTH2_TOKEN"]["access_token"]}
|
data = {"access_token": session["DISCORD_OAUTH2_TOKEN"]["access_token"]}
|
||||||
headers = {"Authorization": f"Bot {current_app.config['DISCORD_BOT_TOKEN']}"}
|
except KeyError:
|
||||||
return self._request(
|
raise exceptions.Unauthorized
|
||||||
f"/guilds/{guild_id}/members/{self.id}", method="PUT", oauth=False, json=data, headers=headers
|
return self._bot_request(f"/guilds/{guild_id}/members/{self.id}", method="PUT", json=data) or dict()
|
||||||
) or dict()
|
|
||||||
|
|
||||||
def fetch_guilds(self) -> list:
|
def fetch_guilds(self) -> list:
|
||||||
"""A method which makes an API call to Discord to get user's guilds. It prepares the internal guilds cache
|
"""A method which makes an API call to Discord to get user's guilds. It prepares the internal guilds cache
|
||||||
|
|||||||
Reference in New Issue
Block a user