Add global configuration option to toggle audioset notify command and update command handling in ExtendedAudio cog
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit introduces a new global configuration option to enable or disable the audioset notify command. A new command, `togglenotify`, is added for the bot owner to manage this setting. Additionally, the command handling is updated to block the audioset notify command when it is disabled, directing users to use ExtendedAudio's notification features instead.
This commit is contained in:
parent
54103024e6
commit
c517b95f7c
1 changed files with 23 additions and 0 deletions
|
@ -36,7 +36,11 @@ class ExtendedAudio(commands.Cog):
|
|||
"last_status_message": None, # ID of the last status message (for cleanup)
|
||||
"clean_old_messages": True, # Whether to delete old status messages
|
||||
}
|
||||
default_global = {
|
||||
"disable_notify_command": True, # Whether to disable the audioset notify command
|
||||
}
|
||||
self.config.register_guild(**default_guild)
|
||||
self.config.register_global(**default_global)
|
||||
self.task = self.bot.loop.create_task(self.initialize())
|
||||
self.audio = None
|
||||
|
||||
|
@ -376,11 +380,30 @@ class ExtendedAudio(commands.Cog):
|
|||
except Exception as e:
|
||||
log.error(f"Error resetting channel name on stop: {e}")
|
||||
|
||||
@commands.command()
|
||||
@commands.is_owner()
|
||||
async def togglenotify(self, ctx: commands.Context):
|
||||
"""Toggle whether the audioset notify command should be disabled.
|
||||
|
||||
This command is bot owner only.
|
||||
When disabled, users will be directed to use ExtendedAudio's notification features instead.
|
||||
"""
|
||||
current = await self.config.disable_notify_command()
|
||||
await self.config.disable_notify_command.set(not current)
|
||||
state = "disabled" if not current else "enabled"
|
||||
await ctx.send(f"The audioset notify command is now {state}.")
|
||||
|
||||
async def cog_before_invoke(self, ctx: commands.Context):
|
||||
"""Check if the voice channel can be used before any audio command."""
|
||||
if not ctx.guild:
|
||||
return True
|
||||
|
||||
# Check if we should block audioset notify
|
||||
if await self.config.disable_notify_command():
|
||||
if ctx.command.qualified_name == "audioset notify":
|
||||
await ctx.send("This command is disabled. Please use the ExtendedAudio cog's notification features instead.")
|
||||
return False
|
||||
|
||||
# Only check audio-related commands
|
||||
if not self.audio or ctx.cog != self.audio:
|
||||
return True
|
||||
|
|
Loading…
Add table
Reference in a new issue