Compare commits

...

3 commits

Author SHA1 Message Date
f5d0faa8f2
misc(forums): removed role viewing functionality from resolvedset role, use resolvedset show
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2023-09-08 13:59:35 -04:00
c498bdce05
misc(forums): improved formatting in resolvedset show command 2023-09-08 13:59:07 -04:00
0d46cbf969
fix(forums): added invoke_without_command to resolvedset show 2023-09-08 13:58:46 -04:00

View file

@ -95,7 +95,7 @@ class Forums(commands.Cog):
async def resolvedset(self, ctx: commands.Context): async def resolvedset(self, ctx: commands.Context):
"""Manages the configuration for the [p]resolved command.""" """Manages the configuration for the [p]resolved command."""
@resolvedset.group(name='show', aliases=['settings']) @resolvedset.group(name='show', invoke_without_command=True, aliases=['settings'])
async def resolvedset_show(self, ctx: commands.Context): async def resolvedset_show(self, ctx: commands.Context):
"""Shows the current cog configuration.""" """Shows the current cog configuration."""
channel_id = await self.config.guild(ctx.guild).forum_channel() channel_id = await self.config.guild(ctx.guild).forum_channel()
@ -109,44 +109,32 @@ class Forums(commands.Cog):
if role_obj: if role_obj:
already_in_list.append(role_obj.mention) already_in_list.append(role_obj.mention)
if already_in_list: if already_in_list:
roles_list = "Roles already in the allowed roles list:\n" + "\n".join(already_in_list) + f"\nUse `{command} add` to add roles to this list.\nUse `{command} remove` to remove roles from this list." roles_list = "**Allowed Roles**:\n" + "\n".join(already_in_list) + f"\nUse `{command} add` to add roles to this list.\nUse `{command} remove` to remove roles from this list."
else: else:
roles_list = f"No roles are currently in the allowed roles list.\nUse `{command} add` to add some." roles_list = f"No roles are currently in the allowed roles list.\nUse `{command} add` to add some."
tag_str = None tag_str = None
if channel_id is not None: if channel_id is not None:
channel_obj = ctx.guild.get_channel(channel_id) channel_obj = ctx.guild.get_channel(channel_id)
if channel_obj is None: if channel_obj is None:
channel = f"Channel: {channel_id}\n- ⚠️ This channel cannot be found in this guild. Is this the correct ID?\n\n" channel = f"**Channel**: {channel_id}\n- ⚠️ This channel cannot be found in this guild. Is this the correct ID?\n\n"
else: else:
channel = f"Channel: {channel_obj.mention}\n\n" channel = f"**Channel**: {channel_obj.mention}\n\n"
if tag is not None: if tag is not None:
tag_obj = channel_obj.get_tag(tag) tag_obj = channel_obj.get_tag(tag)
if tag_obj is None: if tag_obj is None:
tag_str = f"Tag: {tag}\n- ⚠️ This tag cannot be found in the set forums channel. Is this the correct ID?\n\n" tag_str = f"**Tag**: {tag}\n- ⚠️ This tag cannot be found in the set forums channel. Is this the correct ID?\n\n"
else: else:
tag_str = f"Tag: {tag_obj.emoji} {tag_obj.name}\n\n" tag_str = f"**Tag**: {tag_obj.emoji} {tag_obj.name}\n\n"
else: else:
channel = f"Channel: Not set!\n- Use `{command} channel` to set the forums channel.\n\n" channel = f"**Channel**: Not set!\n- Use `{command} channel` to set the forums channel.\n\n"
if tag_str is None: if tag_str is None:
tag_str = f"Tag: Not set!\n- Use `{command} tag` to set the tag.\n\n" tag_str = f"**Tag**: Not set!\n- Use `{command} tag` to set the tag.\n\n"
embed = discord.Embed(title="resolvedset Settings", color=await self.bot.get_embed_color(None), description=channel + tag_str + roles_list) embed = discord.Embed(title="Cog Settings", color=await self.bot.get_embed_color(None), description=channel + tag_str + roles_list)
await ctx.reply(embed=embed) await ctx.reply(embed=embed)
@resolvedset.group(name='role', invoke_without_command=True, aliases=['roles']) @resolvedset.group(name='role', autohelp=True, aliases=['roles'])
async def resolvedset_role(self, ctx: commands.Context): async def resolvedset_role(self, ctx: commands.Context):
"""Manages the allowed roles list.""" """Manages the allowed roles list."""
current_list = await self.config.guild(ctx.guild).request_roles()
already_in_list = []
for role_id in current_list:
role_obj = ctx.guild.get_role(role_id)
if role_obj:
already_in_list.append(role_obj.mention)
split_content = ctx.message.content.split()
command = ' '.join(split_content[:2])
if already_in_list:
await ctx.send("Roles already in the allowed roles list:\n" + "\n".join(already_in_list) + f"\nUse `{command} add` to add roles to this list.\nUse `{command} remove` to remove roles from this list.", allowed_mentions=discord.AllowedMentions(roles=False))
else:
await ctx.send(f"No roles are currently in the allowed roles list.\nUse `{command} add` to add some!")
@resolvedset_role.command(name='add') @resolvedset_role.command(name='add')
async def resolvedset_role_add(self, ctx: commands.Context, role: discord.Role = None): async def resolvedset_role_add(self, ctx: commands.Context, role: discord.Role = None):