Skip to content

Instantly share code, notes, and snippets.

@aveao
Last active January 11, 2018 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aveao/1491df56fdd0c89bb6be1a9d569b19da to your computer and use it in GitHub Desktop.
Save aveao/1491df56fdd0c89bb6be1a9d569b19da to your computer and use it in GitHub Desktop.
Discord chat exporter
import logging
import discord
import asyncio
import datetime
logging.basicConfig(level=logging.INFO)
client = discord.Client()
# You need discord.py rewrite.
# pip3 install -U git+https://github.com/Rapptz/discord.py@rewrite
FILENAME="chatlog.txt"
USERID=#ID in int form
TOKEN="mfa.something"
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
await asyncio.sleep(3)
chan = client.get_user(USERID)
with open(FILENAME, "a") as myfile:
async for log in chan.history(limit=None):
text = "["+str(log.created_at.timestamp())+ "]<" + log.author.name + ">" + log.clean_content
print(text)
myfile.write(text+"\n")
print("done")
exit()
client.run(TOKEN, bot=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment