예제 #1
0
 async def verify(self, ctx, member: discord.Member):
     db = Session().db
     cursor = db.cursor()
     try:
         if ctx.message.author.server_permissions.manage_roles:
             cursor.execute(
                 "SELECT `enabled`, `role_id` FROM `verification` WHERE `guild_id`=%s",
                 (ctx.message.server.id, ))
             data = cursor.fetchone()
             if data['enabled'] == 1:
                 await self.bot.add_roles(
                     member, discord.Object(id=data['role_id']))
                 embed = discord.Embed(title='Member Was Verified',
                                       description="",
                                       color=0x008000)
                 embed.add_field(name='Member', value=member.mention)
                 embed.add_field(name='Whomst Verified Them',
                                 value=ctx.message.author.mention,
                                 inline=True)
                 embed.set_thumbnail(url=member.avatar_url)
                 await self.bot.say(embed=embed)
             else:
                 embed = discord.Embed(
                     title='Command Error',
                     description='Verification disabled on this server',
                     color=0x990000)
                 await self.bot.say(embed=embed)
     except:
         embed = discord.Embed(title="An Error Occurred!",
                               description=traceback.format_exc(),
                               color=0x990000)
         await self.bot.say(embed=embed)
     db.close()
예제 #2
0
 async def leave(self, ctx, channel: discord.Channel=None, *message):
     db = Session().db
     cursor = db.cursor()
     if ctx.message.author.id == ctx.message.server.owner.id:
         try:
             if channel is None:
                 channel = ctx.message.channel
             if message == '':
                 message = 'Welcome to-' + ctx.message.server.name + '-%m'
             else:
                 message = ' '.join(message)
             cursor.execute("SELECT * FROM `leave_message` WHERE `guild_id`=%s", (ctx.message.server.id,))
             check = cursor.fetchone()['enabled']
             if check == 0:
                 cursor.execute("UPDATE `leave_message` SET `channel_id`=%s, `enabled`=1, `message`=%s WHERE `guild_id`=%s", (channel.id, message, ctx.message.server.id,))
                 db.commit()
                 embed = discord.Embed(title='Leave Message Enabled', description='', color=0x008000)
                 embed.add_field(name='Channel', value=channel.mention)
                 embed.add_field(name='Message', value=str(message), inline=True)
                 await self.bot.say(embed=embed)
             else:
                 cursor.execute("UPDATE `leave_message` SET `enabled`=0 WHERE `guild_id`=%s", (ctx.message.server.id,))
                 db.commit()
                 embed = discord.Embed(title='Leave Message Disabled', description='', color=0x008000)
                 embed.add_field(name='Channel', value=channel.mention)
                 await self.bot.say(embed=embed)
         except:
             embed = discord.Embed(title="An Error Occurred!", description=traceback.format_exc(), color=0x990000)
             await self.bot.say(embed=embed)
         db.close()
예제 #3
0
 async def info(self, ctx, user: discord.Member=None):
     db = Session().db
     cursor = db.cursor()
     if user is None:
         user = ctx.message.author
     cursor.execute("SELECT `value` FROM `rep` WHERE `guild_id`=%s AND `user_id`=%s", (ctx.message.server.id, user.id,))
     data = cursor.fetchone()
     if data is None:
         cursor.execute("INSERT INTO `rep` (`guild_id`, `user_id`, `value`) VALUES (%s, %s, 0)", (ctx.message.server.id, user.id,))
         db.commit()
         rep = str(0)
     else:
         rep = str(data['value'])
     if user is None:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(title=ctx.message.author.name + "'s info", description="", color=embed_color)
         embed.set_thumbnail(url=ctx.message.author.avatar_url)
         embed.add_field(name="User id", value=ctx.message.author.id)
         embed.add_field(name="Rep", value=rep, inline=True)
         embed.add_field(name="Server join date", value=ctx.message.author.joined_at)
         embed.add_field(name="Discord join date", value=ctx.message.author.created_at.date(), inline=True)
         embed.add_field(name="Status", value=ctx.message.author.status)
         await self.bot.say(embed=embed)
     else:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(title=user.name + "'s info", description="", color=embed_color)
         embed.set_thumbnail(url=user.avatar_url)
         embed.add_field(name="User id", value=user.id)
         embed.add_field(name="Rep", value=rep, inline=True)
         embed.add_field(name="Server join date", value=user.joined_at)
         embed.add_field(name="Discord join date", value=user.created_at.date(), inline=True)
         embed.add_field(name="Status", value=user.status)
         await self.bot.say(embed=embed)
     db.close()
예제 #4
0
 async def on_member_remove(self, member):
     db = Session().db
     cursor = db.cursor()
     cursor.execute("SELECT `message`, `channel_id` FROM `leave_message` WHERE `guild_id`=%s AND `enabled`=1", (member.server.id,))
     data = cursor.fetchone()
     if data is not None:
         message = data['message'].replace('%m', member.mention)
         embed = discord.Embed(title="Member Left!", description=message, color=embed_color)
         embed.set_thumbnail(url=member.avatar_url)
         await self.bot.send_message(discord.Object(id=data['channel_id']), embed=embed)
     db.close()
예제 #5
0
 async def subtract(self, ctx, user: discord.Member = None):
     db = Session().db
     cursor = db.cursor()
     if user is None:
         embed = discord.Embed(
             title="Command Error!",
             description="You must mention who to add rep to",
             color=embed_color)
         await self.bot.say(embed=embed)
     else:
         if user is ctx.message.author:
             embed = discord.Embed(
                 title='Command Error!',
                 description="LOL you can't rep your self",
                 color=embed_color)
             await self.bot.say(embed=embed)
         else:
             cursor.execute(
                 "SELECT `value` FROM `rep` WHERE `guild_id`=%s AND `user_id`=%s",
                 (
                     ctx.message.server.id,
                     user.id,
                 ))
             data = cursor.fetchone()
             if data is None:
                 cursor.execute(
                     "INSERT INTO `rep` (`guild_id`, `user_id`, `value`) VALUES (%s, %s, -1)",
                     (
                         ctx.message.server.id,
                         user.id,
                     ))
                 db.commit()
                 embed = discord.Embed(title="+rep",
                                       description=user.mention +
                                       " now has -1 rep",
                                       color=embed_color)
                 await self.bot.say(embed=embed)
             else:
                 value = data['value'] - 1
                 cursor.execute(
                     "UPDATE `rep` SET `value`=%s WHERE `guild_id`=%s AND`user_id`=%s",
                     (
                         value,
                         ctx.message.server.id,
                         user.id,
                     ))
                 db.commit()
                 embed = discord.Embed(title="+rep",
                                       description=user.mention +
                                       " now has ``" + str(value) +
                                       "`` rep",
                                       color=embed_color)
                 await self.bot.say(embed=embed)
     db.close()
예제 #6
0
 async def on_server_join(self, server):
     db = Session().db
     cursor = db.cursor()
     cursor.execute("SELECT * FROM `welcome_message` WHERE `guild_id`=%s", (server.id,))
     wel = cursor.fetchone()
     if wel is None:
         cursor.execute("INSERT INTO `welcome_message` (`guild_id`, `channel_id`, `enabled`, `message`) VALUES (%s, NULL, 0, NULL)", (server.id,))
         db.commit()
     cursor.execute()
     lev = cursor.fetchone("SELECT * FROM `leave_message` WHERE `guild_id`=%s", (server.id,))
     if lev is None:
         cursor.execute("INSERT INTO `leave_message` (`guild_id`, `channel_id`, `enabled`, `message`) VALUES (%s, NULL, 0, NULL)", (server.id,))
         db.commit()
     db.close()
예제 #7
0
 async def autoverify(self, ctx, *args: int):
     db = Session().db
     cursor = db.cursor()
     try:
         if ctx.message.author.id == ctx.message.server.owner.id:
             cursor.execute(
                 "SELECT * FROM `auto_verify` WHERE `guild_id`=%s",
                 (ctx.message.server.id, ))
             data = cursor.fetchone()
             if data is None:
                 if args is None:
                     embed = discord.Embed(
                         title="Argument Error",
                         description=
                         "Please specify what requirements a member needs to meet to be auto-verified",
                         color=0x990000)
                     await self.bot.say(embed=embed)
                 else:
                     cursor.execute(
                         "INSERT INTO `auto_verify` (`guild_id`, `enabled`, `avatar_req`, `date_req`, `online_req`) VALUES (%s, 1, %s, %s, %s)",
                         (ctx.message.server.id, args[0], args[1], args[2]))
                     db.commit()
                     embed = discord.Embed(title="Auto-Verify Enabled",
                                           description='',
                                           color=0x008000)
                     embed.add_field(name='Avatar Required',
                                     value=args[0],
                                     inline=False)
                     embed.add_field(name='Date Required',
                                     value='Epoch:' + str(time.time()) +
                                     ' - ' + str(args[1]),
                                     inline=False)
                     embed.add_field(name='Online Required',
                                     value=args[2],
                                     inline=False)
                     await self.bot.say(embed=embed)
             else:
                 if args is None:
                     if data['enabled'] == 0:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `enabled`=1 WHERE `guild_id`=%s",
                             (ctx.message.server.id, ))
                         embed = discord.Embed(title="Auto-Verify Enabled",
                                               description='',
                                               color=0x008000)
                         await self.bot.say(embed=embed)
                     if data['enabled'] == 1:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `enabled`=0 WHERE `guild_id`=%s",
                             (ctx.message.server.id, ))
                         embed = discord.Embed(title="Auto-Verify Disabled",
                                               description='',
                                               color=0x008000)
                         await self.bot.say(embed=embed)
                 else:
                     if data['enabled'] == 0:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `enabled`=1 WHERE `guild_id`=%s",
                             (ctx.message.server.id, ))
                         embed = discord.Embed(title="Auto-Verify Enabled",
                                               description='',
                                               color=0x008000)
                     else:
                         embed = discord.Embed(
                             title="Auto-Verify Requirements Changed",
                             description='',
                             color=0x008000)
                     if args[0] is not None:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `avatar_req`=%s WHERE `guild_id`=%s",
                             (
                                 args[0],
                                 ctx.message.server.id,
                             ))
                         embed.add_field(name='Avatar Required',
                                         value=args[0],
                                         inline=False)
                     if args[1] is not None:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `date_req`=%s WHERE `guild_id`=%s",
                             (
                                 args[1],
                                 ctx.message.server.id,
                             ))
                         embed.add_field(name='Date Required',
                                         value='Epoch:' + str(time.time()) +
                                         ' - ' + str(args[1]),
                                         inline=False)
                     if args[2] is not None:
                         cursor.execute(
                             "UPDATE `auto_verify` SET `online_req`=%s WHERE `guild_id`=%s",
                             (
                                 args[2],
                                 ctx.message.server.id,
                             ))
                         embed.add_field(name='Online Required',
                                         value=args[2],
                                         inline=False)
                     db.commit()
                     await self.bot.say(embed=embed)
     except:
         embed = discord.Embed(title="Command Error",
                               description=traceback.format_exc(),
                               color=0x990000)
         await self.bot.say(embed=embed)
     db.close()
예제 #8
0
 async def on_member_join(self, member):
     db = Session().db
     cursor = db.cursor()
     cursor.execute(
         "SELECT `enabled`, `role_id` FROM `verification` WHERE `guild_id`=%s",
         (member.server.id, ))
     datax = cursor.fetchone()
     cursor.execute("SELECT * FROM `auto_verify` WHERE `guild_id`=%s",
                    (member.server.id, ))
     datay = cursor.fetchone()
     if datax['enabled'] == 1:
         if datay['enabled'] == 1:
             year = member.created_at.year
             month = member.created_at.month
             day = member.created_at.day
             hour = member.created_at.hour
             min = member.created_at.minute
             sec = member.created_at.second
             member_epoch = calendar.timegm(
                 (int(year), int(month), int(day), int(hour), int(min),
                  int(sec)))
             if member.avatar:
                 avatar = 1
             else:
                 avatar = 0
             if member.status != discord.Status.offline:
                 online = 1
             else:
                 online = 0
             if datay['avatar_req'] <= avatar:
                 if datay['online_req'] <= online:
                     if datay['date_req'] == 0:
                         await self.bot.add_roles(
                             member, discord.Object(id=datax['role_id']))
                         embed = discord.Embed(
                             title="Auto-Verification",
                             description=
                             "You have met the requirements to be auto-verified in the following server",
                             color=0x008000)
                         embed.add_field(name="Server Name",
                                         value=member.server.name)
                         embed.add_field(name="Server Id",
                                         value=member.server.id,
                                         inline=True)
                         await self.bot.send_message(member, embed=embed)
                     else:
                         if member_epoch < int(
                                 time.time()) - datay['date_req']:
                             await self.bot.add_roles(
                                 member,
                                 discord.Object(id=datax['role_id']))
                             embed = discord.Embed(
                                 title="Auto-Verification",
                                 description=
                                 "You have met the requirements to be auto-verified in the following server",
                                 color=0x008000)
                             embed.add_field(name="Server Name",
                                             value=member.server.name)
                             embed.add_field(name="Server Id",
                                             value=member.server.id,
                                             inline=True)
                             await self.bot.send_message(member,
                                                         embed=embed)
                         else:
                             embed = discord.Embed(
                                 title="Auto-Verification",
                                 description=
                                 "You have not met the requirements to be auto-verified in the following server; please wait for an admin to verify you",
                                 color=0x990000)
                             embed.add_field(name="Server Name",
                                             value=member.server.name)
                             embed.add_field(name="Server Id",
                                             value=member.server.id,
                                             inline=True)
                             await self.bot.send_message(member,
                                                         embed=embed)
                 else:
                     if datay['date_req'] == 0:
                         await self.bot.add_roles(
                             member, discord.Object(id=datax['role_id']))
                         embed = discord.Embed(
                             title="Auto-Verification",
                             description=
                             "You have met the requirements to be auto-verified in the following server",
                             color=0x008000)
                         embed.add_field(name="Server Name",
                                         value=member.server.name)
                         embed.add_field(name="Server Id",
                                         value=member.server.id,
                                         inline=True)
                         await self.bot.send_message(member, embed=embed)
                     else:
                         if member_epoch < int(
                                 time.time()) - datay['date_req']:
                             await self.bot.add_roles(
                                 member,
                                 discord.Object(id=datax['role_id']))
                             embed = discord.Embed(
                                 title="Auto-Verification",
                                 description=
                                 "You have met the requirements to be auto-verified in the following server",
                                 color=0x008000)
                             embed.add_field(name="Server Name",
                                             value=member.server.name)
                             embed.add_field(name="Server Id",
                                             value=member.server.id,
                                             inline=True)
                             await self.bot.send_message(member,
                                                         embed=embed)
                         else:
                             embed = discord.Embed(
                                 title="Auto-Verification",
                                 description=
                                 "You have not met the requirements to be auto-verified in the following server; please wait for an admin to verify you",
                                 color=0x990000)
                             embed.add_field(name="Server Name",
                                             value=member.server.name)
                             embed.add_field(name="Server Id",
                                             value=member.server.id,
                                             inline=True)
                             await self.bot.send_message(member,
                                                         embed=embed)
             else:
                 embed = discord.Embed(
                     title="Auto-Verification",
                     description=
                     "You have not met the requirements to be auto-verified in the following server; please wait for an admin to verify you",
                     color=0x990000)
                 embed.add_field(name="Server Name",
                                 value=member.server.name)
                 embed.add_field(name="Server Id",
                                 value=member.server.id,
                                 inline=True)
                 await self.bot.send_message(member, embed=embed)
     db.close()
예제 #9
0
 async def verification(self, ctx, role=None):
     db = Session().db
     cursor = db.cursor()
     try:
         if ctx.message.author.id == ctx.message.server.owner.id:
             cursor.execute(
                 "SELECT `enabled`, `role_id` FROM `verification` WHERE `guild_id`=%s",
                 (ctx.message.server.id, ))
             data = cursor.fetchone()
             if data is None:
                 for r in ctx.message.server.roles:
                     if r.name == role:
                         r_id = r.id
                 if r_id:
                     cursor.execute(
                         "INSERT INTO `verification` (`guild_id`, `role_id`, `enabled`) VALUES (%s, %s, 1)",
                         (
                             ctx.message.server.id,
                             r_id,
                         ))
                     db.commit()
                     embed = discord.Embed(title='Verification Enabled',
                                           description="",
                                           color=0x008000)
                     embed.add_field(name='Verification Role', value=role)
                     await self.bot.say(embed=embed)
                 else:
                     await self.bot.say('this role does not exist')
             else:
                 if role is None:
                     if data['enabled'] == 1:
                         cursor.execute(
                             "UPDATE `verification` SET `enabled`=0 WHERE `guild_id`=%s",
                             (ctx.message.server.id, ))
                         db.commit()
                         embed = discord.Embed(
                             title='Verification Disabled',
                             description="",
                             color=0x008000)
                         await self.bot.say(embed=embed)
                     if data['enabled'] == 0:
                         cursor.execute(
                             "UPDATE `verification` SET `enabled`=1 WHERE `guild_id`=%s",
                             (ctx.message.server.id, ))
                         db.commit()
                         embed = discord.Embed(title='Verification Enabled',
                                               description="",
                                               color=0x008000)
                         embed.add_field(name='Verification Role',
                                         value=data['role_id'])
                         await self.bot.say(embed=embed)
                 else:
                     for r in ctx.message.server.roles:
                         if r.name == role:
                             r_id = r.id
                     if r_id:
                         if data['enabled'] == 0:
                             cursor.execute(
                                 "UPDATE `verification` SET `role_id`=%s, `enabled`=1 WHERE `guild_id`=%s",
                                 (
                                     r_id,
                                     ctx.message.server.id,
                                 ))
                             db.commit()
                             embed = discord.Embed(
                                 title='Verification Enabled',
                                 description="",
                                 color=0x008000)
                             embed.add_field(name='Verification Role',
                                             value=role)
                             await self.bot.say(embed=embed)
                         if data['enabled'] == 1:
                             cursor.execute(
                                 "UPDATE `verification` SET `role_id`=%s WHERE `guild_id`=%s",
                                 (
                                     r_id,
                                     ctx.message.server.id,
                                 ))
                             db.commit()
                             embed = discord.Embed(
                                 title='Verification Role Changed',
                                 description="",
                                 color=0x008000)
                             embed.add_field(name='Verification Role',
                                             value=role)
                             await self.bot.say(embed=embed)
                     else:
                         await self.bot.say("this role does not exist")
         else:
             embed = discord.Embed(
                 title='Command Error',
                 description=
                 'This command may only execute by the server owner',
                 color=0x990000)
             await self.bot.say(embed=embed)
     except:
         embed = discord.Embed(title="An Error Occurred!",
                               description=traceback.format_exc(),
                               color=0x990000)
         await self.bot.say(embed=embed)
     db.close()