<div align="center">
<h2>Py-Discord-HTML-Transcripts</h2>
</div>
---
## Credits
This code was NOT made by me, but is a fork and altered for my needs. All credit goes to the original developer.
# Requirements
`discord.py` v2.4.0 or later
---
## Installation
To install the library to your virtual environment, for bot usage, run the command:
```sh
pip install py-discord-html-transcripts
```
---
## Usage
There are currently 3 methods (functions) to `chat-exporter` which you can use to export your chat.<br/>
_Expand the blocks below to learn the functions, arguments and usages._
<details><summary><b>Basic Usage</b></summary>
`.quick_export()` is the simplest way of using chat-exporter.
Using the _quick_export_ function will gather the history of the channel you give, build the transcript then post the file and embed directly to the channel - returning a message object gathered from the message it posted.
This is mostly seen as a demo function, as opposed to a command you should actually use.
**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.
**Optional Argument(s):**<br/>
`bot`: `commands.Bot` object to gather members who are no longer in your guild.
**Return Argument:**<br/>
`discord.Message`: The message _quick_export_ will send, containing the embed and exported chat file.
**Example:**
```python
import discord
import chat_exporter
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
...
@bot.command()
async def save(ctx: commands.Context):
await chat_exporter.quick_export(ctx.channel)
...
```
</details>
<details><summary><b>Customisable Usage</b></summary>
`.export()` is the most efficient and flexible method to export a chat using chat-exporter.
Using the _export_ function will generate a transcript using the channel you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).
This would be the main function to use within chat-exporter.
**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.
**Optional Argument(s):**<br/>
`limit`: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).<br/>
`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>
`guild`: `discord.Guild` object which can be passed in to solve bugs for certain forks<br/>
`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>
`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>
`before`: `datetime.datetime` object which allows to gather messages from before a certain date
`after`: `datetime.datetime` object which allows to gather messages from after a certain date
`bot`: `commands.Bot` object to gather members who are no longer in your guild.
**Return Argument:**<br/>
`transcript`: The HTML build-up for you to construct the HTML File with Discord.
**Example:**
```python
import io
...
@bot.command()
async def save(ctx: commands.Context, limit: int = 100, tz_info: str = "UTC", military_time: bool = True):
transcript = await chat_exporter.export(
ctx.channel,
limit=limit,
tz_info=tz_info,
military_time=military_time,
bot=bot,
)
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)
```
</details>
<details><summary><b>Raw Usage</b></summary>
`.raw_export()` is for the crazy people who like to do their own thing when using chat-exporter.
Using the _raw_export_ function will generate a transcript using the list of messages you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).
This would be for people who want to filter what content to export.
**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather (this is just for padding the header).<br/>
`messages`: A list of Message objects which you wish to export to an HTML file.
**Optional Argument(s):**<br/>
`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>
`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>
`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>
`bot`: `commands.Bot` object to gather members who are no longer in your guild.
**Return Argument:**<br/>
`transcript`: The HTML build-up for you to construct the HTML File with Discord.
**Example:**
```python
import io
...
@bot.command()
async def purge(ctx: commands.Context, tz_info: str, military_time: bool):
deleted_messages = await ctx.channel.purge()
transcript = await chat_exporter.raw_export(
ctx.channel,
messages=deleted_messages,
tz_info=tz_info,
military_time=military_time,
bot=bot,
)
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)
```
</details>
<p align="right">(<a href="#top">back to top</a>)</p>
---
## Screenshots
<details><summary><b>General</b></summary>
<ol>
<details><summary>Discord</summary>
<img src="https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/channel_output.png">
</details>
<details><summary>Chat-Exporter</summary>
<img src="https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/html_output.png">
</details>
</ol>
</details>
<p align="right">(<a href="#top">back to top</a>)</p>
Raw data
{
"_id": null,
"home_page": "https://github.com/FroostySnoowman/py-discord-html-transcripts",
"name": "py-discord-html-transcripts",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "chat exporter, discord chat exporter, discord, discordpy, disnake, pycord, nextcord",
"author": "FroostySnoowman",
"author_email": "FroostySnoowman <froostysnoowmanbusiness@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/73/8e/8155903916500607a2328d670a3bb31427a80a4ab590fb6503aee2a867b1/py_discord_html_transcripts-2.1.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <h2>Py-Discord-HTML-Transcripts</h2>\n</div>\n\n---\n## Credits\nThis code was NOT made by me, but is a fork and altered for my needs. All credit goes to the original developer.\n\n# Requirements\n`discord.py` v2.4.0 or later\n\n---\n## Installation\n\nTo install the library to your virtual environment, for bot usage, run the command:\n```sh \npip install py-discord-html-transcripts\n```\n\n---\n## Usage\n\nThere are currently 3 methods (functions) to `chat-exporter` which you can use to export your chat.<br/>\n_Expand the blocks below to learn the functions, arguments and usages._\n<details><summary><b>Basic Usage</b></summary>\n\n`.quick_export()` is the simplest way of using chat-exporter.\n\nUsing the _quick_export_ function will gather the history of the channel you give, build the transcript then post the file and embed directly to the channel - returning a message object gathered from the message it posted.\n\nThis is mostly seen as a demo function, as opposed to a command you should actually use. \n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.\n\n**Optional Argument(s):**<br/>\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`discord.Message`: The message _quick_export_ will send, containing the embed and exported chat file.\n\n**Example:**\n```python\nimport discord\nimport chat_exporter\nfrom discord.ext import commands\n\nintents = discord.Intents.default()\nintents.members = True\nintents.message_content = True\n\nbot = commands.Bot(command_prefix=\"!\", intents=intents)\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context):\n await chat_exporter.quick_export(ctx.channel)\n\n...\n```\n\n</details>\n\n<details><summary><b>Customisable Usage</b></summary>\n\n`.export()` is the most efficient and flexible method to export a chat using chat-exporter.\n\nUsing the _export_ function will generate a transcript using the channel you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).\n\nThis would be the main function to use within chat-exporter.\n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.\n\n**Optional Argument(s):**<br/>\n`limit`: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).<br/>\n`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>\n`guild`: `discord.Guild` object which can be passed in to solve bugs for certain forks<br/>\n`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>\n`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>\n`before`: `datetime.datetime` object which allows to gather messages from before a certain date\n`after`: `datetime.datetime` object which allows to gather messages from after a certain date\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`transcript`: The HTML build-up for you to construct the HTML File with Discord.\n\n**Example:**\n```python\nimport io\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context, limit: int = 100, tz_info: str = \"UTC\", military_time: bool = True):\n transcript = await chat_exporter.export(\n ctx.channel,\n limit=limit,\n tz_info=tz_info,\n military_time=military_time,\n bot=bot,\n )\n\n if transcript is None:\n return\n\n transcript_file = discord.File(\n io.BytesIO(transcript.encode()),\n filename=f\"transcript-{ctx.channel.name}.html\",\n )\n\n await ctx.send(file=transcript_file)\n```\n</details>\n<details><summary><b>Raw Usage</b></summary>\n\n`.raw_export()` is for the crazy people who like to do their own thing when using chat-exporter.\n\nUsing the _raw_export_ function will generate a transcript using the list of messages you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).\n\nThis would be for people who want to filter what content to export.\n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather (this is just for padding the header).<br/>\n`messages`: A list of Message objects which you wish to export to an HTML file.\n\n**Optional Argument(s):**<br/>\n`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>\n`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>\n`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`transcript`: The HTML build-up for you to construct the HTML File with Discord.\n\n**Example:**\n```python\nimport io\n\n...\n\n@bot.command()\nasync def purge(ctx: commands.Context, tz_info: str, military_time: bool):\n deleted_messages = await ctx.channel.purge()\n\n transcript = await chat_exporter.raw_export(\n ctx.channel,\n messages=deleted_messages,\n tz_info=tz_info,\n military_time=military_time,\n bot=bot,\n )\n\n if transcript is None:\n return\n\n transcript_file = discord.File(\n io.BytesIO(transcript.encode()),\n filename=f\"transcript-{ctx.channel.name}.html\",\n )\n\n await ctx.send(file=transcript_file)\n```\n</details>\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n---\n## Screenshots\n\n<details><summary><b>General</b></summary>\n<ol>\n <details><summary>Discord</summary>\n <img src=\"https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/channel_output.png\">\n </details>\n <details><summary>Chat-Exporter</summary>\n <img src=\"https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/html_output.png\">\n </details>\n</ol>\n</details>\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "A simple Discord chat exporter for Python Discord bots.",
"version": "2.1.0",
"project_urls": {
"Homepage": "https://github.com/FroostySnoowman/py-discord-html-transcripts"
},
"split_keywords": [
"chat exporter",
" discord chat exporter",
" discord",
" discordpy",
" disnake",
" pycord",
" nextcord"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e864b575587f9e4927eb3f0ba3caa4ec2752585208170deb93b903fcb0708117",
"md5": "a4d7936e48c5beffeab2362e38e9cf03",
"sha256": "c706506f6eb63f097ef347abd617c28ab25d3694e2aa9dc85ca2e56acc229255"
},
"downloads": -1,
"filename": "py_discord_html_transcripts-2.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a4d7936e48c5beffeab2362e38e9cf03",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 49099,
"upload_time": "2024-08-15T22:16:30",
"upload_time_iso_8601": "2024-08-15T22:16:30.357047Z",
"url": "https://files.pythonhosted.org/packages/e8/64/b575587f9e4927eb3f0ba3caa4ec2752585208170deb93b903fcb0708117/py_discord_html_transcripts-2.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "738e8155903916500607a2328d670a3bb31427a80a4ab590fb6503aee2a867b1",
"md5": "bf02e65695faf09dd9568dfe83b1b7d6",
"sha256": "6bc775754c105a3d9e42a690674653cd611e04ce4836e26194e29286cdba99e5"
},
"downloads": -1,
"filename": "py_discord_html_transcripts-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "bf02e65695faf09dd9568dfe83b1b7d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 36574,
"upload_time": "2024-08-15T22:16:32",
"upload_time_iso_8601": "2024-08-15T22:16:32.122371Z",
"url": "https://files.pythonhosted.org/packages/73/8e/8155903916500607a2328d670a3bb31427a80a4ab590fb6503aee2a867b1/py_discord_html_transcripts-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-15 22:16:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FroostySnoowman",
"github_project": "py-discord-html-transcripts",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-discord-html-transcripts"
}