async def disable(event: NewMessage.Event) -> None: """ Disable a command IF it's already enabled. **{prefix}disable (command)** **Example:** `{prefix}disable afk` """ arg = event.matches[0].group(1) if not arg: await event.answer("`Disable what? The void?`") return commands, command_list = await solve_commands(client.commands) arg1 = command_list.get(arg, arg) command = commands.get(arg1, False) if command: if command.builtin: await event.answer("`Cannot disable a builtin command.`") else: client.remove_event_handler(command.func) if arg in command_list: com = command_list.get(arg) client.disabled_commands[com] = command client.commands.pop(com) disabled_coms = ', '.join(split_exp.split(com)) else: client.disabled_commands[arg] = command client.commands.pop(arg) disabled_coms = arg await event.answer(f"`Successfully disabled {disabled_coms}`", log=("disable", f"Disabled command(s): {disabled_coms}")) else: await event.answer("`Couldn't find the specified command.`")
async def disable(event: NewMessage.Event) -> None: """Disable a command IF it's already enabled.""" arg = event.matches[0].group(1) if not arg: await event.answer("`Disable what? The void?`") return commands, command_list = await solve_commands(client.commands) command = commands.get(arg, command_list.get(arg, False)) if command: if command.builtin: await event.answer("`Cannot disable a builtin command.`") else: client.remove_event_handler(command.func) if arg in command_list: disabled_coms = ", ".join(split_exp.split(arg)) else: disabled_coms = arg client.disabled_commands[arg] = command client.commands.pop(arg) await event.answer( f"`Successfully disabled {disabled_coms}`", log=("disable", f"Disabled command(s): {disabled_coms}"), ) else: await event.answer("`Couldn't find the specified command.`")