Created
February 19, 2017 19:17
-
-
Save judge2020/4a6e2266c091c7eab7b43057554988e1 to your computer and use it in GitHub Desktop.
Delete non-image attachments discord - discord.py
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/python | |
# python 3 | |
# requires https://github.com/Rapptz/discord.py / "pip install discord.py" | |
# licensed under the MIT license. For more information view LICENSE.md | |
import discord | |
import asyncio | |
import os.path | |
import re | |
import sys | |
from pathlib import Path | |
# CONFIG START ------- | |
whiteList = ['bmp','jpeg','jpg','png'] | |
# CONFIG END ------- | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) | |
print(client.user.id) | |
print('------') | |
@client.event | |
async def on_message(message): | |
try: | |
for attachment in message.attachments: | |
if attachment['filename'].split('.')[-1] not in whiteListArray: | |
client.delete_message(message) | |
except: | |
print('Unknown error') | |
if os.path.exists('token.txt'): | |
tokenfile = open('token.txt', 'r') | |
token = tokenfile.read() | |
tokenfile.close() | |
client.run(token) | |
else: | |
token = input('Please input token: ') | |
os.system('cls' if os.name == 'nt' else 'clear') | |
client.run(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment