-
-
Save MarioMasta64/23d7fdf54834aa7f53cbc9c406437f16 to your computer and use it in GitHub Desktop.
Discord selfbot that lets you see when people edit or delete their messages
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
""" | |
Revisionist: logs Discord message edits and revisions | |
Copyright © 2017 Benjamin Mintz | |
https://bmintz.mit-license.org/@2017 | |
""" | |
import discord | |
class Revisionist(discord.Client): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
async def on_ready(self): | |
print('Username: {0.name}\nID: {0.id}'.format(self.user)) | |
self.log_channel = discord.utils.get( | |
self.get_all_channels(), | |
guild__name='Test Server', | |
name='revisionist' | |
) | |
print() | |
async def on_message_edit(self, before, after): | |
if before.author.bot or before.clean_content == after.clean_content: | |
return | |
reply = (await self.format_author(before) + ' edited their message:\n' | |
' {0.content}\n' | |
'→ {1.content}') | |
await self.log(reply.format(before, after)) | |
async def on_message_delete(self, message): | |
if message.author.bot: | |
return | |
await self.log(await self.format_author(message), | |
' has deleted the message:\n', | |
message.content | |
) | |
async def format_author(self, message): | |
unformatted = '{0.author} {0.author.mention}' | |
if isinstance(message.author, discord.Member): | |
# we are not in a DM (so author.nick exists or is None) | |
unformatted += ' ({0.author.nick})' | |
return unformatted.format(message) | |
async def log(self, *message): | |
message = ''.join(message) | |
await self.log_channel.send(message) | |
print(message) | |
print() | |
if __name__ == '__main__': | |
import sys | |
client = Revisionist(bot=False) | |
if len(sys.argv) > 1: | |
client.run(sys.argv[1], bot=False) | |
else: | |
print('Usage: {} <token>'.format(sys.argv[0]), file=sys.stderr) | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment