Skip to main content

DiscordChatExporterPy

version license language

DiscordChatExporterPy is a Python plugin for your discord.py bot, allowing you to export a discord channels history within a guild.

Installing

To install the library to your bot, run the command:

pip install chat-exporter

To install the repository, run the command:

git clone https://github.com/mahtoid/DiscordChatExporterPy

Usage

Basic Usage

import discord
import chat_exporter
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)


@bot.event
async def on_ready():
    print("Live: " + bot.user.name)
    chat_exporter.init_exporter(bot)


@bot.command()
async def save(ctx):
    await chat_exporter.quick_export(channel, guild)

if __name__ == "__main__":
    bot.run("BOT_TOKEN_HERE")

Optional: If you want the transcript to display Members (Role) Colours then enable the Members Intent. Passing ‘guild’ is optional and is only necessary when using enhanced-dpy.

Customisable Usage

import io

...

@bot.command()
async def save(ctx, limit: int, tz_info):
    transcript = await chat_exporter.export(ctx.channel, guild, limit, tz_info)

    if transcript is None:
        return

     transcript_file = discord.File(io.BytesIO(transcript.encode()),
                                    filename=f"transcript-{ctx.channel.name}.html")

    await ctx.send(file=transcript_file)

Optional: limit and tz_info are both optional, but can be used to limit the amount of messages transcribed or set a ‘local’ (pytz) timezone for the bot to transcribe message times to. Passing ‘guild’ is optional and is only necessary when using enhanced-dpy.

Raw Usage

import io

...

@bot.command()
async def purge(ctx, tz_info):
    deleted_messages = await ctx.channel.purge()

    transcript = await chat_exporter.raw_export(channel, guild, deleted_messages, tz_info)

    if transcript is None:
        return

     transcript_file = discord.File(io.BytesIO(transcript.encode()),
                                    filename=f"transcript-{ctx.channel.name}.html")

    await ctx.send(file=transcript_file)

Optional: tz_info is optional, but can be used to set a ‘local’ (pytz) timezone for the bot to transcribe message times to. Passing ‘guild’ is optional and is only necessary when using enhanced-dpy.

Screenshots

https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/channel_output.png https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/html_output.png

Attributions

This project borrows CSS and HTML code from Tyrrrz’s C# DiscordChatExporter repository.

Release files for chat-exporter 1.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chat-exporter 1.7.2
File Size Uploaded
chat_exporter-1.7.2.tar.gz 34.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chat-exporter 1.7.2
File Interpreter ABI Platform
chat_exporter-1.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 77.9 kB

Release files / chat_exporter-1.7.2.tar.gz

Download URL chat_exporter-1.7.2.tar.gz
Size 34.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9dc18ebd7db96778a8cef7b7642e47f08d8029b734573b9324422e0b7903881c
BLAKE2b-256 checksum
How to use checksums
d486153710d5044cc977e409e9f97320a74fa51fd7eda121231bb9e7fa1e3d89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / chat_exporter-1.7.2-py3-none-any.whl

Download URL chat_exporter-1.7.2-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bd067acc39f7b56c9a28426ef011eaab55fdf52d294e633e95fb4adfec85ce6
BLAKE2b-256 checksum
How to use checksums
a15ff299e0bcc168a56e43901c4f5daaed10390d6b442164abe9e0117ffe7ab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.8.4

2 release files

2.8.3

2 release files

2.8.2

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.1

1 release file

2.4

1 release file

2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2

1 release file

2.1.1

2 release files

2.1

1 release file

2.0

1 release file

1.7.3

2 release files

This release

1.7.2 This release

2 release files

1.7.1

2 release files

1.7

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6

2 release files

1.5

2 release files

1.4.1

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page