Created
October 26, 2017 20:44
-
-
Save IAmJSD/fa0d73b0c28eea2a8b32d1d833bca42a to your computer and use it in GitHub Desktop.
A quickly made selfbot to log a server. Run !gen_logs in a channel to get a log of it.
This file contains 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
# gen_logs - A tool to get a full log of a Discord chat. Created by Jake#0009. | |
token = "" | |
# Insert your user token here. | |
prefix = "!" | |
# Here is the prefix. Feel free to change if you want. | |
import discord | |
import logging | |
# Imports discord and logging. | |
logging.basicConfig(level=logging.INFO) | |
# Sets the logging level. | |
dclient = discord.Client() | |
# Imports the discord client. | |
@dclient.event | |
async def on_ready(): | |
logging.info("Successfully signed into Discord.") | |
# Defines on_ready | |
@dclient.event | |
async def on_message(message): | |
if message.author == dclient.user and message.content.startswith(prefix): | |
cmd = message.content.lstrip(prefix).split(' ')[0].lower() | |
if cmd == "gen_logs": | |
await dclient.edit_message(message, "Creating JSON log of this channel!") | |
data = [] | |
async for msg in dclient.logs_from(message.channel, limit=10000000): | |
tdata = {"author_id" : msg.author.id, "message_content" : msg.content, "attachments" : msg.attachments} | |
data.append(tdata) | |
await dclient.edit_message(message, "Backing up " + str(len(data)) + " messages!") | |
data = {message.channel.name : data} | |
with open(message.channel.name + ".json", "w+", encoding="utf-8") as logfile: | |
logfile.write(str(data)) | |
await dclient.edit_message(message, "Done!") | |
# Defines on_message. | |
dclient.run(token, bot=False) | |
# Starts the selfbot. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment