Giter Site home page Giter Site logo

cryptobichara / discordchatexporterpy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mahtoid/discordchatexporterpy

0.0 0.0 0.0 905 KB

A simple Discord chat exporter for Python Discord bots.

License: GNU General Public License v3.0

Python 71.31% HTML 28.69%

discordchatexporterpy's Introduction

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

Links

Attributions

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

discordchatexporterpy's People

Contributors

mahtoid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.