channel lists command
This commit is contained in:
parent
3209d88824
commit
95f7045afa
@ -5,8 +5,9 @@ Loading this file via `commands.Bot.load_extension` will add `ChannelCog` to the
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from sqlalchemy.orm import aliased
|
||||||
from sqlalchemy import select, insert, delete, and_
|
from sqlalchemy import select, insert, delete, and_
|
||||||
from discord import Interaction, TextChannel
|
from discord import Interaction, TextChannel, Embed, Colour
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.app_commands import Group, Choice, autocomplete
|
from discord.app_commands import Group, Choice, autocomplete
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class ChannelCog(commands.Cog):
|
|||||||
|
|
||||||
# All RSS commands belong to this group.
|
# All RSS commands belong to this group.
|
||||||
channel_group = Group(
|
channel_group = Group(
|
||||||
name="channel",
|
name="channels",
|
||||||
description="Commands for channel assignment.",
|
description="Commands for channel assignment.",
|
||||||
guild_only=True # These commands belong to channels of
|
guild_only=True # These commands belong to channels of
|
||||||
)
|
)
|
||||||
@ -152,6 +153,37 @@ class ChannelCog(commands.Cog):
|
|||||||
|
|
||||||
await followup(inter, "I've removed this item (placeholder response)")
|
await followup(inter, "I've removed this item (placeholder response)")
|
||||||
|
|
||||||
|
@channel_group.command(name="list")
|
||||||
|
async def list_feeds(self, inter: Interaction):
|
||||||
|
# """"""
|
||||||
|
|
||||||
|
await inter.response.defer()
|
||||||
|
|
||||||
|
async with DatabaseManager() as database:
|
||||||
|
whereclause = and_(FeedChannelModel.discord_server_id == inter.guild_id)
|
||||||
|
query = (
|
||||||
|
select(FeedChannelModel)
|
||||||
|
.where(whereclause)
|
||||||
|
.order_by(FeedChannelModel.search_name)
|
||||||
|
)
|
||||||
|
result = await database.session.execute(query)
|
||||||
|
|
||||||
|
feed_channels = result.scalars().all()
|
||||||
|
|
||||||
|
if not feed_channels:
|
||||||
|
await followup(inter, "It looks like there are no feed channels available.")
|
||||||
|
return
|
||||||
|
|
||||||
|
output = "\n".join([f"{i}. <#{feed.discord_channel_id}> · {feed.search_name}" for i, feed in enumerate(feed_channels)])
|
||||||
|
|
||||||
|
embed = Embed(
|
||||||
|
title="Saved Feed Channels",
|
||||||
|
description=f"placeholder, add rss hyperlink for each item using a sql join\n\n{output}",
|
||||||
|
colour=Colour.lighter_grey()
|
||||||
|
)
|
||||||
|
|
||||||
|
await followup(inter, embed=embed)
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user