コード例 #1
0
    async def avatar(self, msg, *, inp=None):

        member = getuser(self.client, inp)

        avatarurl = member.avatar_url

        await msg.send(avatarurl)
コード例 #2
0
    async def spotify(self, msg, *, inp=None):
        def chop_microseconds(delta):
            return delta - datetime.timedelta(microseconds=delta.microseconds)

        member = getuser(self.client, inp)

        for activity in member.activities:

            if isinstance(activity, Spotify):
                dur = chop_microseconds(activity.duration)
                artist = activity.artist.split(';')[0]
                query = request_song_info(artist, activity.title.split("(")[0])
                try:
                    genius = f'[Lyrics](https://genius.com{query.json()["response"]["hits"][0]["result"]["path"]})'
                except:
                    genius = "Failed to find Lyrics!"

                emb = discord.Embed(
                    title=f'{activity.title}',
                    description=
                    f'By **{activity.artist}** on **{activity.album}**',
                    colour=activity.colour,
                    timestamp=activity.created_at)

                emb.set_thumbnail(url=activity.album_cover_url)
                emb.add_field(name='Duration', value=f'{dur}')
                emb.add_field(name="Genius", value=genius)
                emb.set_footer(text=f'Started listening')

                await msg.channel.send(embed=emb)
                return
コード例 #3
0
    async def boop(self, msg, *, inp=None):

        member = getuser(self.client, inp)

        if msg.author == member:
            await msg.channel.send('thou shall not boop thyselef')
            return

        prefix = blutapi.getprefix(msg.guild)

        if msg.message.content.startswith(f'{prefix}bab'):
            await msg.channel.send(f'✅ Succesfully Babbed `{member.name}`!')
        else:
            await msg.channel.send(f'✅ Succesfully Booped `{member.name}`!')
コード例 #4
0
ファイル: levels.py プロジェクト: IsraelAristide/Blutonium
    async def levels(self, ctx, glbl=None):

        if glbl is None:
            levels = query_database(
                f"SELECT userid,currentlevel,currentxp,requiredxp FROM levels WHERE guildid = {ctx.guild.id} ORDER BY currentlevel DESC, currentxp DESC LIMIT 10"
            )
            emb = discord.Embed(title=f'{ctx.guild} Leaderboard',
                                timestamp=datetime.datetime.now(
                                    tz=pytz.timezone('US/Eastern')),
                                colour=0x36393F)
        if glbl == 'global':
            emb = discord.Embed(title=f'Global Leaderboard',
                                timestamp=datetime.datetime.now(
                                    tz=pytz.timezone('US/Eastern')),
                                colour=0x36393F)
            levels = query_database(
                f"SELECT userid,currentlevel,currentxp,requiredxp FROM levels ORDER BY currentlevel DESC, currentxp DESC LIMIT 10"
            )

        emb.set_thumbnail(url=ctx.guild.icon_url)

        q = 1

        for x in levels:

            user = getuser(self.client, x[0])

            if x[1] == 0:
                pass
            else:
                try:
                    emb.add_field(
                        name=f'#{q} - Level {x[1]} | {x[2]}/{x[3]}xp ',
                        value=f"{user.mention}",
                        inline=False)
                except:
                    emb.add_field(
                        name=f'#{q} - Level {x[1]} | {x[2]}/{x[3]}xp ',
                        value=f"{user}",
                        inline=False)

            q += 1

        await ctx.send(embed=emb)
コード例 #5
0
    async def pp(self, ctx, *, usr=None):

        user = getuser(self.client, usr)

        length = randrange(1, 25)

        pp = "8" + ("=" * length) + "D"

        if length > 22:
            lens = "Too long to measure"
            pp = "8====================================================================================D"
        else:
            lens = f'{length} inches'

        if user.id == Setup.ownerid:
            lens = "too long to measure"
            pp = "8=========================================================================================D"

        emb = discord.Embed(title=f"{user}'s pp length'")

        emb.add_field(name=lens, value=f"**{pp}**")

        await ctx.channel.send(embed=emb)
コード例 #6
0
    async def gay(self, msg, *, inp=None):
        owner = Setup.ownerid
        bot = self.client.user.id
        chance = randrange(0, 2)

        member = getuser(self.client, inp)

        if msg.author == member:
            await msg.channel.send('lmao u just called urslef gey')
            return

        if str(member.id) == owner:
            await msg.channel.send('No u')
            return

        if str(member.id) == bot:
            await msg.channel.send('No u')
            return

        if chance:
            await msg.channel.send(
                f'Hey <@{member.id}> {msg.author.name} Thinks ur mega gey ')
        else:
            await msg.channel.send('No u')
コード例 #7
0
ファイル: levels.py プロジェクト: IsraelAristide/Blutonium
    async def rank(self, ctx: commands.Context, *, user=None):

        support = get(self.client.guilds, id=629436501964619776)
        emoji = get(support.emojis, name="Blutonium_loading")
        emoji2 = get(support.emojis, name="BlutoX")
        emb = discord.Embed(title=f'{emoji} Generating rank card...')

        msg = await ctx.send(embed=emb)

        colors = (('green', '#27d600'), ('blue', '#0064d6'),
                  ('red', '#e30000'), ('white', '#ffffff'),
                  ('black', '#000000'), ('gold', '#ffd500'),
                  ('pink', '#ff75fa'), ('purple', '#8400ff'))
        try:

            user = getuser(self.client, user)
            leveldata = getleveldata(user, ctx.guild)[0]

            masksize = (700, 700)
            mask = Image.new('L', masksize, 0)

            Maskdraw = ImageDraw.Draw(mask)
            Maskdraw.ellipse((0, 0) + masksize, fill='#fff')

            mask = ImageOps.fit(mask, (160, 160))

            aurl = '.'.join(str(user.avatar_url).split('.')[:3]) + '.png'

            pfp = requests.get(aurl)
            link = getbackground(user)

            print(link)

            TINT_COLOR = (0, 0, 0)
            TRANSPARENCY = .60
            OPACITY = int(255 * TRANSPARENCY)

            accent = getaccent(user)

            if accent is None:
                accent = '#FFF'

            for x in colors:

                if accent == x[0]:
                    accent = x[1]

            if ctx.guild.id == 264445053596991498:
                image = requests.get(
                    'https://img.wallpapersafari.com/desktop/1920/1080/89/4/6KjDH9.jpg'
                )
            else:
                try:
                    image = requests.get(link)
                except:
                    image = requests.get(
                        'https://img.wallpapersafari.com/desktop/1920/1080/89/4/6KjDH9.jpg'
                    )

            profile = Image.open(BytesIO(pfp.content))
            circular = ImageOps.fit(profile, mask.size)
            circular.putalpha(mask)

            circular = circular.convert('RGBA')
            #image = Image.new('RGBA', (700,200), '#424242')
            image = Image.open(BytesIO(image.content))
            #image = image.resize((700,200))
            image = ImageOps.fit(image, (700, 200))

            #draw.rectangle((10,10,690,190),fill=(0,0,0,200), outline='#fff',width=3)

            rec = Image.new('RGBA', image.size, TINT_COLOR + (0, ))
            drew = ImageDraw.Draw(rec)
            drew.rectangle((10, 10, 690, 190), fill=TINT_COLOR + (OPACITY, ))

            image = image.convert('RGBA')
            image = Image.alpha_composite(image, rec)

            draw = ImageDraw.Draw(image)

            font = ImageFont.truetype(os.path.join('fonts', 'arial.ttf'), 32)
            font2 = ImageFont.truetype(os.path.join('fonts', 'arial.ttf'), 18)
            font3 = ImageFont.truetype(os.path.join('fonts', 'arial.ttf'), 25)

            image.paste(circular, (20, 20, 180, 180), mask=mask)
            draw.text((200, 50),
                      f'{user}',
                      align='center',
                      font=font,
                      fill=accent)

            text = gettext(user)

            if text is None:
                text = " "

            text = purgoclient.retrieve_filtered_text(text)

            draw.text((200, 85),
                      f'{text}',
                      align='center',
                      font=font3,
                      fill=accent)

            draw.text((548, 145),
                      f'{leveldata[3]} / {leveldata[4]}xp',
                      align='center',
                      font=font2,
                      fill=accent)
            draw.text((200, 145),
                      f'Level {leveldata[2]}',
                      align='center',
                      font=font2,
                      fill=accent)

            recbox = (200, 120, 630, 140)

            levelpercentage = round(((leveldata[3] / leveldata[4]) * 100))

            fill = ((levelpercentage * 430) / 100) + 200

            recboxfill = (200, 120, fill, 140)
            draw.rectangle(recbox)
            draw.rectangle(recboxfill, fill=accent)
        except Exception as err:

            if user is None:
                error = 'User not found!'
            else:
                error = err

            emb = discord.Embed(title=f'{emoji2} Rank card Failed: {error}')
            await msg.edit(embed=emb)

        path = f"/media/home/FS2/WEB/blutopia.ca/img/blutonium/{ctx.guild.id}/{user.id}.png"
        image.save(path, format='PNG')

        link = f'https://img.blutopia.ca/blutonium/{ctx.guild.id}/{user.id}.png'

        req = requests.get(link)

        img = BytesIO(req.content)
        img.name = f"{user.id}.png"

        file = discord.File(img)

        await msg.delete()
        await ctx.send(file=file)