Esempio n. 1
0
 async def on_message_edit(self, before, after):
     message = after
     ignore = DataManager.read('data/ignorelist.json')['ignore']
     if message.author.id in ignore:
         return
     keywords = DataManager.read('data/trigger.json')
     for id in keywords:
         target = discord.utils.get(self.bot.get_all_members(),
                                    id=int(id)) if message.guild else None
         if keywords[id] == "":
             return
         msg = keywords[id].split('|')
         temp = []
         for a in msg:
             temp.append(a.lower())
         msg = temp
         if (message.guild is not None) and (
             (any(var in message.content.lower().split(" ")
                  for var in msg)) or (target in message.mentions)):
             if target is None:
                 pass
             else:
                 if message.author.bot:
                     return
                 if message.author == target:
                     return
                 await target.send(embed=notify(message))
Esempio n. 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!")
Esempio n. 3
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
Esempio n. 4
0
    async def on_message(self, message):
        a = DataManager.read('data/votereact.json')['channels']
        try:
            b = DataManager.read('data/votereact.json')[str(
                message.channel.id)]
        except KeyError:
            b = []
        if message.author.bot:
            return
        if message.channel.id in a:
            if not message.attachments == []:
                if 'arrows' in b:
                    if 'np' in b:
                        await message.add_reaction("\U0001f53d")
                    elif 'nd' in b:
                        await message.add_reaction("\U0001f53c")
                    else:
                        await message.add_reaction("\U0001f53d")
                        await message.add_reaction("\U0001f53c")
                else:
                    if 'np' in b:
                        await message.add_reaction("\U0001f44e")
                    elif 'nd' in b:
                        await message.add_reaction('\U0001f44d')
                    else:
                        await message.add_reaction('\U0001f44d')
                        await message.add_reaction('\U0001f44e')
            elif not message.embeds == []:
                if 'arrows' in b:
                    if 'np' in b:
                        await message.add_reaction("\U0001f53d")
                    elif 'nd' in b:
                        await message.add_reaction("\U0001f53c")
                    else:
                        await message.add_reaction("\U0001f53d")
                        await message.add_reaction("\U0001f53c")

                else:
                    if 'np' in b:
                        await message.add_reaction("\U0001f44e")
                    elif 'nd' in b:
                        await message.add_reaction('\U0001f44d')
                    else:
                        await message.add_reaction('\U0001f44d')
                        await message.add_reaction('\U0001f44e')
            else:
                pass
        else:
            pass
Esempio n. 5
0
    async def leaderboard(self, ctx):
        m = Manager()
        users = m.leaderboard()
        sbk = discord.utils.get(ctx.bot.guilds, id=257889450850254848)
        c = 0
        embed = discord.Embed(color=ctx.author.color)
        embed.set_author(name='Sinbad Knights Top Nine!',
                         icon_url=ctx.guild.icon_url)
        for user in users:
            c += 1
            member = discord.utils.get(sbk.members, id=int(user))
            if not c >= 11:
                z = m.get_xp(user)
                zz = DataManager.read('data/activity.json')['last-week']
                if member is not None:
                    if zz and user in zz:
                        if not c >= 4:
                            embed.add_field(name=f"{c}. " + member.name,
                                            value=f"🔥 XP: **{z}**",
                                            inline=False)
                        else:
                            pass
                    else:
                        embed.add_field(name=f"{c}. " + member.name,
                                        value=f"XP: **{z}**",
                                        inline=False)
                else:
                    c -= 1
                    continue
            else:
                break

        await ctx.send(embed=embed)
Esempio n. 6
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
Esempio n. 7
0
 def get_xp(self, author):
     """Returns the XP of the author. Returns None if not avavilble."""
     try:
         xp = DataManager.read('data/xp.json')[str(author)]
         return xp
     except KeyError:
         return None
Esempio n. 8
0
 async def on_message(self, message):
     m = Manager()
     if message.author.bot:
         return
     if message.channel.id in DataManager.read(
             'data/activity.json')['ignore-list']:
         return
     else:
         await m.xp_calc(message.author)
Esempio n. 9
0
    async def artblacklist(self, ctx, number=10):
        if ctx.invoked_subcommand is None:
            embed = discord.Embed(color=ctx.author.color)
            i = 0
            for b in DataManager.read('data/artblacklist.json'):
                greater = False
                i += 1
                if number:
                    if number > 10:
                        if i > 10:
                            greater = True
                        else:
                            greater = True
                    else:
                        if i > number:
                            break
                else:
                    if i > 10:
                        greater = True

                reason = DataManager.read('data/artblacklist.json')[str(b)][1]
                pos = DataManager.read('data/artblacklist.json')[str(b)][0]

                member = discord.utils.get(ctx.bot.get_all_members(),
                                           id=int(b))
                embed.set_author(name="Art channel blacklists:\n")
                clean_name = emoji.get_emoji_regexp().sub(r'\\\1', member.name)

                embed.add_field(
                    name=f"#{pos} {clean_name}#{member.discriminator}"
                    f" (ID:{member.id})",
                    value=reason,
                    inline=False)

            try:
                if len(DataManager.read('data/artblacklist.json')) == 0:
                    await ctx.send("❌ | Nobody is blacklisted!")
                else:
                    await ctx.send(embed=embed)

            except discord.errors.HTTPException as e:
                await ctx.send("❌ | Nobody is blacklisted!")
                raise e
Esempio n. 10
0
 async def list(self, ctx):
     channels = DataManager.read('data/votereact.json')['channels']
     embed = discord.Embed(color=ctx.author.color, title="Channels")
     for channel in channels:
         ch = discord.utils.get(ctx.guild.channels, id=channel)
         embed.add_field(name=ch.name, value=ch.mention, inline=False)
     if channels == []:
         await Formatter.error(ctx, "No votereact channels!")
     else:
         await ctx.send(embed=embed)
Esempio n. 11
0
 async def on_member_join(self, member):
     if test:
         testsbk = discord.utils.get(self.bot.guilds, id=402197486317338625)
         channel = discord.utils.get(testsbk.channels,
                                     id=431944465532321802)
     else:
         mainsbk = discord.utils.get(self.bot.guilds, id=257889450850254848)
         channel = discord.utils.get(mainsbk.channels,
                                     id=257895860757725186)
     message = DataManager.read('data/general.json')['welcome']
     await channel.send(message + f"{member.mention}!")
Esempio n. 12
0
 async def on_member_update(self, before, after):
     try:
         role = discord.utils.get(after.guild.roles, name='Artist')
         if role in after.roles:
             if str(after.id) in DataManager.read('data/artblacklist.json'):
                 await after.remove_roles(role,
                                          reason=f"[Blacklisted user "
                                          f"{after.name}#"
                                          f"{after.discriminator}]")
     except Exception as e:
         raise e
Esempio n. 13
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
Esempio n. 14
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!")
Esempio n. 15
0
 async def artist(self, ctx, member: discord.Member):
     role = discord.utils.get(ctx.guild.roles, name='Artist')
     if not str(member.id) in DataManager.read('data/artblacklist.json'):
         try:
             await member.add_roles(role,
                                    reason=f"[Artist command executed"
                                    f" by:{ctx.author.name}#"
                                    f"{ctx.author.discriminator}]")
             await ctx.send(f"✅ | {member.mention} is now an artist!")
         except Exception as e:
             if ctx.author.id == 286246724270555136:
                 await ctx.send(f"❌ | Ignoring exception in command "
                                f"{ctx.command}:\n```py\n{e}\n```")
             else:
                 await ctx.send("❌ | An error has occured.")
     else:
         ap = DataManager.read('data/artblacklist.json')[str(member.id)]
         if not ap:
             blacklist = DataManager.read('data/artblacklist.json')
             await ctx.send(f"⚠ | This user is Artist role blacklisted! "
                            f"Reason: {blacklist[str(member.id)][1]}")
         else:
             await ctx.send(f"⚠ | This user is Artist role blacklisted!")
Esempio n. 16
0
 async def on_message(self, message):
     keywords = DataManager.read('data/trigger.json')
     ignore = DataManager.read('data/ignorelist.json')['ignore']
     if message.author.id in ignore:
         return
     for id in keywords:
         target = discord.utils.get(self.bot.get_all_members(),
                                    id=int(id)) if message.guild else None
         if keywords[id] == "":
             return
         msg = keywords[id].split('|')
         if (message.guild is not None) and (
             (any(var in message.content.lower()
                  for var in msg)) or (target in message.mentions)):
             if target is None:
                 pass
             else:
                 if message.author.bot:
                     return
                 if message.author == target:
                     return
                 await target.send(
                     f"You were mentioned in {message.channel.mention}:\n",
                     embed=notify(message))
Esempio n. 17
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)
Esempio n. 18
0
    async def on_member_join(self, member):
        global sandbox
        try:
            if not member.guild.id == DataManager.read(
                    'data/bot.json')['SERVER']:
                pass
            else:
                await member.send(
                    "Hello!\nYou're in SbK or Sinbad :crossed_swords: Knights!\nYou should type \`>getcode` in the channel welcome. <#422736408520687617> <-- clickable.\nThen I'll send you some numbers and you can type those in the welcome place!\n:D"
                )

                def find(rolename):
                    for role in member.guild.roles:
                        if role.name == rolename:
                            return role

                r = find(roles)
                await member.add_roles(r)
        except AttributeError:
            pass
Esempio n. 19
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.")
Esempio n. 20
0
    async def addpoints(self, ctx, user: discord.Member, pts):
        errored = True
        gc = gspread.authorize(credentials)
        sheet = gc.open_by_key(key)
        worksheet = sheet.get_worksheet(0)
        try:
            cell = worksheet.find(str(user.id))
            errored = False
        except gspread.exceptions.CellNotFound:
            await ctx.send("❌ | I couldn't find that user...")

        if errored:
            pass
        else:
            a = DataManager.read('data/challenges.json')
            values_list = worksheet.row_values(cell.row)
            newpts = int(values_list[3]) + int(pts)
            col = int(cell.col) + 2
            worksheet.update_cell(cell.row, col, newpts)
            values_list = worksheet.row_values(cell.row)
            for r, v in a.items():
                if newpts >= v:
                    rr = discord.utils.get(user.roles, name=r)
                    if rr is None:
                        role = discord.utils.get(ctx.guild.roles, name=r)
                        rolelog = discord.utils.get(ctx.guild.channels,
                                                    name='challenge-role-logs')
                        await user.add_roles(role)
                        await rolelog.send(f"{user.mention} + **{r}** ({newpts} points!)")
            await ctx.send(f"✅ | Successfully added {pts} "
                           f"points to {user.mention}")
            chan = discord.utils.get(ctx.guild.channels,
                                     name='challenge-tracker')
            if not pts == 0:
                await chan.send(f"{ctx.author.mention} added **{pts}** points "
                                f"to {user.mention}!")
Esempio n. 21
0
    async def addblacklist(self, ctx, member: discord.Member, *reason):
        if reason:
            reason = ' '.join(reason)
        if not str(member.id) in DataManager.read('data/artblacklist.json'):
            if reason:
                asas = [
                    len(DataManager.read('data/artblacklist.json')) + 1, reason
                ]
                DataManager.update('data/artblacklist.json', member.id, asas)
                role = discord.utils.get(ctx.guild.roles, name='Artist')
                check = discord.utils.get(member.roles, name='Artist')
                if check:
                    await member.remove_roles(role,
                                              reason=f"[Blacklisted user"
                                              f"{member.name}"
                                              f"#{member.discriminator}]")

                await ctx.send(f"✅ | Successfully blacklisted"
                               f"{member.name}#{member.discriminator}.")
            else:
                role = discord.utils.get(ctx.guild.roles, name='Artist')
                check = discord.utils.get(member.roles, name='Artist')
                if check:
                    await member.remove_roles(role,
                                              reason=f"[Blacklisted User"
                                              f"""
                                        {member.name}#{member.discriminator}]
                                              """)
                asa = [
                    len(DataManager.read('data/artblacklist.json')) + 1, None
                ]
                DataManager.update('data/artblacklist.json', member.id, asa)
                await ctx.send(f"✅ | Successfully blacklisted `{member.name}"
                               f"#{member.discriminator}``.")
        else:
            await ctx.send("❌ | That user is already blacklisted!")
Esempio n. 22
0
 async def owner(self, ctx, member: discord.Member):
     DataManager.list_update('data/bot.json', 'OWNERS', member.id)
     await ctx.send("Updated owner!")
Esempio n. 23
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!")
Esempio n. 24
0
 async def unblock(self, ctx, member: discord.Member):
     DataManager.list_remove('data/ignorelist.json', 'ignore', member.id)
     await Formatter.success(ctx, f'Successfully unblocked {member.name}')
Esempio n. 25
0
 def leaderboard(self):
     """Returns a list of the highest achievers this week."""
     x = DataManager.read('data/xp.json')
     return sorted(x, key=x.get, reverse=True)
Esempio n. 26
0
import discord
from discord.ext import commands
from __main__ import Checks, DataManager, test

if test == True:
    guild = discord.utils.get(self.bot.guilds, id=402197486317338625)

joining = DataManager.read('data/lockdown.json')[str('joining')]
role = discord.utils.get(
    guild.roles, id=DataManager.read('data/lockdown.json')[str('role')])


class Lockdown:
    def __init__(self, bot):
        self.bot = bot

    @commands.group(name="lockdown", invoke_without_command=True)
    @Checks.is_staff()
    async def lockdown(self, ctx):
        if ctx.invoked_subcommand is None:
            await ctx.send("<:error:436279057416585217>")

    @lockdown.command()
    @Checks.is_staff()
    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
Esempio n. 27
0
 async def ignore(self, ctx, channel: discord.TextChannel):
     DataManager.list_update('data/activity.json', 'ignore-list',
                             channel.id)
     await ctx.send("Updated ignore list!")