import json, urllib.request, os

config_path = os.path.expanduser('~/.openclaw/openclaw.json')
with open(config_path, 'r') as f:
    cfg = json.load(f)

token = cfg['channels']['discord']['token']
GUILD_ID = '1478419889243820042'
url = f'https://discord.com/api/v10/guilds/{GUILD_ID}/channels'
req = urllib.request.Request(url, headers={'Authorization': f'Bot {token}'})
with urllib.request.urlopen(req) as resp:
    data = json.loads(resp.read().decode('utf-8'))

for ch in sorted(data, key=lambda c: c.get('position', 0)):
    name = ch.get('name', '')
    cid = ch.get('id')
    ctype = ch.get('type')
    parent = ch.get('parent_id', '')
    print(f'{name} = {cid} (type={ctype}, parent={parent})')
