Last active
January 11, 2018 09:41
-
-
Save aveao/1491df56fdd0c89bb6be1a9d569b19da to your computer and use it in GitHub Desktop.
Discord chat exporter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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