-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
24 lines (21 loc) · 1.05 KB
/
utils.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
import asyncio
import discord
from discord.ext import commands
import aiofiles
import os
import time
#Single user large comment storage
async def buildDatabase(username, channel):
if os.path.exists("MessageLogs/" + username + ".txt"):
if os.path.getmtime("MessageLogs/" + username + ".txt") < time.time() - 86400: #if a db is more than 1 day old
async with aiofiles.open("MessageLogs/" + username + ".txt", 'w+') as file:
async for message in channel.history(limit=4000):
if message.author.id == int(username): # and str(message.content)[0] != "!":
await file.write("{}\n".format(message.content))
await file.close()
else:
async with aiofiles.open("MessageLogs/" + username + ".txt", 'w+') as file:
async for message in channel.history(limit=4000):
if message.author.id == int(username): # and str(message.content)[0] != "!":
await file.write("{}\n".format(message.content))
await file.close()