import discord #import secrets from discord.ext import commands from discord.ui import ChannelSelect #from common.logging import report from common.settings import check_ignore from query.guild import set_output_channel async def setup(bot: commands.Bot): await bot.add_cog(Admin(bot)) class View(discord.ui.View): def __init__(self, pg): super().__init__() self.pg = pg @discord.ui.select(cls=ChannelSelect, channel_types=[discord.ChannelType.text]) async def select_channels(self, interaction: discord.Interaction, select: ChannelSelect): await set_output_channel(self.pg, interaction.guild_id, select.values[0].id) return await interaction.response.send_message(f'You selected {select.values[0].mention}') class Select(discord.ui.Select): def __init__(self, pg, channels): self.pg = pg print(channels) options = [] for channel in channels: options.append(discord.SelectOption(label=str(channel.name),emoji="👌",description=str(channel.category)),) print(options) #options=[ # discord.SelectOption(label="Option 1",emoji="👌",description="This is option 1!"), # discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"), # discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!") # ] super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options) async def callback(self, interaction: discord.Interaction): await set_output_channel(self.pg, interaction.guild_id, 971796738484625468) await interaction.response.send_message(content=f"Your choice is {self.values[0]}!", ephemeral=True) class SelectView(discord.ui.View): def __init__(self, pg, channels, *, timeout = 180): super().__init__(timeout=timeout) self.add_item(Select(pg, channels)) class Admin(commands.Cog): """Administrative functionality.""" def __init__(self, bot: commands.Bot): self.bot = bot # @commands.command( # description="Modify channel settings via a browser", # brief="Set channel specific settings via the webgui", # help="Sends a single-use time based token to the webportal" # ) # #@commands.has_guild_permissions(administrator=True) # async def guildsettings(self, ctx: commands.Context): # # # Halt on ignore list. # if await check_ignore(self.bot.pg, ctx.author): # return # # #await ctx.send("Menus!", view=SelectView(self.bot.pg, ctx.guild.channels)) # await ctx.send("Menus!", view=View(self.bot.pg), ephemeral=True)