fix add & list commands for api changes

This commit is contained in:
Corban-Lee Jones 2024-03-13 17:24:43 +00:00
parent 7e9e60b782
commit 307d341ec2
3 changed files with 7 additions and 2 deletions

View File

@ -108,7 +108,7 @@ class API:
url=url
)
async def create_subscription(self, name: str, rss_url: str, image_url: str, server_id: str) -> dict:
async def create_subscription(self, name: str, rss_url: str, image_url: str, server_id: str, targets: list) -> dict:
"""
Create a new Subscription.
"""
@ -122,6 +122,7 @@ class API:
form.add_field("name", name)
form.add_field("rss_url", rss_url)
form.add_field("server", server_id)
form.add_field("targets", ";".join(map(str, targets)))
form.add_field("image", image_data, filename="file.jpg")
data = await self._post_data(self.SUBSCRIPTION_ENDPOINT, form)

View File

@ -267,7 +267,7 @@ class FeedCog(commands.Cog):
async with aiohttp.ClientSession() as session:
api = API(self.bot.api_token, session)
data = await api.create_subscription(name, rss_url, image_url, str(inter.guild_id))
data = await api.create_subscription(name, rss_url, image_url, str(inter.guild_id), [-1])
except aiohttp.ClientResponseError as exc:
return await (

View File

@ -259,6 +259,9 @@ class Subscription(DjangoDataModel):
image_url: str
creation_datetime: datetime
server: int
targets: list[int]
extra_notes: str
active: bool
@staticmethod
def parser(item: dict) -> dict:
@ -266,6 +269,7 @@ class Subscription(DjangoDataModel):
item["image_url"] = item.pop("image")
item["creation_datetime"] = datetime.strptime(item["creation_datetime"], DATETIME_FORMAT)
item["server"] = int(item["server"])
item["targets"] = item["targets"].split(";")
return item