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

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

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

// New threads to create with updated research
const newThreads = [
  {
    forumId: '1464923072724209780', // distribution
    name: '📧 Label Demo Contacts (Verified)',
    message: `**Verified Demo Submission Links** (January 2026)

## TIER 1 — Dream Labels

**Bitbird (San Holo)**
- Portal: https://www.labelradar.com/labels/bitbird/portal
- Also: https://labelsbase.net/bitbird
- Email: info@bitbirdofficial.com

**Ophelia Records (Seven Lions)**
- Email: demos@opheliarecords.com
- They review demos from cold emails for Advent Volume series

**Heaven Sent (SLANDER / Insomniac)**
- Portal: https://www.labelradar.com/labels/insomniac/portal
- Website contact form: insomniacmusicgroup.com/label/heaven-sent/

---

## TIER 2 — Strong Fits

**Deadbeats (Zeds Dead)**
- Demo form: https://docs.google.com/forms/d/e/1FAIpQLScr_NcnaHy7UB8RHaNYCaF8Ih-JJg6YU0bjGUtkmKsNgMu3hg/viewform

**Cyclops Recordings (Subtronics)**
- Email: demos@cyclopsrecordings.com

**Joytime Collective (Marshmello)**
- Portal: https://form.jotform.com/241135232391043

**Jadu Dala (What So Not)**
- Check website/socials for submission process

**Seeking Blue**
- Demo portal via MrSuicideSheep: https://sheepnetwork.com/submit

**Lowly (Trap Nation)**
- Through parent network

---

## Pro Tips
- LabelRadar is used by many labels - worth making an account
- LabelsBase.net has verified contact info
- Always check official websites for current submission links`
  },
  {
    forumId: '1464923074813231126', // networking
    name: '🎪 Good Society LA',
    message: `**Good Society — LA Record Label + Event Promoter**

## Overview
- Based in Los Angeles
- Run by Josh Yamini
- Both a record label AND event promoter
- Focus: new wave artists, future beats, future bass

## Artists They Manage
- chromonicci
- Zenaware
- Sofasound

## Why Das Should Connect
- Perfect genre fit (future beats, melodic bass)
- They curate both releases AND shows
- Strong community focus
- Could be path to both label release + live bookings

## Contact
- Facebook: facebook.com/goodsocietyla
- Instagram: @goodsocietyLA (likely)

## Action Items
- [ ] Follow on all socials
- [ ] Attend their next event
- [ ] Engage genuinely before pitching
- [ ] Eventually reach out with demo + DJ mix`
  },
  {
    forumId: '1464923072392855653', // production
    name: '🔄 Remix Contests',
    message: `**Where to Find Remix Contests**

## Active Platforms

**SKIO Music** — skiomusic.com
- Major labels post contests here
- Prize: often official release

**Kreasound** — kreasound.com
- Regular contests
- Good community

**REMIEXS** — remiexs.com
- Has future bass category
- Check regularly

**Splice** — splice.com
- Sample challenges + remix contests
- Check "Contests" section

**Audius** — audius.co
- Decentralized platform
- Growing contest scene

**Cymatics** — cymatics.fm
- Regular production contests
- Often sample-based

**Beatportal** — beatportal.com/communities/630379-remix-contests
- List of current contests

## Labels That Run Contests
- Monstercat
- Armada Music
- Spinnin' Records
- Proximity

## Tips for Winning
1. Use only 1-2 stems as foundation
2. Don't listen to original too much
3. Create a NEW hook
4. Make first 30 seconds count
5. Submit early, not last minute

---

Check these weekly for new opportunities!`
  },
  {
    forumId: '1464923074813231126', // networking  
    name: '📍 Space Yacht Info',
    message: `**Space Yacht — LA Weekly Party**

## Overview
- Weekly Tuesday night parties
- Venue: Sound Nightclub (primarily)
- Founders: Perlman & Lu
- Focus: "showcasing the next generation of dance music"

## Space Yacht Records
- They have their own label
- Multi-genre (dubstep, DnB, trap, etc.)
- 100+ releases

## Demo Submission
- They have demo submission on their website
- They also book artists they meet at shows
- Being a regular at their events helps

## Strategy for Das
1. Go to Tuesday nights regularly
2. Become a familiar face
3. Network with organizers naturally
4. Eventually submit demo when relationship exists

## Contact
- Website: spaceyacht.com (check for demo link)
- SoundCloud: soundcloud.com/spaceyacht
- Facebook: facebook.com/spaceyacht`
  }
];

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

  for (const thread of newThreads) {
    try {
      const channel = await client.channels.fetch(thread.forumId);
      const created = await channel.threads.create({
        name: thread.name,
        message: { content: thread.message }
      });
      console.log('Created:', thread.name);
    } catch (err) {
      console.error('Error:', thread.name, err.message);
    }
  }

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

createThreads();
