# Discord Message Scraper (`vulnv/discord-message-scraper`) Actor

Export Discord messages and chat history. Download conversations from any channel, backup servers, archive threads, and analyze community data. Filter by date range and user. Perfect for data analysis and archival.

- **URL**: https://apify.com/vulnv/discord-message-scraper.md
- **Developed by:** [VulnV](https://apify.com/vulnv) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 55 total users, 7 monthly users, 94.5% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Discord Message Scraper - Export & Download Discord Chat History

Download and export Discord messages, conversations, and chat history from any channel. Perfect for archiving Discord servers, backing up important conversations, or analyzing Discord community data.

### Why Use This Discord Scraper?

- 💾 **Backup Discord Messages** - Preserve important conversations and server history
- 📊 **Export Discord Data** - Get structured Discord message data in JSON format
- 🔍 **Search & Filter** - Find specific messages by user, date, or content
- 🧵 **Include Threads** - Export Discord threads along with main channel messages
- ⏰ **Date-Based Export** - Download Discord chat history for specific time periods
- 🎯 **Easy to Use** - Simply provide your Discord token and channel URL

### How to Export Discord Messages

#### Step 1: Get Your Discord Token

Your Discord token is needed to access and download messages:

1. Open Discord in your web browser
2. Press `F12` to open Developer Tools
3. Click the `Console` tab
4. Paste this code and press Enter:
   ```javascript
   (webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()
   ```
5. Copy the token that appears (keep it private!)

⚠️ **Important**: Never share your token with anyone - it provides full access to your Discord account.

#### Step 2: Get the Channel URL

1. Open Discord and go to the channel you want to export
2. Copy the URL from your browser's address bar
   - Example: `https://discord.com/channels/123456789/987654321`

#### Step 3: Configure Your Export

**Required:**

- **Discord Token** - Your authentication token from Step 1
- **Channel URL or ID** - The Discord channel to download messages from

**Optional Settings:**

- **Date Range** - Export messages only from specific dates
  - Example: Messages from January 2026 only
- **Message Filters** - Download only specific types of messages
  - Example: Only messages with images
  - Example: Only messages from a specific user
- **Include Threads** - Also export threaded conversations

### Common Use Cases

#### 📚 Archive Discord Server History

Export all messages from your Discord server before it closes or for record-keeping.

#### 💼 Business Communication Backup

Save important Discord conversations for compliance or reference.

#### 🔬 Discord Data Analysis

Download Discord chat data for sentiment analysis, community insights, or research.

#### 🎮 Gaming Community Archives

Preserve your gaming community's Discord history and memorable moments.

#### 📝 Content Creation

Extract Discord conversations to create content, documentation, or training materials.

### What You'll Get

Each exported Discord message includes:

- ✅ **Message content** - Full text of the message
- ✅ **Timestamps** - When the message was sent and edited
- ✅ **Author details** - Username, nickname, avatar, bot status
- ✅ **Attachments** - Links to images, videos, and files
- ✅ **Reactions** - All emoji reactions with counts
- ✅ **Embeds** - Rich content like links, images, videos
- ✅ **Mentions** - Tagged users and roles
- ✅ **Thread info** - Reply chains and thread metadata
- ✅ **Server/Channel** - Guild and channel information

Data is exported in structured JSON format, with each message as a separate record for easy filtering and analysis.

### Advanced Message Filtering

Use powerful filters to export only the messages you need. Filter syntax mimics Discord's search with additional capabilities.

#### Filter by User

```
from:Tyrrrz
from:Tyrrrz#1234
```

#### Filter by Content Type

```
has:link        # Messages with links
has:embed       # Messages with embeds
has:file        # Messages with file attachments
has:video       # Messages with videos
has:image       # Messages with images
has:sound       # Messages with audio
```

#### Filter by Mentions

```
mentions:Tyrrrz#1234
```

#### Filter by Text Content

```
hello world           # Has "hello" AND "world"
"hello world"         # Has exact phrase "hello world"
```

#### Combine Filters (AND)

```
from:Tyrrrz has:image
from:Tyrrrz & has:image
```

#### Combine Filters (OR)

```
from:Tyrrrz | from:"96-LB"
```

#### Use Groups

```
(from:Tyrrrz | from:"96-LB") has:image
```

#### Negate Filters

```
-from:Tyrrrz          # NOT from Tyrrrz
-has:image            # Messages WITHOUT images
-(from:Tyrrrz has:image)  # Negate grouped filter
```

#### Escape Special Characters

```
from:96\-LB           # Escape the dash
```

#### Complex Examples

```
from:Tyrrrz has:image -has:video
(from:user1 | from:user2) & has:link
"important message" mentions:@everyone
```

### Frequently Asked Questions

#### Is it legal to export Discord messages?

You can export messages from channels you have access to. Respect Discord's Terms of Service and privacy laws.

#### How long does it take to export Discord messages?

Export time depends on the number of messages. Small channels (hundreds of messages) take seconds, while large channels (thousands of messages) may take several minutes.

#### Can I export messages from private Discord servers?

Yes, as long as your Discord account has access to the channel.

#### What happens to deleted messages?

Only messages currently visible in the channel can be exported. Deleted messages are not included.

#### Can I export Discord DMs (direct messages)?

This scraper is designed for channels. For DMs, you'll need the specific DM channel ID.

### Security & Privacy

- 🔒 Your Discord token is encrypted and never stored
- 🛡️ All exports happen securely within the Apify platform
- 🔐 Only you have access to your exported Discord data
- ⚠️ Keep your token private - never share it publicly

### Keywords

Discord scraper, Discord message exporter, download Discord chat, export Discord messages, Discord backup tool, Discord history export, Discord data extraction, save Discord conversations, Discord archiver, Discord channel downloader

# Actor input Schema

## `token` (type: `string`):

Your Discord authentication token

## `channelInput` (type: `string`):

Discord channel URL (e.g., https://discord.com/channels/SERVER\_ID/CHANNEL\_ID) or just the channel ID

## `afterDate` (type: `string`):

Export messages sent after this date (format: YYYY-MM-DD HH:MM or YYYY-MM-DD)

## `beforeDate` (type: `string`):

Export messages sent before this date (format: YYYY-MM-DD HH:MM or YYYY-MM-DD)

## `messageFilter` (type: `string`):

Filter messages using Discord search syntax. Examples: from:username | has:image, has:video, has:link, has:embed, has:file, has:sound | mentions:username | "exact phrase" | Combine: from:user has:image | Negate: -from:user | Groups: (from:user1 | from:user2) has:image

## `includeThreads` (type: `string`):

Specify which threads to include in the export

## Actor input object example

```json
{
  "token": "mfa.Ifrn...",
  "channelInput": "869237470565392388",
  "afterDate": "2026-01-25 01:00",
  "beforeDate": "2026-01-26",
  "messageFilter": "from:Tyrrrz has:image",
  "includeThreads": "none"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("vulnv/discord-message-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("vulnv/discord-message-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call vulnv/discord-message-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vulnv/discord-message-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wUoh2wdO7k9mnzL9d/builds/oqFvvBcw7i8vfB0CX/openapi.json
