command list tracked content
All checks were successful
Build and Push Docker Image / build (push) Successful in 7s

This commit is contained in:
Corban-Lee Jones 2024-08-19 21:21:21 +01:00
parent 213024ba9f
commit a71866ed6e

View File

@ -113,7 +113,7 @@ class CommandsCog(commands.Cog):
channels = f"{item.channels_count}{' channels' if item.channels_count != 1 else ' channel'}"
filters = f"{len(item.filters)}{' filters' if len(item.filters) != 1 else ' filter'}"
notes = item.extra_notes[:25] + "..." if len(item.extra_notes) > 28 else item.extra_notes
links = f"[RSS URL]({item.url}) · [API URL]({API.API_EXTERNAL_ENDPOINT}subscription/{item.id}/)"
links = f"[RSS Link]({item.url}) · [API Link]({API.API_EXTERNAL_ENDPOINT}subscription/{item.id}/)"
description = f"{channels}, {filters}\n"
description += f"{notes}\n" if notes else ""
@ -145,6 +145,37 @@ class CommandsCog(commands.Cog):
async def cmd_list_tracked(self, inter: Interaction):
"""List Tracked Content from this server, or a given sub"""
await inter.response.defer()
def formatdata(index, item):
item = TrackedContent.from_dict(item)
sub = Subscription.from_dict(item.subscription)
links = f"[Content Link]({item.url}) · [Message Link](https://discord.com/channels/{sub.guild_id}/{item.channel_id}/{item.message_id}/)"
description = f"Subscription: {sub.name}\n{links}"
key = f"{index}. {item.title}"
return key, description
async def getdata(page: int, pagesize: int):
async with aiohttp.ClientSession() as session:
api = API(self.bot.api_token, session)
return await api.get_tracked_content(
subscription__guild_id=inter.guild_id, page=page, page_size=pagesize
)
embed = Followup(f"Tracked Content in {inter.guild.name}").info()._embed
pagination = PaginationView(
self.bot,
inter=inter,
embed=embed,
getdata=getdata,
formatdata=formatdata,
pagesize=10,
initpage=1
)
await pagination.send()
# Group for test related commands
test_group = Group(
name="test",