-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
31 lines (26 loc) · 1.11 KB
/
data.py
File metadata and controls
31 lines (26 loc) · 1.11 KB
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
import asyncio
import discord
from collections import Counter
from utils import default
from discord.ext.commands import AutoShardedBot
config = default.get("config.json")
class Bot(AutoShardedBot):
def __init__(self, *args, prefix=None, **kwargs):
super().__init__(*args, **kwargs)
self.db = kwargs.pop("db")
async def on_message(self, message):
query = "SELECT * FROM afk;"
row = await self.db.fetch(query)
for entry in row:
if entry['userid'] == message.author.id:
username = self.get_user(entry['userid'])
await message.channel.send(f"Welcome back {username}!")
query = "DELETE FROM afk WHERE userid=$1;"
await self.db.execute(query, message.author.id)
if message.mentions:
for entry in row:
if message.mentions[0].id == entry['userid']:
username = self.get_user(entry['userid'])
await message.channel.send(f"{username} isn't available: {entry['reason']}")
break
await self.process_commands(message)