Skip to content

Commit 6f45934

Browse files
authored
Update channel_controller.py
1 parent 22d890b commit 6f45934

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

swibots/api/community/controllers/channel_controller.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import TYPE_CHECKING, List
33

44
from swibots.api.community.models import Channel
5-
5+
from swibots.errors import SwitchError
66

77
if TYPE_CHECKING:
88
from swibots.api.community import CommunityClient
@@ -25,14 +25,14 @@ async def create_channel(self, channel: Channel) -> str:
2525
response = await self.client.post(BASE_PATH, data=channel.to_json_request())
2626
return response.data.get("result", {}).get("channelId")
2727

28-
async def delete_channel(self, channel_id: str) -> str:
28+
async def delete_channel(self, channel_id: str) -> bool:
2929
response = await self.client.delete(f"{BASE_PATH}/{channel_id}")
30-
# return response.data.get("result", {}).get("channelId")
31-
return (
32-
"Successfully deleted the channel."
33-
if response.status_code == 200
34-
else response.data.get("errorMessage")
35-
)
30+
if response.status_code == 200:
31+
return True
32+
logging.debug(response.data)
33+
if err:= response.data.get("errorMessage"):
34+
raise SwitchError(err)
35+
return False
3636

3737
async def update_channel(self, channel: Channel) -> str:
3838
response = await self.client.put(BASE_PATH, data=channel.to_json_request())

0 commit comments

Comments
 (0)