const { Client, GatewayIntentBits } = require('discord.js');
const fs = require('fs');
const path = require('path');

// Read config to get token
const configPath = path.join(process.env.HOME, '.clawdbot', 'clawdbot.json');
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const token = config.channels?.discord?.token;

if (!token) {
  console.error('No Discord token found in config');
  process.exit(1);
}

const client = new Client({
  intents: [GatewayIntentBits.Guilds]
});

// Forum channel IDs
const forums = {
  distribution: '1464923072724209780',
  networking: '1464923074813231126', 
  promotion: '1464923073827573854',
  production: '1464923072392855653',
  business: '1464923075589046437',
  hq: '1464923076583227406',
  resources: '1464918799470956723',
  analytics: '1464923071096815690'
};

// Thread data
const threads = [
  {
    forum: 'distribution',
    name: '🎯 Label Targets',
    message: `**Das's Label Hit List**

Based on melodic bass + vocal + emotional vibe with Polynesian groove influences.

---

## TIER 1 — Dream Targets

**Bitbird (San Holo)** — Perfect sonic fit. San Holo is a direct influence.
**Ophelia Records (Seven Lions)** — Melodic bass with emotional depth.
**Foreign Family Collective (ODESZA)** — Emotional, melodic, cinematic.

## TIER 2 — Strong Fits

- **Lowly** — Future bass focused
- **Monstercat (Instinct)** — Melodic/emotional catalog
- **Seeking Blue** — Melodic bass focused
- **Heroic Recordings** — Supports newer artists
- **Moving Castle** — Future bass collective

## TIER 3 — Exposure

- **NCS** — Massive exposure
- **Proximity** — YouTube reach
- **MrSuicideSheep** — Chill/melodic

---

**Strategy:** Lead with best Surya track, write personal intros, don't spam, track submissions.`
  },
  {
    forum: 'distribution',
    name: '🎵 Playlist Targets',
    message: `**Spotify + Platform Playlist Strategy**

## Spotify Editorial (pitch via Spotify for Artists)
- Bass Arcade
- Electronic Rising
- Chill Tracks
- Dance Rising

## SubmitHub Curators
- The Wavs
- Selected.
- CloudKid
- Diversity

## YouTube Channels
- Proximity
- Trap Nation / Chill Nation
- MrSuicideSheep
- xKito Music

---

**Strategy:** Pitch 4+ weeks before release, use SubmitHub for indie curators, track all submissions.`
  },
  {
    forum: 'networking',
    name: '🎤 LA Promoters & Bookings',
    message: `**Local LA Scene Targets**

## Key Promoters

**Brownies & Lemonade** — THE tastemaker collective. They break artists.
**Space Yacht** — Weekly Tuesday parties, great for emerging artists.
**HARD Events / Insomniac** — Long-term targets

## Venues
- Exchange LA (1,500 cap)
- Academy LA (1,100 cap)
- Sound Nightclub (600 cap)
- Avalon Hollywood

## Strategy
1. Attend events regularly
2. Network before pitching
3. Build relationships first
4. DJ mix needed for bookings (BLOCKED until mix done)`
  },
  {
    forum: 'networking',
    name: '🤝 Contacts & Network',
    message: `**Relationship Tracker**

## Current Network

**Danny & Parker (XLNT)** — Das's bosses, potential industry intros
**Hallwood** — Distribution deal, $10K budget
**Icon Music School** — Alumni network

## Collab Targets

**Near-term:** Nikita the Wicked, Evalution, female vocalists (1K-20K monthly)
**Dream:** Brakence, 2hollis, Subtronics, Svdden Death

## Personal
- Andrew (buddy) — collab potential
- Shelby (friend, singer) — vocal collab

---

Track relationships, follow up regularly.`
  },
  {
    forum: 'promotion',
    name: '💰 Ad Campaigns',
    message: `**Paid Promo Strategy**

Budget: $20/day (~$600/month)

## Campaign 1: Spotify Push
- Platform: Meta (IG/FB)
- Audience: San Holo, Illenium, Seven Lions fans, 18-34
- Creative: 15-30 sec video, best hook, vertical
- Budget: $15/day
- Target: <$0.50 CPC, >1% CTR

## Campaign 2: Engagement
- Boost best organic content
- Budget: $5/day

## Creative Best Practices
- Hook in first 1-3 seconds
- Vertical format (9:16)
- Captions always
- Clear CTA

---

Test → Learn → Scale winners`
  },
  {
    forum: 'promotion',
    name: '🔗 Landing Pages',
    message: `**Landing Pages Needed**

## Priority Pages

1. **Main Smart Link** — Routes to all platforms
   - Tools: Linkfire, Toneden, Feature.fm
   - Include: Spotify, Apple, SoundCloud, email signup

2. **Surya Album Page** — Album art, stream links, previews

3. **Ad Landing Pages** — Optimized for conversion
   - Single CTA
   - Fast loading
   - Mobile first
   - Pixel installed

## Email Capture
- Every landing page needs email signup
- Offer: exclusive content, early access
- Platform: Mailchimp or ConvertKit

## EPK
- Bio, photos, music links, stats, contact`
  },
  {
    forum: 'production',
    name: '📀 Current WIPs & Projects',
    message: `**Production Tracker**

## Released
**Surya (Album)** — Out everywhere
- 581 monthly Spotify listeners
- Best track for ads: [TBD]

## Current WIPs
| Track | Status | Notes |
|-------|--------|-------|
| | | |

## DJ Mix (CRITICAL)
- **Status:** [ ] Not started
- **Needed for:** LA promoter outreach
- **Format:** 30-60 min showcase mix

## Remix Targets
- Check remix contests
- Reach out for stems from smaller artists

## Collabs
- Shelby (vocals) — potential
- Andrew — potential`
  },
  {
    forum: 'business',
    name: '📊 2026 Goals & KPIs',
    message: `**Das's Career Goals**

## 6-Month (July 2026)
- [ ] 10,000 monthly Spotify listeners (from 581)
- [ ] Regularly booked weekends
- [ ] Email list started
- [ ] Label relationship started

## 12-Month (January 2027)
- [ ] 100,000 monthly listeners
- [ ] First festival circuit
- [ ] Song on Bitbird (dream)

## Current Stats
| Platform | Now | 6mo Target |
|----------|-----|------------|
| Spotify | 581 | 10,000 |
| SoundCloud | 849 | 2,000 |
| TikTok | ~600 | 5,000 |

## Revenue Streams to Develop
1. Live bookings (primary)
2. Sync licensing
3. Merch (later)

---

Review weekly. Celebrate wins.`
  },
  {
    forum: 'hq',
    name: '🎉 Wins',
    message: `**Celebrate wins big and small!**

## 2026 Wins Log

**January:**
- ✅ Surya album released
- ✅ Discord server set up for artist development

---

Add wins as they happen. Even small ones count!`
  },
  {
    forum: 'resources',
    name: '🔧 Useful Tools & Links',
    message: `**Resource Library**

## Analytics
- Spotify for Artists
- Chartmetric / Songstats
- Social Blade

## Distribution
- Hallwood (current)
- DistroKid, TuneCore (alternatives)

## Playlist Pitching
- SubmitHub
- PlaylistPush
- Daily Playlists

## Landing Pages
- Linkfire, Toneden, Feature.fm
- Carrd (custom pages)

## Content
- Canva (graphics)
- CapCut / DaVinci (video)

## Email
- Mailchimp, ConvertKit, Beehiiv

---

Add tools as you discover them!`
  }
];

async function createThreads() {
  await client.login(token);
  console.log('Logged in as', client.user.tag);

  for (const thread of threads) {
    try {
      const channel = await client.channels.fetch(forums[thread.forum]);
      if (!channel || !channel.threads) {
        console.error('Could not fetch forum:', thread.forum);
        continue;
      }

      const created = await channel.threads.create({
        name: thread.name,
        message: { content: thread.message }
      });
      console.log('Created thread:', thread.name, 'in', thread.forum);
    } catch (err) {
      console.error('Error creating thread:', thread.name, err.message);
    }
  }

  console.log('Done!');
  client.destroy();
  process.exit(0);
}

createThreads();
