feat(forums): improved resolvedset tag command
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
parent
82d556a4e5
commit
5811aec756
1 changed files with 12 additions and 7 deletions
|
@ -174,17 +174,20 @@ class Forums(commands.Cog):
|
|||
"""Sets the channel used by the [p]resolved command."""
|
||||
if isinstance(channel, discord.ForumChannel):
|
||||
await self.config.guild(ctx.guild).forum_channel.set(channel.id)
|
||||
await ctx.send(f"Forum channel has been set to {channel.mention}.")
|
||||
await ctx.reply(f"Forum channel has been set to {channel.mention}.")
|
||||
else:
|
||||
await ctx.send(f"{channel.mention} is not a forums channel!")
|
||||
await ctx.reply(f"{channel.mention} is not a forums channel!")
|
||||
|
||||
@resolvedset.command(name="tag")
|
||||
async def resolvedset_tag(self, ctx: commands.context):
|
||||
async def resolvedset_tag(self, ctx: commands.Context):
|
||||
"""Sets the tag used by the [p]resolved command."""
|
||||
channel: discord.ForumChannel = ctx.guild.get_channel(await self.config.guild(ctx.guild).forum_channel())
|
||||
if channel is not None:
|
||||
options = self.create_select_options(ctx, channel.available_tags)
|
||||
msg = await ctx.send("Select a forum tag below.")
|
||||
msg = await ctx.reply("Select a forum tag below.")
|
||||
await msg.edit(view=SelectView(msg, options))
|
||||
else:
|
||||
await ctx.reply(f"Configuration error! Channel does not exist.")
|
||||
|
||||
class Select(ui.Select):
|
||||
def __init__(self, message, options):
|
||||
|
@ -195,7 +198,9 @@ class Select(ui.Select):
|
|||
msg: discord.Message = self.message
|
||||
config = Config.get_conf(None, cog_name='Forums', identifier=2352711325)
|
||||
await config.guild(msg.guild).forum_tag.set(int(self.values[0]))
|
||||
await msg.edit(content=f"Set resolved tag to {self.values[0]}", view=None)
|
||||
channel: discord.ForumChannel = await config.guild(msg.guild).forum_channel()
|
||||
tag = channel.get_tag(self.values[0])
|
||||
await msg.edit(content=f"Set resolved tag to {tag.emoji} {tag.name}", view=None)
|
||||
await interaction.response.defer()
|
||||
|
||||
class SelectView(ui.View):
|
||||
|
|
Loading…
Reference in a new issue