fix to faulty get_prefix method
get_prefix would throw error if a command was used in DMs, not anymore, there's better fixes out there but this one works for now
This commit is contained in:
parent
a8765d4c79
commit
9303645c37
24
bot.py
24
bot.py
|
@ -5,17 +5,23 @@ from discord.ext import commands
|
||||||
import os, sqlite3
|
import os, sqlite3
|
||||||
|
|
||||||
def get_prefix(client, message):
|
def get_prefix(client, message):
|
||||||
conn = sqlite3.connect('db.sqlite3')
|
try:
|
||||||
curr = conn.cursor()
|
conn = sqlite3.connect('db.sqlite3')
|
||||||
curr.execute(f'SELECT * FROM guilds WHERE guild_id="{message.guild.id}"')
|
curr = conn.cursor()
|
||||||
query = curr.fetchone()
|
curr.execute(f'SELECT * FROM guilds WHERE guild_id="{message.guild.id}"')
|
||||||
|
query = curr.fetchone()
|
||||||
|
|
||||||
if query == None:
|
if query == None:
|
||||||
curr.execute(f"INSERT INTO guilds VALUES ('{message.guild.id}','$')")
|
curr.execute(f"INSERT INTO guilds VALUES ('{message.guild.id}','$')")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
prefix = "$"
|
||||||
|
else:
|
||||||
|
prefix = query[1]
|
||||||
|
conn.close()
|
||||||
|
return prefix
|
||||||
|
except AttributeError:
|
||||||
|
conn.close()
|
||||||
return "$"
|
return "$"
|
||||||
else:
|
|
||||||
return query[1]
|
|
||||||
|
|
||||||
client = commands.Bot(command_prefix = get_prefix)
|
client = commands.Bot(command_prefix = get_prefix)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue