Skip to content

Commit

Permalink
Fix incorrect request usage
Browse files Browse the repository at this point in the history
This fixes #40.
  • Loading branch information
nexy7574 committed Jan 8, 2025
1 parent c8318dc commit 56794aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/niobot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/niobot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 56794aa

Please sign in to comment.