Changed back to the normal format for selecting the database
This commit is contained in:
parent
42fc65c789
commit
d3a20edcf3
|
@ -142,14 +142,14 @@ class Core:
|
||||||
tag = result[0:result.find('-')]
|
tag = result[0:result.find('-')]
|
||||||
result = result[result.find('-') + 2:]
|
result = result[result.find('-') + 2:]
|
||||||
cursor = config.getCursor()
|
cursor = config.getCursor()
|
||||||
cursor.execute("""use %s""", (config.db_default,))
|
cursor.execute('use {}'.format(config.db_default))
|
||||||
cursor.execute("""select * from tags where server_id=%s and tag=%s""", (ctx.message.server.id, tag))
|
cursor.execute('select * from tags where server_id=%s and tag=%s', (ctx.message.server.id, tag))
|
||||||
response = cursor.fetchone()
|
response = cursor.fetchone()
|
||||||
if response is not None:
|
if response is not None:
|
||||||
await self.bot.say('That tag already exists! Please remove it and re-add it!')
|
await self.bot.say('That tag already exists! Please remove it and re-add it!')
|
||||||
config.closeConnection()
|
config.closeConnection()
|
||||||
return
|
return
|
||||||
sql = """insert into tags (server_id, tag, result) values (%s, %s, %s)"""
|
sql = 'insert into tags (server_id, tag, result) values (%s, %s, %s)'
|
||||||
cursor.execute(sql, (ctx.message.server.id, tag, result))
|
cursor.execute(sql, (ctx.message.server.id, tag, result))
|
||||||
await self.bot.say("I have just added the tag {0}! You can call this tag by entering !tag {0}".format(tag))
|
await self.bot.say("I have just added the tag {0}! You can call this tag by entering !tag {0}".format(tag))
|
||||||
config.closeConnection()
|
config.closeConnection()
|
||||||
|
@ -158,7 +158,7 @@ class Core:
|
||||||
@commands.has_permissions(kick_members=True)
|
@commands.has_permissions(kick_members=True)
|
||||||
async def del_tag(self, ctx, tag: str):
|
async def del_tag(self, ctx, tag: str):
|
||||||
cursor = config.getCursor()
|
cursor = config.getCursor()
|
||||||
cursor.execute('use %s', (config.db_default,))
|
cursor.execute('use {}'.format(config.db_default))
|
||||||
cursor.execute('select * from tags where server_id=%s and tag=%s', (ctx.message.server.id, tag))
|
cursor.execute('select * from tags where server_id=%s and tag=%s', (ctx.message.server.id, tag))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result is None:
|
if result is None:
|
||||||
|
@ -169,5 +169,6 @@ class Core:
|
||||||
await self.bot.say('I have just removed the tag {}'.format(tag))
|
await self.bot.say('I have just removed the tag {}'.format(tag))
|
||||||
config.closeConnection()
|
config.closeConnection()
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Core(bot))
|
bot.add_cog(Core(bot))
|
||||||
|
|
Loading…
Reference in a new issue