// List all channels in the guild
const https = require('https');
const TOKEN = 'MTQ3OTY0ODcxNjA1MzgwNzI4NQ.GVMGbd.WN7BliH8oq9fqbaiQcyxXesJTYgBx-ObsDkK7o';
const GUILD_ID = '1478722210460991662';

function apiGet(path) {
  return new Promise((resolve, reject) => {
    const opts = {
      hostname: 'discord.com',
      path: `/api/v10${path}`,
      headers: { 'Authorization': `Bot ${TOKEN}` }
    };
    https.get(opts, res => {
      let data = '';
      res.on('data', c => data += c);
      res.on('end', () => {
        try { resolve(JSON.parse(data)); } catch { resolve(data); }
      });
    }).on('error', reject);
  });
}

async function main() {
  const channels = await apiGet(`/guilds/${GUILD_ID}/channels`);
  if (!Array.isArray(channels)) {
    console.log('Error:', channels);
    return;
  }
  console.log(`Total channels: ${channels.length}\n`);
  channels.sort((a,b) => (a.position||0) - (b.position||0));
  channels.forEach(c => {
    const type = ['TEXT','DM','VOICE','GROUP_DM','CATEGORY','ANNOUNCE','','','','','','THREAD','THREAD','THREAD','','FORUM','MEDIA'][c.type] || c.type;
    console.log(`${c.id} | ${type.padEnd(10)} | #${c.name}`);
  });
}

main().catch(e => console.error(e));
