import os
import re

def fix_text_input_default(filepath):
    with open(filepath, 'r', encoding='utf-8') as f:
        content = f.read()

    # Match TextInput( followed by anything including newlines, until )
    # This is a bit risky but we can refine it.
    # We look for default= inside the arguments of TextInput
    
    def replace_default(match):
        args = match.group(2)
        new_args = args.replace("default=", "value=")
        return f"{match.group(1)}{new_args})"

    # Regex: (disnake\.ui\.TextInput\(|ui\.TextInput\(|TextInput\() (.*? \))
    # We need to handle nested parentheses if any, but TextInput usually doesn't have them in args.
    
    new_content = re.sub(r'((?:disnake\.ui\.|ui\.|)TextInput\()(.*?\))', replace_default, content, flags=re.DOTALL)

    if new_content != content:
        with open(filepath, 'w', encoding='utf-8') as f:
            f.write(new_content)
        return True
    return False

files_to_check = [
    "commandes/moderation.py",
    "commandes/ticket/__init__.py"
]

for path in files_to_check:
    if os.path.exists(path):
        if fix_text_input_default(path):
            print(f"Fixed {path}")
