Ejemplo n.º 1
0
async def charter(ctx, user_id, get=False):
    await ctx.trigger_typing()
    user = users_db.find_one(user_id=user_id)

    try:
        chart_url = user["chart_url"]
        if chart_url == "":
            raise Exception
        else:
            if ctx.author.color.value == 0x000000:
                color = discord.Colour(0x9ebbdb)
            else:
                color = ctx.author.color

            embed = discord.Embed(color=color).set_image(url=chart_url)
            await ctx.send(content=ctx.author.mention, embed=embed)
    except:
        if get:
            await ctx.send(
                f"{ctx.author.mention} **Error:** The specified user doesn't seem to have set a chart."
            )
            return
        await ctx.send(
            f"{ctx.author.mention} **Error:** You haven't seemed to have set a chart. Use the `submit` command to set one."
        )
Ejemplo n.º 2
0
async def parse(context, chart_type, usage, *args, get=False):
    await context.trigger_typing()

    size = "3x3" # 3x3 by default
    appropriate_sizes = ["3x3", "4x4", "5x5", "2x6"]
    captions = True

    if len(args) >= 1:
        if args[0] in appropriate_sizes:
            size = args[0]
            if len(args) >= 2:
                if args[1] == "-nc":
                    captions = False

        elif args[0] == "-nc": # no captions flag
            captions = False
        
        else:
            pass
    
    user = users_db.find_one(user_id=context.author.id)
    if user is None:
        await context.send(f"{context.author.mention} **Error:** You haven't set a last.fm username yet! Use the `set` command to set your username.")
        return
    
    message_content = context.message.author.mention

    try:
        chart = await get_chart(user["username"], chart_type, size, nc=captions)
        await context.send(content=message_content, file=discord.File(fp=chart,filename="chart.png"))
    except Exception as e:
        await context.send(general_error)
        raise e
Ejemplo n.º 3
0
    async def fmyt(self, ctx):
        await ctx.trigger_typing()
        user = users_db.find_one(user_id=ctx.author.id)

        if user is None:
            await ctx.send(f"{ctx.author.mention} **Error:** You haven't set a last.fm username yet! Use the `set` command to set your username.")
            return
        
        scrobbles = Scrobbles(username=user["username"])

        await ctx.send(fmyt(scrobbles.recent_scrobble))
Ejemplo n.º 4
0
    async def recent(self, ctx):
        await ctx.trigger_typing()
        _usage = "usage: `last <number, 0-100>`"
        
        user = users_db.find_one(user_id=ctx.author.id)

        if user is None:
            await ctx.send(f"**Error:** You haven't set a last.fm username yet! Use the `set` command to set your username.")
            return
        
        await ctx.send(embed=recent_embed(user["username"], ctx))
Ejemplo n.º 5
0
    async def fm(self, ctx):
        await ctx.trigger_typing()
        user = users_db.find_one(user_id=ctx.author.id)

        if user is None:
            await ctx.send(f"{ctx.author.mention} **Error:** You haven't set a last.fm username yet! Use the `set` command to set your username.")
            return
        
        scrobbles = Scrobbles(username=user["username"])
        embed = await embedify(scrobbles, ctx)

        msg = await ctx.send(embed=embed)

        # for the reaction functionality you MUST specify emojis within your server in this list, or at least a server that the current instance of the bot is in.
        emojis = [':bigW:682714792762277908', ':bigL:682714792808808512']

        reactions = False

        if servers_db.find_one(server_id=ctx.guild.id, reactions=True) is not None:
            reactions = True
        
        if reactions is True:
            for emoji in emojis:
                await msg.add_reaction(emoji)
Ejemplo n.º 6
0
async def profiler(ctx, member, get=False):
    await ctx.trigger_typing()
    user = users_db.find_one(user_id=member.id)

    try:
        lastfm = user["username"]
    except:
        if get:
            await ctx.send(
                f"{ctx.author.mention} **Error:** It seems this user doesn't have enough data to generate a profile."
            )
            return
        await ctx.send(
            f"{ctx.author.mention} **Error:** It seems you don't have enough data to generate a profile. Use `!set` to set a last.fm name to fix this."
        )
        return

    scrobbles = Scrobbles(lastfm)
    userobj = FMUser(lastfm)
    avatar = userobj.avatar

    if avatar == "":
        avatar = member.avatar_url

    recent_scrobble = f"{scrobbles.recent_scrobble.name} - {scrobbles.recent_scrobble.artist}"
    playcount = userobj.playcount

    if ctx.author.color.value == 0x000000:
        color = discord.Colour(0x9ebbdb)
    else:
        color = ctx.author.color

    embed = discord.Embed(
        title=f"{member.name}#{member.discriminator}",
        description=f"Total Scrobbles: **{playcount}**",
        color=color  # i thought this would be cute
    )
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(
        text=f"Recently Played: {recent_scrobble}",
        icon_url=scrobbles.recent_scrobble.image,
    )
    embed.set_author(name=f"last.fm", icon_url=avatar, url=scrobbles.user_url)
    try:
        rym = user["rym"]
        if rym is not None:
            embed.add_field(name="RateYourMusic",
                            value=f"https://rateyourmusic.com/~{rym}",
                            inline=False)
    except:
        pass
    try:
        spotify = user["spotify"]
        if spotify is not None:
            embed.add_field(name="Spotify",
                            value=f"https://open.spotify.com/user/{spotify}",
                            inline=False)
    except:
        pass

    await ctx.send(embed=embed)