Exemplo n.º 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
Exemplo n.º 2
0
 async def on(self, ctx, channel: discord.TextChannel = None, *args):
     if channel is None:
         channel = ctx.channel
     ch = str(channel.id)
     args = ''.join(args)
     DataManager.write('data/votereact.json', ch, [])
     try:
         a = DataManager.read('data/votereact.json')['channels']
     except KeyError:
         DataManager.write('data/votereact.json', 'channels', [])
     print(args)
     if '--arrows' or '-a' in args:
         print("Hm. 1")
         DataManager.list_update('data/votereact.json', ch, 'arrows')
         print("Interest.")
         if channel.id not in a:
             DataManager.list_update('data/votereact.json', 'channels',
                                     channel.id)
             await ctx.send("✅ | Enabled vote reacting here!")
         else:
             await Formatter.error(
                 ctx, "Vote reacting is already enabled here!")
     elif '-nd' or '--no-downvote' in args:
         print("Hm. 2")
         if channel.id not in a:
             DataManager.list_update('data/votereact.json', 'channels',
                                     channel.id)
             await ctx.send("✅ | Enabled vote reacting here!")
         else:
             await Formatter.error(
                 ctx, "Vote reacting is already enabled here!")
         DataManager.list_update('data/votereact.json', ch, 'nd')
     elif '-np' or '--no-upvote' in args:
         print("Hm. 3")
         if channel.id not in a:
             DataManager.list_update('data/votereact.json', 'channels',
                                     channel.id)
             await ctx.send("✅ | Enabled vote reacting here!")
         else:
             await Formatter.error(
                 ctx, "Vote reacting is already enabled here!")
         DataManager.list_update('data/votereact.json', ch, 'np')
     else:
         print("Hm. 4")
         DataManager.list_update('data/votereact.json', ch, None)
         if channel.id not in a:
             print("/")
             DataManager.list_update('data/votereact.json', 'channels',
                                     channel.id)
             await ctx.send("✅ | Enabled vote reacting here!")
         else:
             await Formatter.error(
                 ctx, "Vote reacting is already enabled here!")
Exemplo n.º 3
0
 async def remove_trigger(self, ctx, *words):
     words = '|'.join(words)
     words = words + '|'
     print(words)
     try:
         abc = DataManager.read('data/trigger.json')[str(ctx.author.id)]
         words = abc.replace(words, "")
         print(words)
         print(abc)
         DataManager.write('data/trigger.json', str(ctx.author.id), words)
         await Formatter.success(ctx,
                                 "You've removed a trigger from yourself!")
     except KeyError:
         await Formatter.error(ctx,
                               'You need to have a trigger to use this!')
         return
Exemplo n.º 4
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)
Exemplo n.º 5
0
 async def off(self, ctx, channel: discord.TextChannel = None):
     if channel is None:
         channel = ctx.channel
     ch = str(channel.id)
     try:
         a = DataManager.read('data/votereact.json')['channels']
     except KeyError:
         DataManager.write('data/votereact.json', 'channels', [])
         await Formatter.error(ctx, 'Votereact was never enabled!')
     if channel.id in a:
         DataManager.list_remove('data/votereact.json', 'channels',
                                 channel.id)
         try:
             DataManager.list_update('data/votereact.json', ch, [])
         except KeyError:
             pass
         await ctx.send("✅ | Disabled vote reacting!")
     else:
         await Formatter.error(ctx, "Votereact wasn't ever enabled.")
Exemplo n.º 6
0
    async def joining(self, ctx):
        if joining == "False":
            DataManager.write('data/lockdown.json', 'joining', 'True')
            await ctx.send("✅ | Joining lockdown is now **on**.")

        if joining == "True":
            member = discord.Member
            for member in guild.members:
                if role in member.roles:
                    await member.remove_roles(role)
            DataManager.write('data/lockdown.json', 'joining', 'False')
            await ctx.send("✅ | Joining lockdown is now **off**.")

        else:
            await ctx.send("<:error:436279057416585217>")

        async def on_member_join(self, member):
            if lockdown == "True":
                await member.add_roles(role)
            else:
                pass
Exemplo n.º 7
0
    async def trigger(self, ctx, *words):
        words = '|'.join(words)
        try:
            abc = DataManager.read('data/trigger.json')[str(ctx.author.id)]
            if abc == "":
                DataManager.write('data/trigger.json', str(ctx.author.id),
                                  words)
            else:
                words = words + '|'
                DataManager.write('data/trigger.json', str(ctx.author.id),
                                  words)
                words += abc
                DataManager.write('data/trigger.json', str(ctx.author.id),
                                  words)
        except KeyError:
            DataManager.write('data/trigger.json', str(ctx.author.id), words)

        await Formatter.success(ctx, "You've added a trigger for yourself!")