Beispiel #1
0
    async def fakequote(self, ctx, user: Optional[Member], *, message):
        now = datetime.now()
        user = user or ctx.author

        font = ImageFont.truetype("fonts/Whitney-Medium.ttf", 22, encoding="unic")
        fontsmall = ImageFont.truetype("fonts/Whitney-Medium.ttf", 16, encoding="unic")
        fontnormal = ImageFont.truetype("fonts/Whitney-Medium.ttf", 20, encoding="unic")
        fontchannel = ImageFont.truetype("fonts/Whitney-Medium.ttf", 16, encoding="unic")

        userchar = font.getsize(user.name)[0]
        color = (255, 255, 255) if (user.color.to_rgb() == (0, 0, 0)) else Misc.hex_to_rgb(str(user.color))

        image = Image.open("images/fake.png")

        msg = message if len(message) <= 30 else f'{message[:38]}...'

        parser = TwemojiParser(image, parse_discord_emoji=True)
        await parser.draw_text((80, 30), user.name, font=font, fill=color)
        await parser.draw_text((88 + userchar, 33), now.strftime("Today at %H:%M"), font=fontsmall, fill='grey')
        await parser.draw_text((80, 57), msg, font=fontnormal, fill=(220,221,222))
        await parser.close()

        CONVERT = await Misc.circle_pfp(user, 50, 50)
        image.paste(CONVERT, (20, 30), CONVERT)
        await ctx.send(file=Misc.save_image(image))
Beispiel #2
0
    async def fast(self, ctx, option: Optional[str], user: Optional[Member]=None):
        user = user or ctx.author
        if option in ["--rank", "rank"]:
            if not Wealth.collection.find_one({"_id": user.id}):
                return await ctx.send(f"Sorry {ctx.author.mention} that user is not ranked yet.")
            
            img = Image.new('RGB', (1000, 300), color=(35, 39, 42))
            font = ImageFont.truetype("fonts/Whitney-Medium.ttf", 65, encoding="unic")
            fontsmall = ImageFont.truetype("fonts/Whitney-Medium.ttf", 49, encoding="unic")
            result = self.collection.find_one({"_id": user.id})
            user_points = result['points']
            rank = self.collection.find({"points":{"$gt":user_points}}).count() + 1
            CONVERT = await Misc.circle_pfp(user, 180, 180)
            color = (255, 255, 255) if (user.color.to_rgb() == (0, 0, 0)) else user.color.to_rgb()
            name = user.name if len(user.name) <= 16 else f'{user.name[:13]}...'
            user_points = result['points']

            parser = TwemojiParser(img)
            await parser.draw_text((249, 69), name, font=font, fill=color) # Name of author
            await parser.draw_text((250, 160), f"Global rank: #{rank}, Points: {user_points:,}", font=fontsmall, fill='white') # Current rank, and points
            await parser.close()

            img.paste(CONVERT, (50, 67), CONVERT)
            return await ctx.send(file=Misc.save_image(img))
        
        word = choice(Misc.ALL_WORDS)

        font = ImageFont.truetype("fonts/Arial-bold.ttf", 25, encoding="unic")

        wx, wy = font.getsize(word)
        offset_y = font.getsize(word)[1]
        height = offset_y + wy

        img = Image.new('RGB', (wx+30, height), color='lightblue')

        imgdraw = ImageDraw.Draw(img)
        imgdraw.text((14, 9), word, fill='black', font=font)
        game = await ctx.send(file=Misc.save_image(img))

        while True:
            try:
                start = round(time() * 100)
                resp = await self.bot.wait_for("message", check=lambda message: message.channel == ctx.channel and message.guild == ctx.guild and message.content.lower() == word, timeout=18)
                elapse = round(time() * 100) - start
                if resp.content.lower() == word:
                    if not Wealth.collection.find_one({"_id": user.id}):
                        Wealth.collection.insert_one({
                            "_id": user.id,
                            "points": 0
                        })
                    
                    isfast = choice(self.badmessages) if (elapse/1000 > 6) else choice(self.goodmessages)
                    random_points = randint(10, 45) if (elapse/1000 > 6) else randint(5, 17)
                    Wealth.collection.update_one({"_id": resp.author.id}, {"$inc": {"coins": random_points}})
                    return await ctx.send(embed=Embed(title="Fastest typer!", description=f"{resp.author.mention} typed the word `{word}` first, also has earned `{random_points}` Points.", color=self.bot.color).add_field(name=":alarm_clock: | Time information", value=f"Time took in milliseconds: `{elapse}ms`\nTime took in seconds: `{elapse/1000}s`").add_field(name="<:Worldcool:768201555492864030> | Message from World", value=f"{isfast}", inline=False))
            except:
                await game.delete()
                return await ctx.send(f"Sorry {ctx.author.mention} nobody took part! So i have ended the game.")
Beispiel #3
0
    async def on_member_remove(self, member):
        result = self.collection.find_one({"_id": member.guild.id})
        if (not result) or (not result["LeftServer"]):
            return
        picture = await Misc.fetch_pfp(member)

        font = ImageFont.truetype("fonts/Arial-bold.ttf", 60, encoding="unic")
        fontsmall = ImageFont.truetype("fonts/Arial-bold.ttf",
                                       45,
                                       encoding="unic")

        check_length = member.name if len(
            member.name) <= 14 else f'{member.name[:11]}...'

        mainimage = Image.open("images/Welcome.png")

        parser = TwemojiParser(mainimage)
        await parser.draw_text((275, 230),
                               f"Goodbye {check_length}",
                               font=font,
                               fill='black')
        await parser.draw_text((279, 300),
                               f"We loved having you here!",
                               font=fontsmall,
                               fill='black')
        await parser.close()

        CONVERT = await Misc.circle_pfp(member, 200, 200)
        mainimage.paste(CONVERT, (50, 195), CONVERT)
        await self.bot.get_channel(result["LeftServer"]
                                   ).send(file=Misc.save_image(mainimage))
Beispiel #4
0
    async def profile_canvas(self, user, result):
        pfp = await Misc.fetch_pfp(user)
        pfp_resize = pfp.resize((49, 49))
        font = ImageFont.truetype("./fonts/Whitney-Medium.ttf", 30)
        fontm = ImageFont.truetype("./fonts/Whitney-Medium.ttf", 25)
        fontmm = ImageFont.truetype("./fonts/Whitney-Medium.ttf", 20)

        main = Image.open("./images/profile_template.png")
        draw = ImageDraw.Draw(main)
        if pfp.mode != "RGBA":
            main.paste(pfp_resize, (0, 0))
        else:
            main.paste(pfp_resize, (0, 0), pfp_resize)

        draw.text((60, 5), user.display_name, font=font, fill=(255, 255, 255))
        draw.text(
            (10, 60),
            f"Created account {Misc._delayfstr(result['AccountCreated'])} ago\nLast transfer: {Misc._delayfstr(result['LastTransfer'])} ago\nMarried to: {result['MarriedTo']}\nReputation: {result['Reputation']:,}",
            font=fontmm,
            fill=(255, 255, 255))

        cursor = 60
        for item in self.items_order:
            width = font.getsize(f"{result[item]:,}")[0]
            draw.text((564 - width, cursor),
                      f"{result[item]:,}",
                      font=fontm,
                      fill=(255, 255, 255))
            cursor += 40

        cursor = 10
        for i in range(3):
            if not result[f"BadgeSlot{i + 1}"].startswith("<:"):
                continue
            badge_image = await Misc.image_from_url(self.bot,
                                                    self.badge_urls[i])
            badge_image = badge_image.convert("RGBA").resize((90, 90))
            main.paste(badge_image, (cursor, 260), badge_image)
            cursor += 94

        pfp.close()
        del draw, cursor, pfp, font, fontm, fontmm
        return Misc.save_image(main)
Beispiel #5
0
    async def steam(self, ctx, user: Optional[Member], *, message=None):
    	"""Returns a Image of a Steam notifaction!"""
    	if message == None: message = "Nothing"
    	user = user or ctx.author
    	image = Image.open("images/steam.png")
    	font = ImageFont.truetype("fonts/Arial.ttf", 46, encoding="unic") # Steam's notifaction font.

    	pfp = await Misc.fetch_pfp(user)
    	CONVERT = pfp.resize((140,140)) # Resize the Members Avatar.

    	KKS_MESSAGE_CONVERT = ''.join(item['hepburn'] for item in self.kks.convert(message)) # Transliteration if the text is CJK
    	KKS_NAME_CONVERT = ''.join(item['hepburn'] for item in self.kks.convert(user.name)) # Transliteration if the text is CJK

    	MSG_CHECK = KKS_MESSAGE_CONVERT if len(KKS_MESSAGE_CONVERT) <= 25 else f'{KKS_MESSAGE_CONVERT[:22]}'
    	NAME_CHECK = KKS_NAME_CONVERT if len(KKS_NAME_CONVERT) <= 25 else f'{KKS_NAME_CONVERT[:22]}...'

    	parser = TwemojiParser(image)
    	await parser.draw_text((262, 77), NAME_CHECK, font=font, fill=(139,195,21)) # Name of discord.Member
    	await parser.draw_text((264, 132), "is now playing", font=font, fill="grey")
    	await parser.draw_text((263, 188), MSG_CHECK, font=font, fill=(139,195,21)) # Message/Game name (message)
    	await parser.close() # Close the session

    	image.paste(CONVERT, (92, 92), CONVERT)
    	return await ctx.send(file=Misc.save_image(image))
Beispiel #6
0
    async def topgg(self, ctx, user: Optional[Member], *, message):
        user = user or ctx.author
        if len(message) > 30:
            return await ctx.send(f"Sorry {ctx.author.mention} there is a limit of `30` chars.")

        ran_days = randint(2, 30)

        font = ImageFont.truetype("fonts/karla1.ttf", 19, encoding="unic")
        fontsmall = ImageFont.truetype("fonts/karla1.ttf", 15, encoding="unic")
        fontnormal = ImageFont.truetype("fonts/karla1.ttf", 18, encoding="unic")

        userchars = font.getsize(user.name)[0]

        mainimage = Image.open("images/tgg.png")

        parser = TwemojiParser(mainimage, parse_discord_emoji=True)
        await parser.draw_text((126, 43), user.name, font=font, fill='black')
        await parser.draw_text((134 + userchars, 47), f"{ran_days} days ago", font=fontsmall, fill='grey')
        await parser.draw_text((129, 84), message, font=font, fill='black')
        await parser.close()

        CONVERT = await Misc.circle_pfp(user, 41, 41)
        mainimage.paste(CONVERT, (62, 46), CONVERT)
        await ctx.send(file=Misc.save_image(mainimage))
Beispiel #7
0
    async def spotify(self, ctx, user: Optional[Member], option: Optional[str], *, song: Optional[str]):
        if option == "--artist":
        	if not song:
        		return await ctx.send(f"Sorry {ctx.author.mention} please specify a artist's name!")

        	results = self.sp.search(q=song, limit=1, type='artist')
        	for track in self.sp.search(q=song, limit=1, type='artist'):
        		items = results['artists']['items']

        		try:
        			artist = items[0]
        		except IndexError:
        			return await ctx.send(f"Sorry {ctx.author.mention} but that artist does not exist!")
        		return await ctx.send(embed=Embed(title=artist['name'], color=self.bot.color).add_field(name="Artist information", value=f"Followers: `{artist['followers']['total']:,}`\nPopularity: `{artist['popularity']}%`\nArtist Link: [`{artist['name']}`](https://open.spotify.com/artist/{artist['id']})").set_thumbnail(url=artist['images'][0]['url']))

        if option == "--song":
        	if not song:
        		return await ctx.send(f"Sorry {ctx.author.mention} Please specify a song name!")

        	results = self.sp.search(q=song, limit=1, type='track')
        	for track in results:
        		items = results['tracks']['items']

        		try:
        			song = items[0]
        			spotify = results['tracks']['items'][0]
        			name = ', '.join([artist['name'] for artist in spotify['artists']])
        		except IndexError:
        			return await ctx.send(f"Sorry {ctx.author.mention} but that artist does not exist!")
        		return await ctx.send(embed=Embed(title=song['name'], color=self.bot.color).add_field(name="Song information", value=f"Artist(s): `{name}`\nPopularity: `{song['popularity']}%`\nRelease date: `{spotify['album']['release_date']}`\nSong Link: [`{song['name']}`](https://open.spotify.com/track/{song['id']})").set_thumbnail(url=spotify['album']['images'][0]['url']))
        try:
        	user = user or ctx.author
        	spotify_activity = next((activity for activity in user.activities if isinstance(activity, Spotify)), None)

        	if not spotify_activity:
        		return await ctx.send(f"Sorry {ctx.author.mention} {user.name} is not currently listening to Spotify.")

        	r = await self.session.get(str(spotify_activity.album_cover_url))
        	res = BytesIO(await r.read())
        	r.close()

        	color_thief = ColorThief(res)
        	dominant_color = color_thief.get_color(quality=40)

        	font = ImageFont.truetype("fonts/spotify.ttf", 42, encoding="unic")
        	fontbold = ImageFont.truetype("fonts/spotify-bold.ttf", 53, encoding="unic")

        	title = self.kks.convert(spotify_activity.title)
        	album = self.kks.convert(spotify_activity.album)
        	artists = self.kks.convert(spotify_activity.artists)

        	title_new = ''.join(item['hepburn'] for item in title)
        	album_new = ''.join(item['hepburn'] for item in album)
        	transliterated_artists = [self.kks.convert(artist) for artist in spotify_activity.artists]
        	artists_new = ', '.join(''.join(item['hepburn'] for item in artist) for artist in transliterated_artists)

        	abridged = album_new if len(album_new) <= 30 else f'{album_new[:27]}...'
        	cbridged = title_new if len(title_new) <= 20 else f'{title_new[:17]}...'
        	dbridged = artists_new if len(artists_new) <= 30 else f'{artists_new[:27]}...'
        	text_colour = 'black' if Misc.relative_luminance(dominant_color) > 0.5 else 'white'

        	img = Image.new('RGB', (999, 395), color=dominant_color)

        	album = Image.open(res)
        	resized_album = album.resize((245, 245))
        	img.paste(resized_album, (41, 76))

        	parser = TwemojiParser(img, parse_discord_emoji=False)
        	await parser.draw_text((300, 90), cbridged, font=fontbold, fill=text_colour) # Top section - Song name
        	await parser.draw_text((303, 170), dbridged, font=font, fill=text_colour) # Middle secion - Artists of the song
        	await parser.draw_text((303, 228), abridged, font=font, fill=text_colour) # Album name - Bottom section
        	await parser.close()
        	await ctx.send(file=Misc.save_image(Misc.add_corners(img, 42)))
        except Exception as e:
        	return await ctx.send(e)
Beispiel #8
0
 async def wide(self, ctx, user: Member=None):
     user = user or ctx.author
     av_img = await Misc.fetch_pfp(user)
     await ctx.send(file=Misc.save_image(av_img.resize((350, 180))))
Beispiel #9
0
    async def blur(self, ctx, user: Member=None):
        user = user or ctx.author

        av_img = await Misc.fetch_pfp(user)
        done = av_img.filter(ImageFilter.GaussianBlur(radius=8))
        await ctx.send(file=Misc.save_image(done))
Beispiel #10
0
    async def flip(self, ctx, user: Member=None):
        user = user or ctx.author

        av_img = await Misc.fetch_pfp(user)
        done = av_img.rotate(180)
        await ctx.send(file=Misc.save_image(done))