1
0
Fork 0
mirror of synced 2024-05-19 20:12:30 +12:00

Added error checking for an already registered nsfw channel

This commit is contained in:
Phxntxm 2016-07-09 10:26:13 -05:00
parent a112a9173f
commit 168aa819a1

View file

@ -15,9 +15,12 @@ class Mod:
"""Registers this channel in the database as a 'nsfw' channel''"""
cursor = config.connection.cursor()
cursor.execute('use {}'.format(config.db_default))
cursor.execute('insert into nsfw_channels (channel_id) values ("{}")'.format(ctx.message.channel.id))
try:
cursor.execute('insert into nsfw_channels (channel_id) values ("{}")'.format(ctx.message.channel.id))
except pymysql.IntegrityError:
await self.bot.say("This channel is already registered as 'nsfw'!")
config.connection.commit()
await bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
await self.bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
@commands.command(pass_context=True, no_pm=True)
@checks.isAdmin()