fix(tempvoice): allow channel owners to use setlimit without admin permissions

This commit is contained in:
zv
2026-04-18 19:32:36 +02:00
parent f6f1358c1b
commit eeb345b299

View File

@@ -684,12 +684,12 @@ class TempVoice(commands.Cog):
@commands.group(name="tempvoice", invoke_without_command=True) @commands.group(name="tempvoice", invoke_without_command=True)
@commands.guild_only() @commands.guild_only()
@commands.admin_or_permissions(manage_guild=True)
async def tempvoice_group(self, ctx: commands.Context) -> None: async def tempvoice_group(self, ctx: commands.Context) -> None:
"""Administrative commands for TempVoice.""" """Administrative commands for TempVoice."""
await ctx.send_help() await ctx.send_help()
@tempvoice_group.command(name="settings") @tempvoice_group.command(name="settings")
@commands.admin_or_permissions(manage_guild=True)
async def tempvoice_settings(self, ctx: commands.Context) -> None: async def tempvoice_settings(self, ctx: commands.Context) -> None:
"""Show TempVoice configuration for this server.""" """Show TempVoice configuration for this server."""
await self._set_locale_context(ctx.guild) await self._set_locale_context(ctx.guild)
@@ -736,6 +736,7 @@ class TempVoice(commands.Cog):
await ctx.send("\n".join(lines)) await ctx.send("\n".join(lines))
@tempvoice_group.command(name="setstart") @tempvoice_group.command(name="setstart")
@commands.admin_or_permissions(manage_guild=True)
async def tempvoice_setstart(self, ctx: commands.Context, channel: discord.VoiceChannel) -> None: async def tempvoice_setstart(self, ctx: commands.Context, channel: discord.VoiceChannel) -> None:
"""Set the join-to-create start voice channel for this server.""" """Set the join-to-create start voice channel for this server."""
await self._set_locale_context(ctx.guild) await self._set_locale_context(ctx.guild)
@@ -772,6 +773,7 @@ class TempVoice(commands.Cog):
suffix = "" suffix = ""
try: try:
current_start_channel_id, target_category_id = await self._get_runtime_config(ctx.guild) current_start_channel_id, target_category_id = await self._get_runtime_config(ctx.guild)
del current_start_channel_id
if target_category_id is None: if target_category_id is None:
suffix = " " + _("Now set the target category with `tempvoice setcategory`.") suffix = " " + _("Now set the target category with `tempvoice setcategory`.")
except Exception: except Exception:
@@ -802,6 +804,7 @@ class TempVoice(commands.Cog):
) )
@tempvoice_group.command(name="setcategory") @tempvoice_group.command(name="setcategory")
@commands.admin_or_permissions(manage_guild=True)
async def tempvoice_setcategory(self, ctx: commands.Context, category: discord.CategoryChannel) -> None: async def tempvoice_setcategory(self, ctx: commands.Context, category: discord.CategoryChannel) -> None:
"""Set the target category for temporary channels in this server.""" """Set the target category for temporary channels in this server."""
await self._set_locale_context(ctx.guild) await self._set_locale_context(ctx.guild)
@@ -840,6 +843,7 @@ class TempVoice(commands.Cog):
suffix = "" suffix = ""
try: try:
start_channel_id, current_target_category_id = await self._get_runtime_config(ctx.guild) start_channel_id, current_target_category_id = await self._get_runtime_config(ctx.guild)
del current_target_category_id
if start_channel_id is None: if start_channel_id is None:
suffix = " " + _("Now set the start channel with `tempvoice setstart`.") suffix = " " + _("Now set the start channel with `tempvoice setstart`.")
except Exception: except Exception:
@@ -870,12 +874,14 @@ class TempVoice(commands.Cog):
) )
@tempvoice_group.command(name="cleanup") @tempvoice_group.command(name="cleanup")
@commands.admin_or_permissions(manage_guild=True)
async def tempvoice_cleanup(self, ctx: commands.Context) -> None: async def tempvoice_cleanup(self, ctx: commands.Context) -> None:
"""Clean stale mappings and remove empty temporary channels.""" """Clean stale mappings and remove empty temporary channels."""
await self._set_locale_context(ctx.guild) await self._set_locale_context(ctx.guild)
guild = ctx.guild guild = ctx.guild
current_start_channel_id, target_category_id = await self._get_runtime_config(guild) current_start_channel_id, target_category_id = await self._get_runtime_config(guild)
del current_start_channel_id
channel_owners = await self._get_channel_owners_snapshot(guild) channel_owners = await self._get_channel_owners_snapshot(guild)
stale_channel_ids: Set[int] = set() stale_channel_ids: Set[int] = set()