fix(tempvoice): allow channel owners to use setlimit without admin permissions
This commit is contained in:
@@ -684,12 +684,12 @@ class TempVoice(commands.Cog):
|
||||
|
||||
@commands.group(name="tempvoice", invoke_without_command=True)
|
||||
@commands.guild_only()
|
||||
@commands.admin_or_permissions(manage_guild=True)
|
||||
async def tempvoice_group(self, ctx: commands.Context) -> None:
|
||||
"""Administrative commands for TempVoice."""
|
||||
await ctx.send_help()
|
||||
|
||||
@tempvoice_group.command(name="settings")
|
||||
@commands.admin_or_permissions(manage_guild=True)
|
||||
async def tempvoice_settings(self, ctx: commands.Context) -> None:
|
||||
"""Show TempVoice configuration for this server."""
|
||||
await self._set_locale_context(ctx.guild)
|
||||
@@ -736,6 +736,7 @@ class TempVoice(commands.Cog):
|
||||
await ctx.send("\n".join(lines))
|
||||
|
||||
@tempvoice_group.command(name="setstart")
|
||||
@commands.admin_or_permissions(manage_guild=True)
|
||||
async def tempvoice_setstart(self, ctx: commands.Context, channel: discord.VoiceChannel) -> None:
|
||||
"""Set the join-to-create start voice channel for this server."""
|
||||
await self._set_locale_context(ctx.guild)
|
||||
@@ -772,6 +773,7 @@ class TempVoice(commands.Cog):
|
||||
suffix = ""
|
||||
try:
|
||||
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:
|
||||
suffix = " " + _("Now set the target category with `tempvoice setcategory`.")
|
||||
except Exception:
|
||||
@@ -802,6 +804,7 @@ class TempVoice(commands.Cog):
|
||||
)
|
||||
|
||||
@tempvoice_group.command(name="setcategory")
|
||||
@commands.admin_or_permissions(manage_guild=True)
|
||||
async def tempvoice_setcategory(self, ctx: commands.Context, category: discord.CategoryChannel) -> None:
|
||||
"""Set the target category for temporary channels in this server."""
|
||||
await self._set_locale_context(ctx.guild)
|
||||
@@ -840,6 +843,7 @@ class TempVoice(commands.Cog):
|
||||
suffix = ""
|
||||
try:
|
||||
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:
|
||||
suffix = " " + _("Now set the start channel with `tempvoice setstart`.")
|
||||
except Exception:
|
||||
@@ -870,12 +874,14 @@ class TempVoice(commands.Cog):
|
||||
)
|
||||
|
||||
@tempvoice_group.command(name="cleanup")
|
||||
@commands.admin_or_permissions(manage_guild=True)
|
||||
async def tempvoice_cleanup(self, ctx: commands.Context) -> None:
|
||||
"""Clean stale mappings and remove empty temporary channels."""
|
||||
await self._set_locale_context(ctx.guild)
|
||||
|
||||
guild = ctx.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)
|
||||
stale_channel_ids: Set[int] = set()
|
||||
|
||||
Reference in New Issue
Block a user