Exemple #1
0
async def check_punishments(guild):
    # iterate through each punishment, ignore if no expiration
    for user in functions.get_data("SELECT * FROM punishments", ()):
        user_id = user[0]
        for punishment in range(1, 4):
            if not user[punishment]:
                continue

            # if expired, replace punishment expiration
            try:
                if int(time()) >= float(user[punishment]):
                    punish_type = data.punishment_names[punishment]
                    functions.set_data(
                        f"UPDATE punishments SET {punish_type + 'End'} = NULL WHERE userId = (?)",
                        (user_id, ))

                    # find user, get associated role, remove and dm user
                    target = guild.get_member(int(user_id))
                    role = guild.get_role(data.punishment_roles[punish_type])
                    await target.remove_roles(role)
                    await functions.send_embed(
                        target, "ScriptersCF",
                        f"Your **{punish_type}** has expired at ScriptersCF.")
            except:
                0

        # if user has no active punishments, remove row from database
        if not any(user[1:]):
            functions.set_data("DELETE FROM punishments WHERE userId = (?)",
                               (user_id, ))
Exemple #2
0
async def stats(message):
    # get user's current stats to display
    user_data = functions.get_data(f"SELECT * FROM scores WHERE userId = (?)",
                                   (str(message.author.id), ))

    response = await functions.get_user_embed(message.author, user_data[1],
                                              False, False)
    await message.channel.send(embed=response)
Exemple #3
0
async def stats(message):
    # get user's current stats to display
    user_data = functions.get_data(f"SELECT * FROM scores WHERE userId = (?)",
                                   (str(message.author.id), ))

    # format user's stats
    await functions.send_embed(
        message.channel, "Stats", f"""**User:** <@{message.author.id}>
        **Level:** {user_data[2]}
        **Points:** {user_data[1]}""")