-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
35 lines (25 loc) · 917 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import io
import discord
import aiohttp
from bot import client
from bot.actions import on_msg
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
await on_msg(message)
@client.event
async def on_message_delete(message):
if message.author.bot:
return
files = []
async with aiohttp.ClientSession() as session:
for attachment in message.attachments:
async with session.get(attachment.url) as resp:
data = io.BytesIO(await resp.read())
files.append(discord.File(data, filename=attachment.url.split('/')[-1]))
await message.channel.send(f'<@{message.author.id}> deleted message: "{message.content}" at '
f'{message.created_at.strftime("%m/%d/%Y, %H:%M:%S")}', files=files)
client.run(os.getenv('BOT_TOKEN'))