示例#1
0
 async def xp_calc(self, author):
     """Adds the XP to the author."""
     a = DataManager.read('data/activity.json')['done']
     global last_author
     try:
         last_author[author.id]
     except KeyError:
         last_author[author.id] = 0
     try:
         if a is False and last_author[author.id] == 0:
             messages = DataManager.read('data/xp.json')[str(author.id)]
             messages += 15
             DataManager.delete('data/xp.json', author.id)
             DataManager.write('data/xp.json', author.id, messages)
             last_author[author.id] = 60
             await asyncio.sleep(60)
             last_author[author.id] = 0
         else:
             return None
     except KeyError:
         if a is False:
             last_author[author.id] = 60
             messages = 15
             DataManager.write('data/xp.json', author.id, messages)
             asyncio.sleep(60)
             last_author[author.id] = 0
             return messages
         else:
             return None
示例#2
0
 async def removeblacklist(self, ctx, member: discord.Member, reason=None):
     if str(member.id) in DataManager.read('data/artblacklist.json'):
         DataManager.delete('data/artblacklist', member.id)
         await ctx.send(f"✅ | Successfully removed {member.mention} from"
                        " the blacklist!")
     else:
         await ctx.send("❌ | That user is not blacklisted!")
示例#3
0
 async def announce(self, ctx):
     DataManager.delete('data/activity.json', 'done')
     DataManager.write('data/activity.json', 'timeleft', 604800)
     DataManager.write('data/activity.json', 'done', False)
     users = DataManager.read('data/activity.json')['last-week']
     sbk = discord.utils.get(ctx.bot.guilds, id=257889450850254848)
     c = 0
     embed = discord.Embed(title='And here are the final results!',
                           color=ctx.author.color)
     for user, points in users.items():
         c += 1
         member = discord.utils.get(sbk.members, id=int(user))
         if not c >= 4:
             embed.add_field(name=f"{c}." + member.name,
                             value=f"XP: **{points}**",
                             inline=False)
     await ctx.send(embed=embed)