Exemplo n.º 1
0
def give_item(item, member):
    items_current = fetch_items(member.id)[0][0]
    if items_current is None:
        items_new = item + "_"
    else:
        items_new = items_current + item + "_"
    sql.execute_query("UPDATE Members SET items = '%s' WHERE UserID = %s" %
                      (items_new, str(member.id)))
Exemplo n.º 2
0
def insert_db_user(member):
    try:
        sql.execute_query("INSERT INTO Members (UserID) VALUES ('%s')" %
                          (member.id))
    except:
        log.warn("User already exists in Database")
        try:
            log.debug(member.name)
        except:
            pass
Exemplo n.º 3
0
 async def give(self, ctx, target: discord.Member = None, amount: int = 0):
     if "Manager" in [role.name for role in ctx.message.author.roles]:
         if target is not None:
             crates_no = \
                 sql.db_query("SELECT crates FROM Members WHERE UserID = %s" % (str(target.id)))[0][0]
             crates_no = crates_no + amount
             sql.execute_query("UPDATE Members SET crates = %s WHERE UserID = %s" % (
                 str(crates_no), str(target.id)))
             await ctx.send("Successfully gave %s **%s** crate(s)" % (target.mention, str(amount)))
     else:
         await ctx.send("**Insufficient Permissions:** This command requires permission rank `MANAGER`")
Exemplo n.º 4
0
    async def open(self, ctx, amount: int = 1):
        crates_no = sql.db_query("SELECT crates FROM Members WHERE UserID = %s" % (str(ctx.author.id)))[0][0]
        if crates_no == 0:
            await ctx.send("**Error:** You don't have any crates to open")
        else:
            if amount > 10:
                await ctx.send(embed=discord.Embed(title="Crates Opening Error",
                                                   description="You're trying to open too many crates, try a smaller number.",
                                                   color=colour.reds))
                return
            elif amount <= 0:
                await ctx.send(embed=discord.Embed(title="Crates Opening Error",
                                                   description="Please don't try to create a black hole and try a bigger number.",
                                                   color=colour.reds))
                return
            # If a user tries to open more crates than they have it'll default to how much they have
            if crates_no < amount:
                amount = crates_no
            # Open crates
            crates = [open_crate(ctx) for _ in range(0, amount)]
            # Take however many crates the user opened
            crates_no = crates_no - amount
            sql.execute_query("UPDATE Members SET crates = %s WHERE UserID = %s" % (str(crates_no), str(ctx.author.id)))
            embed = discord.Embed(description="Opening Crate" if amount == 1 else "Opening %d Crates" % amount)
            embed.set_author(name="Crate")
            msg = await ctx.send(embed=embed)
            await asyncio.sleep(2)
            if amount == 1:
                print(crates)
                embed = discord.Embed(title=crates[0][0], description=crates[0][1], color=crates[0][2])
                embed.set_author(name=crates[0][3])
                await msg.edit(embed=embed)
            else:
                dupe_reward = 0
                description = "You won:\n"
                for c in crates:
                    description += " - " + c[0].strip("You Won:").replace("(Duplicate)", "**(Duplicate +%d XP)**" % c[4])
                    if "Duplicate" in c[0]:
                        dupe_reward += c[4]
                    description += "\n"

                if dupe_reward > 0:
                    description += "\n"
                    description += "You've earned **%d XP** from duplicates" % dupe_reward
                embed = discord.Embed(title="You've successfully opened %d crates!" % amount,
                                      description=description,
                                      colour=colour.primary)
                await msg.edit(embed=embed)
Exemplo n.º 5
0
 async def daily(self, ctx):
     log.debug("%s issued server command %s" %
               (str(ctx.message.author), str(ctx.message.content)))
     current_time = time.time()
     query = sql.db_query(
         "SELECT dailyRewardClaimed, dailyRewardStreak FROM Members WHERE UserID = %s "
         % (str(ctx.author.id)))
     last_advent = query[0][0]
     streak = query[0][1]
     if last_advent < current_time:
         next_advent = current_time + ((60 * 60) * 20)
         sql.execute_query(
             "UPDATE Members SET dailyRewardClaimed = %s WHERE UserID = %s "
             % (str(next_advent), str(ctx.author.id)))
         reward = random.randint(1, 4)
         if reward == 1:
             reward_name = "5000 Exp"
             add_exp(ctx.author.id, 5000)
         if reward == 2:
             reward_name = "$5.00"
             add_coins(ctx.author, float(5.00))
         if reward == 3:
             reward_name = "2 Crates"
             crates_no = sql.db_query(
                 "SELECT crates FROM Members WHERE UserID = %s" %
                 (str(ctx.author.id)))[0][0]
             crates_no = crates_no + 2
             sql.execute_query(
                 "UPDATE Members SET crates = %s WHERE UserID = %s" %
                 (str(crates_no), str(ctx.author.id)))
         if reward == 4:
             reward_name = "3 Crates"
             crates_no = sql.db_query(
                 "SELECT crates FROM Members WHERE UserID = %s" %
                 (str(ctx.author.id)))[0][0]
             crates_no = crates_no + 3
             sql.execute_query(
                 "UPDATE Members SET crates = %s WHERE UserID = %s" %
                 (str(crates_no), str(ctx.author.id)))
         embed = discord.Embed(title="Easter Reward",
                               description="You Won " + reward_name,
                               color=colour.primary)
         await ctx.send(embed=embed)
         new_streak = streak + 1
         sql.execute_query(
             "UPDATE Members SET dailyRewardStreak = %s WHERE UserID = %s "
             % (str(new_streak), str(ctx.author.id)))
     else:
         next_advent = last_advent
         time_difference = next_advent - current_time
         time_difference_string = time_phaser(time_difference)
         embed = discord.Embed(
             title="Error",
             description="You cannot use that command for another **%s**" %
             (time_difference_string),
             color=colour.reds)
         await ctx.send(embed=embed)
Exemplo n.º 6
0
    async def badge(self, ctx, operation, badge, user : discord.Member):
        message = ctx.message
        if "Manager" in [role.name for role in message.author.roles]:
            if operation.upper() == "ADD":
                current_badges = get_profile(str(user.id))[3]
                new_badges = current_badges + badge +" _ _"
                sql.execute_query("UPDATE Members SET Badges = '%s' WHERE UserID = %s" % (new_badges.replace("'", "''"), str(user.id)))
                await message.channel.send(":ok_hand: Successfully added %s to **%s**'s profile!" % (badge, user.name))

            if operation.upper() == "REMOVE":
                badge = badge + " _ _"
                current_badges = get_profile(str(user.id))[3]
                new_badges = current_badges.replace(badge, '')
                sql.execute_query("UPDATE Members SET Badges = '%s' WHERE UserID = %s" % (new_badges.replace("'", "''"), str(user.id)))
                await message.channel.send(":ok_hand: Successfully removed %s from **%s**'s profile!" % (badge, user.name))
        else:
            await ctx.send("**Insufficient Permissions:** This command requires permission rank `MANAGER`")
Exemplo n.º 7
0
def open_crate(ctx):
    # Pick rarity
    chance = random.randint(1, 100)
    if chance <= 50:
        rarity = "COMMON"
        embed_color = 0xFFFFFF
        dupe_reward = 250
    elif 50 < chance <= 75:
        rarity = "UNCOMMON"
        embed_color = 0x55FF55
        dupe_reward = 500
    elif 75 < chance <= 95:
        rarity = "RARE"
        embed_color = 0X5555FF
        dupe_reward = 750
    elif 95 < chance <= 99:
        rarity = "LEGENDARY"
        embed_color = 0xFFAA00
        dupe_reward = 1000
    elif chance == 100:
        rarity = "MYTHIC"
        embed_color = 0xFF5555
        dupe_reward = 0

    # select cosmetic
    if rarity == "MYTHIC":
        title = "You Won: " + "$25.00"
        description = "Some Money to spend on cool things."
        add_balance(ctx.author, float(25.00))
    else:
        items = sql.db_query("SELECT * from cosmetics WHERE cosmetic_rarity = '%s'" % (str(rarity)))
        item = random.choice(items)
        inventory = eval(
            sql.db_query("SELECT cosmetics FROM Members WHERE UserID = %s" % (str(ctx.author.id)))[0][0])
        if item[0] in inventory:
            title = "You Won: " + item[1] + " (Duplicate)"
            description = item[3] + "\nSince you already had this item you've been awarded %s exp" % (str(dupe_reward))
            add_exp(ctx.author.id, dupe_reward)
        else:
            title = "You Won: " + item[1]
            description = item[3]
            inventory.append(int(item[0]))
            sql.execute_query("UPDATE Members SET cosmetics = '%s' WHERE UserID = %s" % (
                str(inventory), str(ctx.author.id)))
    return title, description, embed_color, rarity, dupe_reward  # In this order to prevent confusion with indexes at the embed creation
Exemplo n.º 8
0
    async def cookie(self, ctx, target: discord.Member):
        '''
        Give someone a cookie

        Required Permission: None
        Required Arguments: Mention

        '''
        bal = fetch_balance(ctx.author)
        args = ctx.message.content.split(' ')
        if bal >= 0.01:
            add_balance(ctx.author, -0.01)
            cookie_type = random.choice([
                "just gave you a chocolate chip cookie!",
                "just gave you a otis spunkmeyer cookie!",
                "just gave you a super sized cookie!",
                "just gave you a sainsburys taste the difference cookie!"
            ])
            embed = discord.Embed(
                description="Hey %s, %s %s" %
                (args[1], ctx.message.author.mention, cookie_type),
                color=colour.secondary)
            embed.set_author(name="Cookie")
            embed.set_thumbnail(
                url=
                "https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Oxygen480-apps-preferences-web-browser-cookies.svg/1024px-Oxygen480-apps-preferences-web-browser-cookies.svg.png"
            )
            await ctx.message.channel.send(embed=embed)
            if not target.id == ctx.author.id:
                cookies_no = sql.db_query(
                    "SELECT cookiesReceived FROM Members WHERE UserID = %s" %
                    (str(target.id)))[0][0]
                cookies_no = cookies_no + 1
                sql.execute_query(
                    "UPDATE Members SET cookiesReceived = %s WHERE UserID = %s"
                    % (str(cookies_no), str(target.id)))
        else:
            await ctx.send("%s you do not have sufficient funds for this!" %
                           (ctx.message.author.mention))
Exemplo n.º 9
0
 async def advent(self, ctx):
     current_time = time.time()
     last_advent = sql.db_query(
         "SELECT dailyRewardClaimed FROM Members WHERE UserID = %s " %
         (str(ctx.author.id)))[0][0]
     if last_advent < current_time:
         next_advent = current_time + ((60 * 60) * 20)
         sql.execute_query(
             "UPDATE Members SET dailyRewardClaimed = %s WHERE UserID = %s "
             % (str(next_advent), str(ctx.author.id)))
         reward = random.randint(1, 4)
         if reward == 1:
             reward_name = "1000 Exp"
             add_exp(ctx.author.id, 1000)
         if reward == 2:
             reward_name = "$0.75"
             add_coins(ctx.author, float(0.75))
         if reward == 3:
             reward_name = "1 Crate"
             crates_no = sql.db_query(
                 "SELECT crates FROM Members WHERE UserID = %s" %
                 (str(ctx.author.id)))[0][0]
             crates_no = crates_no + 1
             sql.execute_query(
                 "UPDATE Members SET crates = %s WHERE UserID = %s" %
                 (str(crates_no), str(ctx.author.id)))
         if reward == 4:
             reward_name = "2 Crates"
             crates_no = sql.db_query(
                 "SELECT crates FROM Members WHERE UserID = %s" %
                 (str(ctx.author.id)))[0][0]
             crates_no = crates_no + 2
             sql.execute_query(
                 "UPDATE Members SET crates = %s WHERE UserID = %s" %
                 (str(crates_no), str(ctx.author.id)))
         embed = discord.Embed(title="Advent",
                               description="You Won " + reward_name,
                               color=colour.primary)
         await ctx.send(embed=embed)
     else:
         next_advent = last_advent
         time_difference = next_advent - current_time
         time_difference_string = time_phaser(time_difference)
         embed = discord.Embed(
             title="Error",
             description="You cannot use that command for another **%s**" %
             (time_difference_string),
             color=colour.reds)
         await ctx.send(embed=embed)
Exemplo n.º 10
0
def set_balance_id(user_id, balance):
    sql.execute_query("UPDATE Members SET Balance = %s WHERE UserID = %s" %
                      (str(balance), str(user_id)))
Exemplo n.º 11
0
def set_exp_max(userID, amount):
    sql.execute_query("UPDATE Members SET ExpTotal = %s WHERE UserID = %s" %
                      (str(amount), str(userID)))
Exemplo n.º 12
0
    async def daily(self, ctx):
        current_time = time.time()
        query = sql.db_query(
            "SELECT dailyRewardClaimed, dailyRewardStreak FROM Members WHERE UserID = %s "
            % (str(ctx.author.id)))
        last_advent = query[0][0]
        streak = query[0][1]
        if last_advent < current_time:
            if current_time - last_advent > ((60 * 60) * 24):
                streak = 0
                sql.execute_query(
                    "UPDATE Members SET dailyRewardStreak = %s WHERE UserID = %s "
                    % (str(streak), str(ctx.author.id)))

        if "Supporter" in [role.name for role in ctx.author.roles]:
            multiplier = 2
        else:
            multiplier = 1

        if last_advent < current_time:
            cookie_chance = random.randint(1, 25)
            embed = discord.Embed(
                description="Select your reward by typing the number in chat",
                color=colour.primary)
            embed.set_author(name="Daily Rewards")
            embed.add_field(name="Reward 1",
                            value=str(
                                (1000 + (streak * 10)) * multiplier) + " Exp",
                            inline=False)
            embed.add_field(name="Reward 2",
                            value="$" +
                            str(round(0.10 + (streak * 0.01), 2) * multiplier),
                            inline=False)
            if cookie_chance == 1:
                embed.add_field(name="Reward 3",
                                value="3 Cookies",
                                inline=False)

            embed.set_footer(text="Your current reward streak is: " +
                             str(streak))
            mssg = await ctx.send(embed=embed)
            channel = ctx.channel

            def check(m):
                return m.author.id == ctx.author.id and m.channel == channel

            try:
                msg = await self.client.wait_for('message',
                                                 check=check,
                                                 timeout=60.0)
            except asyncio.TimeoutError:
                embed = discord.Embed(description="No Message Received",
                                      color=colour.reds)
                embed.set_author(name="Daily Reward")
                await mssg.edit(embed=embed)
            else:
                await msg.delete()
                if msg.content == "1":
                    add_exp(ctx.author.id, (1000 + (streak * 10)) * multiplier)
                    embed = discord.Embed(description="You unlocked **" + str(
                        (1000 + (streak * 10)) * multiplier) + " EXP**!",
                                          color=colour.primary)
                    embed.set_author(name="Daily Reward")
                    await mssg.edit(embed=embed)
                    next_advent = current_time + ((60 * 60) * 20)
                    sql.execute_query(
                        "UPDATE Members SET dailyRewardClaimed = %s WHERE UserID = %s "
                        % (str(next_advent), str(ctx.author.id)))
                    new_streak = streak + 1
                    sql.execute_query(
                        "UPDATE Members SET dailyRewardStreak = %s WHERE UserID = %s "
                        % (str(new_streak), str(ctx.author.id)))
                elif msg.content == "2":
                    add_balance(ctx.author,
                                round(0.10 + (streak * 0.01), 2) * multiplier)
                    embed = discord.Embed(
                        description="You unlocked **$" +
                        str(round(0.10 +
                                  (streak * 0.01), 2) * multiplier) + " **!",
                        color=colour.primary)
                    embed.set_author(name="Daily Reward")
                    await mssg.edit(embed=embed)
                    next_advent = current_time + ((60 * 60) * 20)
                    sql.execute_query(
                        "UPDATE Members SET dailyRewardClaimed = %s WHERE UserID = %s "
                        % (str(next_advent), str(ctx.author.id)))
                    new_streak = streak + 1
                    sql.execute_query(
                        "UPDATE Members SET dailyRewardStreak = %s WHERE UserID = %s "
                        % (str(new_streak), str(ctx.author.id)))
                elif msg.content == "3" and cookie_chance == 1:
                    embed = discord.Embed(
                        description="You unlocked **3 Cookies**!",
                        color=colour.primary)
                    embed.set_author(name="Daily Reward")
                    await mssg.edit(embed=embed)
                    cookies_no = sql.db_query(
                        "SELECT cookiesReceived FROM Members WHERE UserID = %s"
                        % (str(ctx.author.id)))[0][0]
                    cookies_no = cookies_no + 3
                    sql.execute_query(
                        "UPDATE Members SET cookiesReceived = %s WHERE UserID = %s"
                        % (str(cookies_no), str(ctx.author.id)))
                else:
                    embed = discord.Embed(description="Invalid Response",
                                          color=colour.reds)
                    embed.set_author(name="Daily Reward")
                    await mssg.edit(embed=embed)
        else:
            next_advent = last_advent
            time_difference = next_advent - current_time
            time_difference_string = time_phaser(time_difference)
            embed = discord.Embed(
                title="Error",
                description="You cannot use that command for another **%s**" %
                (time_difference_string),
                color=colour.reds)
            await ctx.send(embed=embed)
Exemplo n.º 13
0
    async def weekly(self, ctx):
        args = ctx.message.content.split(" ")
        showDetails = False
        if len(args) >= 2 and (
                "Moderator" in [role.name for role in ctx.author.roles]
                or "Manager" in [role.name for role in ctx.author.roles]):
            if args[1].upper() == "DETAILS":
                activity = sql.db_query(
                    "SELECT UserID, weeklyActivity FROM Members WHERE NOT UserID = 472063067014823938 AND NOT UserID = 1 AND NOT UserID = 568905827952361490 ORDER BY weeklyActivity DESC"
                )
                count = 1
                index = 0
                server_total = 0
                for entry in activity:
                    server_total += entry[1]
                lbString = "Server Total: **" + str(
                    server_total) + " Points**\n\n"

                while count < 6:
                    user = discord.utils.get(ctx.guild.members,
                                             id=activity[index][0])
                    if not user == None:
                        lbString += "**" + str(count) + ")** <@" + str(
                            activity[index][0]) + "> - **" + str(
                                balance_formatter(
                                    activity[index][1])) + "** Points\n"
                        count += 1
                    index += 1
                embed = discord.Embed(description=lbString,
                                      color=colour.primary)
                embed.set_author(name="Weekly Activity Leaderboard")
                embed.set_thumbnail(
                    url="https://i.foggyio.uk/varsity_discord.png")
                await ctx.send(embed=embed)
            elif args[1].upper() == "RESET":
                if "Manager" in [role.name for role in ctx.author.roles]:
                    sql.execute_query("UPDATE Members SET weeklyActivity=0")
                    await ctx.send("Reset Weekly Activity Stats")
                    return
        else:
            activity = sql.db_query(
                "SELECT UserID, weeklyActivity FROM Members WHERE NOT UserID = 472063067014823938 AND NOT UserID = 1 AND NOT UserID = 568905827952361490 ORDER BY weeklyActivity DESC"
            )
            count = 1
            index = 0
            server_total = 0
            for entry in activity:
                server_total += entry[1]
            lbString = "Server Total: **" + str(server_total) + " Points**\n\n"
            while count < 6:
                user = discord.utils.get(ctx.guild.members,
                                         id=activity[index][0])
                if not user == None:
                    lbString += "**" + str(count) + ")** <@" + str(
                        activity[index][0]) + ">\n"
                    count += 1
                index += 1

            not_found = True
            i = 1
            index2 = 0
            while not_found:
                user = discord.utils.get(ctx.guild.members,
                                         id=activity[index2][0])
                if not user == None:
                    if activity[index2][0] == ctx.author.id:
                        not_found = False
                        if i >= 6:
                            lbString += "\n**" + str(i) + ")** <@" + str(
                                activity[index2][0]) + ">\n"
                    i += 1
                index2 += 1

            embed = discord.Embed(description=lbString, color=colour.primary)
            embed.set_author(name="Weekly Activity Leaderboard")
            embed.set_thumbnail(url="https://i.foggyio.uk/varsity_discord.png")
            await ctx.send(embed=embed)
Exemplo n.º 14
0
    async def on_message(self, message):
        try:

            def check(m):
                flag = False
                m_split = m.content.translate(
                    {ord(i): None
                     for i in '",.?!;:-_`*\''}).upper().split(" ")
                banned_words = [
                    "NIGGER", "N***A", "AUTISTIC", "RETARD", "RETARDED",
                    "AIDS", "SPASTIC", "SPAZ", "RETARDS"
                ]
                for word in banned_words:
                    if word in m_split:
                        flag = True
                        #print(m.content)
                return flag

            if check(message):
                await message.delete()
                return 0

            message.content = message.content.replace(
                "@!", "@"
            )  #crappy fix for the mention inconsistency between platforms

            if len(message.content) == 0:
                return
            if isinstance(message.channel, discord.DMChannel):
                log.info("Ignoring Direct Message From %s: %s" %
                         (str(message.author), str(message.content)))
                return
            mSplit = message.content.split()
            mList = []
            for word in mSplit:
                user = discord.utils.get(message.guild.members,
                                         mention=word.replace("@",
                                                              "@!").replace(
                                                                  "!!", "!"))
                if not user is None:
                    if not user.nick is None:
                        word = word.replace("@", "@!").replace("!!", "!")
                mList.append(word)
            message.content = " ".join(mList)

            if message.content.upper().startswith("V!UPDATE"):
                await message.channel.send("Syncing DB")
                for member in message.guild.members:
                    insert_db_user(member)
                await message.channel.send("Completed DB Sync")

            args = message.content.split(" ")

            if message.content[0] == "$":
                message.content = message.content.replace("$", "!tag ")
                await self.client.process_commands(message)

            if args[0].lower() in self.client.disabled_commands:
                await error("[423] This command is currently disabled",
                            message.channel)
                return False
            channel = message.channel

            if message.content.upper().startswith("!ENTER"):
                if "Manager" in [role.name for role in message.author.roles
                                 ] and self.client.raffles:
                    embed = discord.Embed(
                        title="Raffle",
                        description=
                        "Sorry %s, you are not allowed to enter raffles." %
                        (message.author.mention),
                        color=colour.reds)
                    await message.channel.send(embed=embed)
                elif self.client.raffles and not message.author.name in self.client.enteries:
                    self.client.enteries.append(message.author.name)
                    embed = discord.Embed(
                        title="Raffle",
                        description="**%s** has been entered!" %
                        (message.author.name),
                        color=0x00ff73)
                    await message.channel.send(embed=embed)
                elif self.client.raffles:
                    embed = discord.Embed(
                        title="Raffle",
                        description=
                        "Hey %s! You can only enter into the same raffle once!"
                        % (message.author.mention),
                        color=colour.reds)
                    await message.channel.send(embed=embed)

            if message.content.upper().startswith("!VOTE"):
                if self.client.polls and not message.author.name in self.client.polls_enteries:
                    args = message.content.split(" ")
                    try:
                        choice = int(args[1])
                        self.client.polls_votes[choice - 1] += 1
                    except (IndexError, TypeError, ValueError):
                        embed = discord.Embed(
                            title="Poll",
                            description="Hey %s! That is not a valid option!" %
                            (message.author.mention),
                            color=colour.reds)
                        await message.channel.send(embed=embed)
                        return

                    self.client.polls_enteries.append(message.author.name)
                    embed = discord.Embed(
                        title="Poll",
                        description="**%s** you have voted for %s" %
                        (message.author.name,
                         self.client.polls_options[choice - 1]),
                        color=0x00ff73)
                    await message.channel.send(embed=embed)
                elif self.client.polls:
                    embed = discord.Embed(
                        title="Poll",
                        description="Hey %s! You can only vote once" %
                        (message.author.mention),
                        color=colour.reds)
                    await message.channel.send(embed=embed)

            if message.content.upper().startswith("!SUDO"):
                if message.author.id == 345514405775147023:
                    args = message.content.split()
                    target = discord.utils.get(message.guild.members,
                                               mention=args[1])
                    channel = self.client.get_channel(int(args[2]))
                    contents = " ".join(args[3:])
                    message.content = contents
                    message.author = target
                    message.channel = channel
                    await self.client.process_commands(message)

            if message.guild == None:
                return

            words = message.content.split()
            if not str(
                    message.author.id
            ) in self.client.ignore_list and not str(
                    message.channel.id
            ) in self.client.ignore_list and not message.author.id in self.client.cooldown and len(
                    words) > 4 and len(message.content) > 16:
                multiplier = sql.db_query(
                    "SELECT Level FROM Members WHERE UserID = 1")[0][0]
                if "Supporter" in [role.name for role in message.author.roles]:
                    multiplier = multiplier + 0.5
                bal = sql.db_query(
                    "SELECT Balance FROM Members WHERE UserID = %s" %
                    (str(message.author.id)))[0][0]
                if not "Manager" in [
                        role.name for role in message.author.roles
                ]:
                    currentWeeklyPoints = sql.db_query(
                        "SELECT weeklyActivity from Members WHERE UserID = %s"
                        % (str(message.author.id)))[0][0]
                    newWeeklyPoints = currentWeeklyPoints + 1
                    sql.execute_query(
                        "UPDATE Members set weeklyActivity = %s WHERE UserID = %s"
                        % (str(newWeeklyPoints), str(message.author.id)))

                level = get_profile(message.author.id)[1]
                self.client.cooldown.append(message.author.id)
                exp_add = int(round(random.randint(15, 25) * multiplier, 0))
                add_exp(message.author.id, exp_add)
                channel = self.client.get_channel(547120498568331267)
                await check_level_up(message.author.id, message.guild,
                                     message.channel)
                await asyncio.sleep(60)
                try:
                    self.client.cooldown.remove(message.author.id)
                except ValueError:  #some people aren't always on cooldown
                    pass

            def check(m):
                flag = False
                m_split = m.content.translate(
                    {ord(i): None
                     for i in '",.?!;:-_`*\''}).upper().split(" ")
                banned_words = [
                    "F**K", "F*****G", "DICK", "BOLLOCK", "F***S", "AIDS",
                    "BOLLOCKS", "F****D", "W***E", "BASTARD", "SHIT",
                    "S******G", "C**T", "WANKER", "BASTARD", "BELLEND",
                    "N***A", "NIGGER", "PISS", "PISSING", "C**T", "CUNTS",
                    "WANKERS", "RETARDS", "RETARD", "RETARDED", "F****T",
                    "FKING", "FK", "CRAP", "PUSSY", "PENIS", "C**K"
                ]
                for word in banned_words:
                    if word in m_split:
                        flag = True

                return flag

        except Exception as e:
            log.error("Error Processing Message From %s - Error: %s" %
                      (str(message.author), str(e)))
Exemplo n.º 15
0
    async def shop(self, ctx):
        args = ctx.message.content.split()
        if len(args) == 1:
            shop_string = """1) **Custom Tag** -  __$15.00__
A custom role for you, permanent, no hoist or color

2) **Custom Profile Colour** -  __$10.00__
Stand out with a custom profile border. (Once a colour is chosen you cannot change it again without purchasing another)

3) **1 Week Custom Role** - __$5.00__
Aqua Coloured role with a name of your choice

4) **1000 Exp** - __$2.50__
Help boost your level with this exp bonus

5) **1 Crate** - __$1.00__
Open the crate to see what's inside
            """
            shopEm = discord.Embed(description="List of Purchasable Items\n" +
                                   shop_string,
                                   color=colour.primary)
            shopEm.set_author(name="Shop")
            shopEm.add_field(
                name="How to use the shop",
                value=
                "You can obtain balance through being the most active each week, once you have enough balance to purchase an item on the shop, type !shop buy <item> <quantity>",
                inline=False)
            await ctx.send(embed=shopEm)
        else:
            if args[1].upper() == "BUY":
                bal = fetch_balance(ctx.author)
                if len(args) > 3:
                    quantity = int(args[3])
                else:
                    quantity = 1
                if args[2] == "1":
                    if bal >= 15.00:
                        add_balance(ctx.author, -15.00)
                        em = discord.Embed(
                            description=
                            "Please contact a member of staff to request your tag!",
                            color=colour.primary)
                        em.set_author(name="Purchase Successful")
                        await ctx.send(embed=em)
                    else:
                        await discord_error("Insufficent funds", ctx)
                elif args[2] == "2":
                    if bal >= 10.00:
                        add_balance(ctx.author, -10.00)
                        em = discord.Embed(
                            description=
                            "Please contact a member of staff to request your profile colour!",
                            color=colour.primary)
                        em.set_author(name="Purchase Successful")
                        await ctx.send(embed=em)
                    else:
                        await discord_error("Insufficent funds", ctx)

                elif args[2] == "3":
                    if bal >= 5.00:
                        add_balance(ctx.author, -5.00)
                        em = discord.Embed(
                            description=
                            "Please contact a member of staff to request your role!",
                            color=colour.primary)
                        em.set_author(name="Purchase Successful")
                        await ctx.send(embed=em)
                    else:
                        await discord_error("Insufficent funds", ctx)
                elif args[2] == "4":
                    if bal >= 2.50 * float(quantity):
                        add_balance(ctx.author, -2.50 * float(quantity))
                        em = discord.Embed(
                            description="You have been given **%s** exp!" %
                            (str(1000 * quantity)),
                            color=colour.primary)
                        em.set_author(name="Purchase Successful")
                        await ctx.send(embed=em)
                        add_exp(ctx.author.id, 1000 * quantity)
                        await check_level_up(ctx.author.id, ctx.guild,
                                             ctx.channel)
                    else:
                        await discord_error("Insufficent funds", ctx)

                elif args[2] == "5":
                    if bal >= 1.00 * float(quantity):
                        crates_no = sql.db_query(
                            "SELECT crates FROM Members WHERE UserID = %s" %
                            (str(ctx.author.id)))[0][0]
                        if crates_no + quantity > 15:
                            await discord_error(
                                "You cannot have more than 15 crates in your inventory",
                                ctx)
                        else:
                            add_balance(ctx.author, -1.00 * float(quantity))
                            em = discord.Embed(
                                description=
                                "You have been given **%s** crate(s)!" %
                                (str(1 * quantity)),
                                color=colour.primary)
                            em.set_author(name="Purchase Successful")
                            await ctx.send(embed=em)
                            crates_no = crates_no + 1 * quantity
                            sql.execute_query(
                                "UPDATE Members SET crates = %s WHERE UserID = %s"
                                % (str(crates_no), str(ctx.author.id)))
                    else:
                        await discord_error("Insufficent funds", ctx)
                else:
                    await discord_error(
                        "Invalid Item! Use `!shop` to view list of items", ctx)
Exemplo n.º 16
0
    async def cosmetics(self, ctx, operand=None, *, cosmetic=None):
        if operand is None:
            #get inventory
            cosmetics_all = sql.db_query("SELECT cosmetic_id FROM cosmetics")
            cosmetics_total = len(cosmetics_all)
            inventory = eval(
                sql.db_query(
                    "SELECT cosmetics FROM Members WHERE UserID = %s" %
                    (str(ctx.author.id)))[0][0])
            inventory_size = len(inventory)
            if len(inventory) == 0:
                embed = discord.Embed(
                    title="Inventory",
                    description="You have nothing in your inventory",
                    color=reds)
                await ctx.send(embed=embed)
            else:
                inventory_string = ""
                count = 1
                for item_id in inventory:
                    cosmetic = sql.db_query(
                        "SELECT * from cosmetics WHERE cosmetic_id = %s" %
                        (str(item_id)))[0]
                    inventory_string += str(count) + ") **" + cosmetic[
                        2] + "** " + cosmetic[1] + "\n"
                    count = count + 1
                embed = discord.Embed(title="Inventory",
                                      description=inventory_string,
                                      color=colour.secondary)
                embed.set_footer(text="%s/%s Cosmetics Unlocked" %
                                 (str(inventory_size), str(cosmetics_total)))
                await ctx.send(embed=embed)

        elif operand.upper() == "SHOW" or operand.upper() == "DISPLAY":
            index = int(cosmetic)
            inventory = eval(
                sql.db_query(
                    "SELECT cosmetics FROM Members WHERE UserID = %s" %
                    (str(ctx.author.id)))[0][0])
            inventory_size = len(inventory)
            try:
                item_id = inventory[index - 1]
            except IndexError:
                await ctx.send(
                    "**Error:** You do not own a cosmetic under that id")
                return
            item = sql.db_query(
                "SELECT * from cosmetics WHERE cosmetic_id = %s" %
                (str(item_id)))[0]
            if item[2] == "COMMON":
                embed_color = 0xFFFFFF
            elif item[2] == "UNCOMMON":
                embed_color = 0x55FF55
            elif item[2] == "RARE":
                embed_color = 0X5555FF
            elif item[2] == "LEGENDARY":
                embed_color = 0xFFAA00
            elif item[2] == "SPECIAL":
                embed_color = 0xFF55FF
            elif item[2] == "FESTIVE":
                embed_color = 0x00AA00
            embed = discord.Embed(title=item[1],
                                  description=item[3],
                                  color=embed_color)
            embed.set_author(name=item[2])
            if not item[4] is None:
                embed.set_thumbnail(url=item[4])
            embed.set_footer(text="Item Owned By: " + str(ctx.author))
            await ctx.send(embed=embed)

        elif operand.upper() == "CREATE":
            if "Manager" in [role.name for role in ctx.author.roles]:
                cosmetic_args = "".join(cosmetic).split("|")
                title = cosmetic_args[0]
                rarity = cosmetic_args[1].upper()
                description = cosmetic_args[2]
                if len(cosmetic_args) >= 4:
                    image_url = cosmetic_args[3]
                else:
                    image_url = None
                if rarity == "COMMON":
                    embed_color = 0xFFFFFF
                elif rarity == "UNCOMMON":
                    embed_color = 0x55FF55
                elif rarity == "RARE":
                    embed_color = 0X5555FF
                elif rarity == "LEGENDARY":
                    embed_color = 0xFFAA00
                elif rarity == "SPECIAL":
                    embed_color = 0xFF55FF
                else:
                    await ctx.send("**Error:** Invalid Rarity")
                    return
                embed = discord.Embed(title=title,
                                      description=description,
                                      color=embed_color)
                embed.set_author(name=rarity)
                if len(cosmetic_args) >= 4:
                    embed.set_thumbnail(url=image_url)

                await ctx.send(content="Confirm Creation Of Cosmetic (y/n)",
                               embed=embed)

                def check(m):
                    return m.channel == ctx.message.channel and m.author == ctx.message.author

                msg = await self.client.wait_for('message', check=check)
                if msg.content.upper() == "Y":
                    if image_url is None:
                        sql.execute_query(
                            "INSERT INTO cosmetics (cosmetic_name, cosmetic_rarity, cosmetic_description) VALUES ('%s', '%s', '%s')"
                            % (title.replace("'", "''"), rarity,
                               description.replace("'", "''")))
                    else:
                        sql.execute_query(
                            "INSERT INTO cosmetics (cosmetic_name, cosmetic_rarity, cosmetic_description, cosmetic_image_url) VALUES ('%s', '%s', '%s', '%s')"
                            % (title.replace("'", "''"), rarity,
                               description.replace(
                                   "'", "''"), image_url.replace("'", "''")))
                    await ctx.send("Cosmetic Created")
                else:
                    await ctx.send("_Cancelled_")
            else:
                await ctx.send(
                    "**Error:** Permission Denied. This command requires permission rank `MANAGER`"
                )
        else:
            await ctx.send("**Error:** Invalid Usage")
Exemplo n.º 17
0
def level_up(userID, level):
    sql.execute_query("UPDATE Members SET Level = %s WHERE UserID = %s" %
                      (str(level), str(userID)))
Exemplo n.º 18
0
 async def tag(self, ctx):
     args = ctx.message.content.split()
     if args[1].upper() == "CREATE":
         if get_profile(ctx.author.id)[1] >= 30 or "Moderator" in [
                 role.name for role in ctx.message.author.roles
         ] or "Manager" in [role.name for role in ctx.message.author.roles]:
             tagContent = " ".join(args[3:]).replace("'", "''")
             print(tagContent)
             tagSubmitter = str(ctx.message.author)
             tagName = args[2]
             try:
                 sql.execute_query(
                     "INSERT INTO tags (name, content, submittedBy) VALUES ('%s', '%s', '%s')"
                     % (tagName.replace(
                         "'", "''"), tagContent.replace(
                             "'", "''"), tagSubmitter.replace("'", "''")))
                 await ctx.send("Tag successfully created")
             except:
                 await ctx.send("A tag already exists with that name")
         else:
             await ctx.send("You are not allowed to create tags yet!")
     elif args[1].upper() == "CREATE_IMG":
         if get_profile(ctx.author.id)[1] >= 30 or "Moderator" in [
                 role.name for role in ctx.message.author.roles
         ] or "Manager" in [role.name for role in ctx.message.author.roles]:
             tagContent = " ".join(args[3:]).replace("'", "''")
             tagSubmitter = str(ctx.message.author)
             tagName = args[2]
             try:
                 sql.execute_query(
                     "INSERT INTO tags (name, content, submittedBy, isImage) VALUES ('%s', '%s', '%s', 1)"
                     % (tagName.replace(
                         "'", "''"), tagContent.replace(
                             "'", "''"), tagSubmitter.replace("'", "''")))
                 await ctx.send("Tag successfully created")
             except:
                 await ctx.send("A tag already exists with that name")
         else:
             await ctx.send("You are not allowed to create tags yet!")
     elif args[1].upper() == "DELETE":
         if "Moderator" in [
                 role.name for role in ctx.message.author.roles
         ] or "Manager" in [role.name for role in ctx.message.author.roles]:
             tagName = args[2]
             tag = sql.db_query("SELECT name FROM tags WHERE name = '%s'" %
                                (tagName.replace("'", "''")))
             if len(tag) == 0:  # tag does not exists
                 await ctx.send("There is no tag with that name")
             else:
                 sql.execute_query("DELETE FROM tags WHERE name = '%s'" %
                                   (tagName.replace("'", "''")))
                 await ctx.send("Tag has been successfully deleted")
     else:
         tagName = args[1]
         tag = sql.db_query(
             "SELECT name, content, submittedBy, isImage FROM tags WHERE name = '%s'"
             % (tagName.replace("'", "''")))
         if not len(tag) == 0:
             if tag[0][3] == 1:
                 embed = discord.Embed(title=tag[0][0],
                                       color=colour.secondary)
                 embed.set_image(url=tag[0][1])
             else:
                 embed = discord.Embed(title=tag[0][0],
                                       description=tag[0][1],
                                       color=colour.secondary)
             embed.set_footer(text="Submitted By: " + tag[0][2])
             await ctx.send(embed=embed)
         else:
             await ctx.send("That tag does not exist")