2020-02-05 22:30:38 -06:00

39 lines
1.4 KiB
Python

from discord.ext import commands
import discord
import pymysql
import asyncio
con = pymysql.connect(host='192.168.1.52',
user='Quentin',
password='kaPl0wskii',
db='Temp',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
class Temp(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, ctx):
if isinstance(ctx.channel, discord.DMChannel) and (ctx.content.lower() == "temp"):
await ctx.channel.send("Send me the data")
data = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
and message.channel == ctx.channel,
timeout=50)
user = await self.client.fetch_user(int(data.content))
list = [0, '', '']
list[0] = int(data.content)
list[1] = user.name
list[2] = user.created_at
print(list)
with con:
cur = con.cursor()
cur.execute(f"INSERT INTO Temp.temp (userID, name, joinDate) VALUES ('{list[0]}','{list[1]}','{list[2]}')")
await ctx.channel.send(f"User added successfully: {list[0]}, {list[1]}, {list[2]}")
def setup(client):
client.add_cog(Temp(client))