diff --git a/src/niobot/client.py b/src/niobot/client.py index 807613f..1ad36ff 100644 --- a/src/niobot/client.py +++ b/src/niobot/client.py @@ -1489,10 +1489,13 @@ async def get_account_data(self, key: str, *, room_id: str = None) -> typing.Uni if room_id: path = ["user", self.user_id, "rooms", room_id, "account_data", key] method, path = "GET", Api._build_path(path) - async with self.send(method, path) as response: - if response.status != 200: - return None - return await response.json() + headers = { + "Authorization": "Bearer %s" % self.access_token, + } + response = await self.send(method, path, headers=headers) + if response.status != 200: + return None + return await response.json() async def set_account_data(self, key: str, data: dict, *, room_id: str = None) -> None: """Sets account data for the currently logged in account @@ -1505,10 +1508,14 @@ async def set_account_data(self, key: str, data: dict, *, room_id: str = None) - if room_id: path = ["user", self.user_id, "rooms", room_id, "account_data", key] method, path = "PUT", Api._build_path(path) - async with self.send(method, path, data, {"Content-Type": "application/json"}) as response: - if response.status != 200: - return None - return await response.json() + headers = { + "Content-Type": "application/json", + "Authorization": "Bearer %s" % self.access_token, + } + response = await self.send(method, path, data, headers=headers) + if response.status != 200: + return None + return await response.json() async def join(self, room_id: str, reason: str = None, is_dm: bool = False) -> U[JoinResponse, JoinError]: """Joins a room. room_id must be a room ID, not alias diff --git a/src/niobot/commands.py b/src/niobot/commands.py index ba90b9b..df5486e 100644 --- a/src/niobot/commands.py +++ b/src/niobot/commands.py @@ -355,7 +355,7 @@ def display_usage(self) -> str: return " ".join(usage) async def can_run(self, ctx: Context) -> bool: - """Checks if the current user passes all of the checks on the command. + """Checks if the current user passes all the checks on the command. If the user fails a check, CheckFailure is raised. Otherwise, True is returned.