<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Blackfyre Holdings LLC</title>
    <description>The latest articles on DEV Community by Blackfyre Holdings LLC (@blackfyreholdings).</description>
    <link>https://dev.to/blackfyreholdings</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258051%2F44c08486-d827-4801-b6ed-a52236d4aac5.png</url>
      <title>DEV Community: Blackfyre Holdings LLC</title>
      <link>https://dev.to/blackfyreholdings</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/blackfyreholdings"/>
    <language>en</language>
    <item>
      <title>Query a Discord Chat Export From the Command Line</title>
      <dc:creator>Blackfyre Holdings LLC</dc:creator>
      <pubDate>Sat, 21 Nov 2026 23:13:58 +0000</pubDate>
      <link>https://dev.to/blackfyreholdings/query-a-discord-chat-export-from-the-command-line-3p0p</link>
      <guid>https://dev.to/blackfyreholdings/query-a-discord-chat-export-from-the-command-line-3p0p</guid>
      <description>&lt;h1&gt;
  
  
  Query a Discord Chat Export From the Command Line
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;You already have a CSV of a Discord channel. Here is how to filter it, turn message IDs into dates, and know when you need JSON instead.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A Discord chat export is more useful once you can ask it questions. Which messages in this channel have files? What did one person write last month? When was this message ID created? You do not need a spreadsheet app for that. A CSV, a terminal, and a few lines of Python are enough.&lt;/p&gt;

&lt;p&gt;This post walks through that workflow with the columns a DiscordSuite CSV actually uses. It is not a general review of exporters, and it is not a substitute for Discord's own data package.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Export the chat as CSV
&lt;/h2&gt;

&lt;p&gt;Work in Chrome, Firefox or Edge on a computer, with Discord open at discord.com. Open the channel, thread, DM or group DM you want. Click the DiscordSuite icon, choose &lt;strong&gt;CSV&lt;/strong&gt;, and click &lt;strong&gt;Export&lt;/strong&gt;. Chat export uses the Discord session already open in your browser. It never asks for your password. The file is built on your computer.&lt;/p&gt;

&lt;p&gt;A few limits matter before you start querying:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A channel export does not include that channel's threads. Open the thread so its own URL shows, then export the thread as its own file.&lt;/li&gt;
&lt;li&gt;Forum channels are not a supported export.&lt;/li&gt;
&lt;li&gt;The file only contains messages that still exist and that your account can already see. Deleted messages are not in it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you also want a copy for scripts that need embeds, stickers, polls or the full author object, export &lt;strong&gt;JSON&lt;/strong&gt; in a second run. The CSV is the easier file to grep. What each format contains is listed on DiscordSuite's &lt;a href="https://discordsuite.io/features/export-formats/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=query-discord-csv-2026-11-21" rel="noopener noreferrer"&gt;export formats&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;Save the CSV somewhere obvious, for example &lt;code&gt;~/exports/channel.csv&lt;/code&gt;. The file is UTF-8, so emoji and accents stay readable.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Look at the 11 columns
&lt;/h2&gt;

&lt;p&gt;A DiscordSuite CSV has a header row and one row per message. The 11 columns, in order, are:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MessageId&lt;/code&gt;, &lt;code&gt;Timestamp&lt;/code&gt;, &lt;code&gt;AuthorId&lt;/code&gt;, &lt;code&gt;Author&lt;/code&gt;, &lt;code&gt;AuthorDisplayName&lt;/code&gt;, &lt;code&gt;Content&lt;/code&gt;, &lt;code&gt;Attachments&lt;/code&gt;, &lt;code&gt;Reactions&lt;/code&gt;, &lt;code&gt;ReplyTo&lt;/code&gt;, &lt;code&gt;Edited&lt;/code&gt;, &lt;code&gt;Pinned&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can print the header without opening Excel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 -c &lt;span class="s2"&gt;"import csv,sys; print(next(csv.reader(open(sys.argv[1], encoding='utf-8'))))"&lt;/span&gt; ~/exports/channel.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;MessageId&lt;/code&gt; and &lt;code&gt;AuthorId&lt;/code&gt; are Discord snowflake IDs. &lt;code&gt;Timestamp&lt;/code&gt; is already a readable time in the file, so many queries can use that column directly. &lt;code&gt;Attachments&lt;/code&gt; holds the file links for that message, when there are any. &lt;code&gt;ReplyTo&lt;/code&gt; points at another message when the row is a reply. &lt;code&gt;Edited&lt;/code&gt; and &lt;code&gt;Pinned&lt;/code&gt; are flags you can filter on.&lt;/p&gt;

&lt;p&gt;Do not paste a CSV of a private server into a public gist. Treat the file as you would treat the channel itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Filter rows from the command line
&lt;/h2&gt;

&lt;p&gt;The following script prints every row that has an attachment link. It uses only the Python standard library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DictReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Attachments"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Timestamp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Author"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Attachments"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 attachments.py ~/exports/channel.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To keep one person's messages, compare &lt;code&gt;AuthorId&lt;/code&gt; (stable) rather than &lt;code&gt;Author&lt;/code&gt; (the username can change). To keep pinned messages only, test &lt;code&gt;row["Pinned"]&lt;/code&gt;. To search the text, test a lowercase substring of &lt;code&gt;row["Content"]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Date ranges are straightforward because &lt;code&gt;Timestamp&lt;/code&gt; is already in the file. If you only want a slice of a long channel, you can also set From and To dates, or the first or last N messages, in DiscordSuite before you export, so the CSV is smaller to begin with.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Turn a message ID into a date
&lt;/h2&gt;

&lt;p&gt;Sometimes you have a message ID and no row in front of you: a jump link, a &lt;code&gt;ReplyTo&lt;/code&gt; value, or a log from another tool. Discord message IDs are snowflakes. The high bits are a timestamp, with Discord's epoch at 1 January 2015, 00:00:00 UTC.&lt;/p&gt;

&lt;p&gt;DiscordSuite has a free browser tool that decodes this without sending the ID to a lookup service. Nothing you paste is sent anywhere, and the tool does not look up users, servers or messages. It only does the date math, to the millisecond, in UTC:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://discordsuite.io/tools/discord-id-to-date/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=query-discord-csv-2026-11-21" rel="noopener noreferrer"&gt;Discord ID lookup&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can do the same math locally if you would rather stay in the terminal. This is the public snowflake layout Discord documents, not a DiscordSuite-specific format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;DISCORD_EPOCH_MS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1420070400000&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;snowflake_to_unix_ms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;DISCORD_EPOCH_MS&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Convert &lt;code&gt;unix_ms / 1000&lt;/code&gt; to a UTC datetime with &lt;code&gt;datetime.utcfromtimestamp&lt;/code&gt;. If that date does not line up with the &lt;code&gt;Timestamp&lt;/code&gt; column for the same &lt;code&gt;MessageId&lt;/code&gt;, you are probably looking at two different IDs (for example a user ID in &lt;code&gt;AuthorId&lt;/code&gt; rather than a message ID). The lookup tool also has a "date to the first and last ID of that moment" mode, which is handy when you want a message-ID window to filter on later.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. When CSV is not enough
&lt;/h2&gt;

&lt;p&gt;CSV is the right file for counting, filtering and joining on IDs. It is the wrong file when you need data the 11 columns do not hold. The JSON export is the one that includes the full message data: author details, content, attachments, embeds, stickers, reactions, mentions, replies and polls.&lt;/p&gt;

&lt;p&gt;If you find yourself parsing mention markup or embed titles out of the &lt;code&gt;Content&lt;/code&gt; column and coming up short, export JSON and work from that instead. Keep the CSV for the questions it answers cleanly.&lt;/p&gt;

&lt;p&gt;One more gap that no format will fix on its own: attachment links on Discord's CDN expire. The &lt;code&gt;Attachments&lt;/code&gt; column is a snapshot of the links at export time. If you need the files themselves later, download them before those links die. DiscordSuite's Media Downloader is the media-only path; a Chat Exporter run can also pack attachments with the export in one ZIP. For a single &lt;code&gt;cdn.discordapp.com&lt;/code&gt; or &lt;code&gt;media.discordapp.net&lt;/code&gt; link, the link expiry checker on the DiscordSuite site reads the &lt;code&gt;ex&lt;/code&gt; and &lt;code&gt;is&lt;/code&gt; parameters as dates and does not open the URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Keep the file, and the Terms, in view
&lt;/h2&gt;

&lt;p&gt;Exports are a local copy of a chat your account could already open. Automated access to user accounts may violate Discord's Terms of Service, and Discord can restrict accounts. DiscordSuite is not affiliated with or endorsed by Discord Inc. Use any exporter at your own discretion.&lt;/p&gt;

&lt;p&gt;If you only needed a readable log, you might have picked HTML, PDF or TXT instead. If you only needed a spreadsheet, Excel (XLSX) uses the same 11 columns as the CSV, with a frozen header. The command line is simply the fastest way I know to ask a large CSV a narrow question without opening the whole file.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Blackfyre Holdings LLC makes DiscordSuite, a browser extension for Chrome, Edge and Firefox with five tools: Chat Exporter, Media Downloader, Member Exporter, Emoji &amp;amp; Sticker Downloader, and Message Cleaner.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discord</category>
      <category>csv</category>
      <category>python</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
