Added error checking for an already registered nsfw channel
This commit is contained in:
parent
a112a9173f
commit
168aa819a1
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue