Add files via upload
This commit is contained in:
parent
8e0c92f693
commit
36a2c9c321
27
bot.py
27
bot.py
|
@ -2,10 +2,33 @@
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import os
|
import os, sqlite3
|
||||||
|
|
||||||
client = commands.Bot(command_prefix = "$")
|
def get_prefix(client, message):
|
||||||
|
conn = sqlite3.connect('db.sqlite3')
|
||||||
|
curr = conn.cursor()
|
||||||
|
curr.execute(f'SELECT * FROM guilds WHERE guild_id="{message.guild.id}"')
|
||||||
|
query = curr.fetchone()
|
||||||
|
|
||||||
|
if query == None:
|
||||||
|
curr.execute(f"INSERT INTO guilds VALUES ('{message.guild.id}','$')")
|
||||||
|
conn.commit()
|
||||||
|
return "$"
|
||||||
|
else:
|
||||||
|
return query[1]
|
||||||
|
|
||||||
|
client = commands.Bot(command_prefix = get_prefix)
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_guild_join(guild):
|
||||||
|
print(dir(guild))
|
||||||
|
print(guild.id)
|
||||||
|
|
||||||
|
conn = sqlite3.connect('db.sqlite3')
|
||||||
|
curr = conn.cursor()
|
||||||
|
curr.execute(f"INSERT INTO guilds VALUES ('{guild.id}','$')")
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
class Basic(commands.Cog):
|
class Basic(commands.Cog):
|
||||||
|
|
||||||
|
@ -10,5 +11,15 @@ class Basic(commands.Cog):
|
||||||
async def ping(self, ctx):
|
async def ping(self, ctx):
|
||||||
await ctx.send("pong!")
|
await ctx.send("pong!")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
async def changeprefix(self, ctx, *, prefix):
|
||||||
|
conn = sqlite3.connect('./db.sqlite3')
|
||||||
|
curr = conn.cursor()
|
||||||
|
curr.execute(f'UPDATE guilds SET prefix = "{prefix}" WHERE guild_id = "{ctx.guild.id}"')
|
||||||
|
conn.commit()
|
||||||
|
await ctx.send(f"Prefix changed to `{prefix}`")
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
client.add_cog(Basic(client))
|
client.add_cog(Basic(client))
|
||||||
|
|
|
@ -9,10 +9,10 @@ class Lydia(commands.Cog):
|
||||||
def __init__(self,client):
|
def __init__(self,client):
|
||||||
self.lydia = LydiaAI("69e6f26aba27d05e14c6a48e38008bc0794e24c1d25591db00575e9ce93c577ca934724981a540c319c7da3209ca4c0f910098c14ad6b5e27902c346c9f5cf7f")
|
self.lydia = LydiaAI("69e6f26aba27d05e14c6a48e38008bc0794e24c1d25591db00575e9ce93c577ca934724981a540c319c7da3209ca4c0f910098c14ad6b5e27902c346c9f5cf7f")
|
||||||
self.client = client
|
self.client = client
|
||||||
self.conn = sqlite3.connect('./lydia_sessions.sqlite3')
|
self.conn = sqlite3.connect('./db.sqlite3')
|
||||||
self.cur = self.conn.cursor()
|
self.cur = self.conn.cursor()
|
||||||
|
|
||||||
@commands.command(aliases=["lydia"])
|
@commands.command(aliases=["lydia"], brief="Have a chat with Lydia", usage="<chat>")
|
||||||
async def ai(self, ctx, *, quest):
|
async def ai(self, ctx, *, quest):
|
||||||
self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"')
|
self.cur.execute(f'SELECT * FROM sessions WHERE user_id="{ctx.author.id}"')
|
||||||
query = self.cur.fetchone()
|
query = self.cur.fetchone()
|
||||||
|
@ -31,19 +31,19 @@ class Lydia(commands.Cog):
|
||||||
self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')")
|
self.cur.execute(f"INSERT INTO sessions VALUES ('{ctx.author.id}','{session.id}','{session.expires}')")
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
|
await ctx.send(session.think_thought(quest))
|
||||||
reply = session.think_thought(quest)
|
|
||||||
await ctx.send(reply)
|
|
||||||
#or alternatively
|
#or alternatively
|
||||||
#await ctx.send(session.think_thought(quest))
|
#reply = session.think_thought(quest)
|
||||||
|
#await ctx.send(reply)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
reply = self.lydia.think_thought(query[1], quest)
|
await ctx.send(self.lydia.think_thought(query[1], quest))
|
||||||
await ctx.send(reply)
|
|
||||||
#or alternatively
|
#or alternatively
|
||||||
#await ctx.send(session.think_thought(quest))
|
#reply = self.lydia.think_thought(query[1], quest)
|
||||||
|
#await ctx.send(reply)
|
||||||
|
|
||||||
#remember to comment this out if you use the alternatives above
|
#uncomment this if you use the alternatives
|
||||||
print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}")
|
#print(f"[<]{ctx.message.author}: {quest}\n[>]{reply}")
|
||||||
|
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue