Exemple #1
0
 async def clear_referral_cmd(self, ctx, user: discord.User = None):
     if (user == None):
         await ctx.send("You must tag a user!")
         return
     existing_user = database.select_one(dbobj.user_link, source=user.id)
     if (existing_user != None and existing_user != []):
         existing_user = existing_user[1]
         user_obj = self.bot.get_user(existing_user)
         confirm = await Confirm(
             "Are you sure you want to clear the record for **" +
             user.name + "#" + user.discriminator +
             "** who declared themselves as referred by **" +
             user_obj.name + "#" + user_obj.discriminator +
             "**?  (this will lower the referrer's score)").prompt(ctx)
         if confirm:
             statement = "DELETE FROM user_link WHERE source = %s"
             data = (user.id, )
             decreasing_score = database.select_one(dbobj.scores,
                                                    user_id=user_obj.id)[1]
             data_2 = (decreasing_score - 1, user_obj.id)
             #database.delete_data(statement,data)
             database.test_delete(dbobj.user_link, source=user.id)
             database.update_data(dbobj.scores, data_2)
         else:
             await ctx.send("Process canceled.")
             return
     else:
         await ctx.send(
             "That user has not declared anyone as their referrer yet!")
Exemple #2
0
 async def score_check(self,ctx,user:discord.User=None):
   # error correction
   target = None
   if(user == None):
     target = ctx.author
   else:
     target = user
   record = database.select_one(dbobj.scores, user_id=target.id)
   score = 0 if record == None or record == [] else record[1]
   await ctx.send("Requested score: **" + str(score) + "**.")
Exemple #3
0
 async def referred_by(self,ctx,user:discord.User=None):
   # Error conditions
   if(user == None):
     await ctx.send("You must tag a user!")
     return
   elif(user == ctx.author):
     await ctx.send("You cannot refer yourself.")
     return
   existing_user = database.select_one(dbobj.user_link, source=ctx.author.id)
   if(existing_user != None and existing_user != []):
     existing_user = existing_user[1]
     user_obj = self.bot.get_user(existing_user)
     if(user == user_obj):
       await ctx.send("You are already registered as referred by that user!")
       return
     confirm = await Confirm("Are you sure you want to change your referring user from **" + user_obj.name + "#" + user_obj.discriminator + "** to **" + user.name + "#" + user.discriminator + "**?").prompt(ctx)
     if confirm:
       data = (user.id,ctx.author.id)
       database.update_data(dbobj.user_link,data)
       decreasing_score = database.select_one(dbobj.scores, user_id=user_obj.id)[1]
       data_2 = (decreasing_score-1,user_obj.id)
       database.update_data(dbobj.scores,data_2)
     else:
       await ctx.send("Process canceled.")
       return
   else:
     confirm = await Confirm("Are you sure you want to set your referring user to **" + user.name + "#" + user.discriminator + "**?").prompt(ctx)
     if confirm:
       data = (ctx.author.id,user.id)
       database.insert_row(dbobj.user_link,data)
     else:
       await ctx.send("Process canceled.")
       return
   increasing_score = database.select_one(dbobj.scores, user_id=user.id)
   if(increasing_score != None and increasing_score != []):
     increasing_score = increasing_score[1]
     data = (increasing_score+1,user.id)
     database.update_data(dbobj.scores,data)
   else:
     data = (user.id,1)
     database.insert_row(dbobj.scores,data)
   await ctx.send("Process complete!")
Exemple #4
0
 async def change_prefix(self, ctx, prefix):
     v = database.select_one(dbobj.servers, id=ctx.guild.id)
     if v != [] and v != None:
         data = (prefix, ctx.guild.id)
         database.update_data(dbobj.servers, data)
         await ctx.send(
             'Command prefix changed to "**{0}**".'.format(prefix))
     else:
         data = (ctx.guild.id, prefix)
         database.insert_row(dbobj.servers, data)
         await ctx.send('Command prefix set to "**{0}**".'.format(prefix))
Exemple #5
0
 async def webhook_profile(self, ctx, username, avatar_url=None):
     existing = database.select_one(dbobj.webhook_profile,
                                    user_id=ctx.author.id)
     url_string = "None"
     if avatar_url != None:
         url_string = avatar_url
     elif ctx.message.attachments:
         url_string = ctx.message.attachments[0].url
     if existing == [] or existing == None:
         database.insert_row(dbobj.webhook_profile,
                             (ctx.author.id, username, url_string))
     else:
         database.update_data(dbobj.webhook_profile,
                              (username, url_string, ctx.author.id))
     await ctx.send("Profile Updated with username: " + username)
Exemple #6
0
 async def webhook_test_cmd(self, ctx, *, msg):
     wh = await ctx.channel.webhooks()
     if wh == []:
         await ctx.send("No webhooks in this channel!")
     else:
         profile = database.select_one(dbobj.webhook_profile,
                                       user_id=ctx.author.id)
         f = None
         if ctx.message.attachments:
             f = await ctx.message.attachments[0].to_file()
         if profile == [] or profile == None:
             await ctx.message.delete()
             await wh[0].send(msg, file=f)
         else:
             print(profile[1])
             await ctx.message.delete()
             if str(profile[2]) == "None":
                 await wh[0].send(msg, username=str(profile[1]), file=f)
             else:
                 await wh[0].send(msg,
                                  username=str(profile[1]),
                                  avatar_url=str(profile[2]),
                                  file=f)