async def piestatus(self, ctx, *, target : discord.Member = None): '''Generates a pie chart displaying the ratios between the statuses the bot has seen the user use.''' target = target or ctx.author async with ctx.channel.typing(): rows = await self.bot.pool.fetch(query_base + ''' select status, sum( extract( epoch from( last_seen - first_seen ))) as sum from status_data group by status order by sum desc ''', target.id) async with self.bot.session.get(str(target.avatar_url_as(format='png'))) as r: avydata = BytesIO(await r.read()) statuses = {row['status'] : row['sum'] for row in rows if row['status'] in status.keys()} data = await self.bot.loop.run_in_executor(None, self._piestatus, avydata, statuses) await ctx.send(file=discord.File(data, filename=f'{target.display_name}_pie_status.png'))
async def pofon(ctx, user: discord.Member = None): if user == None: user = ctx.author stemplate = Image.open("SlapTemplate.jpg") original = ctx.author.avatar_url_as(size = 128) other = user.avatar_url_as(size = 128) data = BytesIO(await original.read()) data2 = BytesIO(await other.read()) pfp = Image.open(data) pfp2 = Image.open(data2) pfp = pfp.resize((300, 300)) pfp2 = pfp2.resize((300, 300)) stemplate.paste(pfp, (460, 50)) stemplate.paste(pfp2, (850, 300)) stemplate.save("slapedit.jpg") await ctx.send(file = discord.File("slapedit.jpg"))
async def _hgames_volunteer(self, ctx, player_name=None, player_image=None, volunteer: discord.Member = None): """ Allows for users to sign themselves up for the Hunger Games. Users will be placed into their own Player class, which will then be added to the gamestate. Users may volunteer others, but this should probably not be advertised. That should probably also be locked behind a permission, or by a role. Make sure to delete this last part later. """ if not volunteer: volunteer = ctx.author player_name = player_name or str(volunteer) if not player_image: if ctx.message.attachments: image_url = ctx.message.attachments[0].url if image_url[-4:] in ['.png', '.jpg', 'jpeg']: player_image = image_url else: player_image = volunteer.avatar_url_as(format='png', size=1024) player = Player(volunteer.id, player_name, image=player_image) self.games[ctx.guild.id].add_player(player)
async def kézfogás(ctx, user: discord.Member = None): if user == None: user = ctx.author htemplate = Image.open("HandShakeTemplate.jpg") original = ctx.author.avatar_url_as(size = 128) other = user.avatar_url_as(size = 128) data = BytesIO(await original.read()) data2 = BytesIO(await other.read()) pfp = Image.open(data) pfp2 = Image.open(data2) pfp = pfp.resize((300, 300)) pfp2 = pfp2.resize((300, 300)) htemplate.paste(pfp, (50, 50)) htemplate.paste(pfp2, (1200, 50)) htemplate.save("hshakeedit.jpg") await ctx.send(file = discord.File("hshakeedit.jpg"))
async def on_member_join(self, member: discord.Member) -> None: """Log member join event to user log.""" if member.guild.id != GuildConstant.id: return member_str = escape_markdown(str(member)) message = f"{member_str} (`{member.id}`)" now = datetime.utcnow() difference = abs(relativedelta(now, member.created_at)) message += "\n\n**Account age:** " + humanize_delta(difference) if difference.days < 1 and difference.months < 1 and difference.years < 1: # New user account! message = f"{Emojis.new} {message}" await self.send_log_message( Icons.sign_in, Colours.soft_green, "User joined", message, thumbnail=member.avatar_url_as(static_format="png"), channel_id=Channels.user_log )
async def test(self, ctx: commands.Context, user: discord.Member = None): if user == None: user = ctx.author image = Image.open("assets/Images/trou_noir.jpg") font = ImageFont.truetype( "assets/Fonts/adler.ttf", 48, ) asset = user.avatar_url_as(size=128) data = BytesIO(await asset.read()) pfp = Image.open(data) pfp = pfp.resize((240, 240)) image.paste(pfp, (270, 140)) draw = ImageDraw draw.Draw(image) text = f"{ctx.author.display_name}#{ctx.author.discriminator}\nà déformé l'espace-temps\npour nous rejoindre!" draw.text((200, 35), text, (0, 0, 0), font=font) image.save("assets/Images/profile.jpg") await ctx.send(file=discord.File("assets/Images/profile.jpg"))
async def avatar(self, ctx, user: discord.Member = None): """Command to see a larger version of the given member's avatar Examples: ++avatar @mention ++avatar 123456789 ++avatar member#1234 """ if not user: user = ctx.author embed = discord.Embed(color=discord.Color.blue()) embed.add_field(name=f"{user.name}#{user.discriminator}", value=user.display_name, inline=True) embed.add_field(name="Avatar URL", value=user.avatar_url, inline=True) embed.set_image(url=user.avatar_url_as(size=128)) embed.set_footer( text=f"Discord ID: {user.id}", icon_url= "https://discordapp.com/assets/2c21aeda16de354ba5334551a883b481.png" ) response = await ctx.send(embed=embed)
async def userinfo(self, ctx, member: discord.Member = None): if member == None: member = ctx.author if member.bot == True: bot = "true" else: bot = "false" UserinfoE = discord.Embed( colour=0xff63b7, title=f"Userinfo **»** {member.name}", description= f"- ID **{member.id}**\n- Nickname **{member.display_name}**\n- Name color **{member.color}**\n- Bot **{bot}**\n\n- Created At **{member.created_at.strftime('%d/%m/%Y, %I:%m %p')}**\n- Join Date **{member.joined_at.strftime('%d/%m/%Y, %I:%m %p')}**" ) UserinfoE.set_thumbnail( url=str(member.avatar_url_as(static_format='png', size=2048))) UserinfoE.set_footer( text=f"Made by llama • Requested by {ctx.author.name}", icon_url=str( ctx.author.avatar_url_as(static_format='png', size=2048))) await ctx.send(embed=UserinfoE)
async def uinfo(self, ctx, *, member: discord.Member = None): """Information on a user""" if member is None: member = ctx.message.author em = discord.Embed(title=member.nick, color=member.color.value and member.color or discord.Embed.Empty) em.add_field(name="Name", value=member.name) em.add_field(name="Client", value="📱: {}\n" "🖥: {}\n" "🌎: {}".format( str(member.mobile_status).capitalize(), str(member.desktop_status).capitalize(), str(member.web_status).capitalize())) em.add_field(name="Joined server", value=member.joined_at.strftime('%d.%m.%Y %H:%M:%S %Z')) em.add_field(name="ID", value=member.id) em.add_field(name="Has existed since", value=member.created_at.strftime('%d.%m.%Y %H:%M:%S %Z')) member.color.value and em.add_field(name="Color", value=member.colour) em.add_field(name="Bot?", value=bool_emojify(member.bot)) em.add_field( name="Server perms", value="[{0}](https://discordapi.com/permissions.html#{0})".format( member.guild_permissions.value)) em.add_field(name="Mention", value="{}\n{}".format(member.mention, chat.inline(member.mention))) em.add_field( name="Roles", value="\n".join( [role.name for role in member.roles if not role.is_default()]) or "❌", inline=False) em.set_image(url=member.avatar_url_as(static_format="png", size=2048)) em.set_thumbnail(url="https://xenforo.com/community/rgba.php?r=" + str(member.colour.r) + "&g=" + str(member.colour.g) + "&b=" + str(member.colour.b) + "&a=255") await ctx.send(embed=em)
async def user(self, ctx, member: discord.Member = None): 'Returns some nifty user info' author = ctx.author roles_string = '' for obj1 in author.roles: roles_string = (roles_string + '\n') + obj1.name if member is None: embed = discord.Embed(title=author.name, color=745822) embed.set_thumbnail(url=ctx.author.avatar_url_as( format=None, static_format='webp', size=1024)) embed.add_field(name='User ID:', value=author.id, inline=True) embed.add_field(name='Status:', value=author.status, inline=True) embed.add_field(name='Roles:', value=roles_string, inline=False) embed.add_field(name='Created At:', value=author.created_at, inline=True) embed.add_field(name='Joined Server At:', value=author.joined_at, inline=True) await ctx.send(embed=embed) membroles = member.roles membroles_string = '' for obj2 in membroles: membroles_string = (membroles_string + '\n') + obj2.name else: embed = discord.Embed(title=member.display_name, color=745822) embed.set_thumbnail(url=member.avatar_url_as( format=None, static_format='webp', size=1024)) embed.add_field(name='User ID:', value=member.id, inline=True) embed.add_field(name='Status:', value=member.status, inline=True) embed.add_field(name='Roles:', value=membroles_string, inline=False) embed.add_field(name='Created At:', value=member.created_at, inline=True) embed.add_field(name='Joined Server At:', value=member.joined_at, inline=True) await ctx.send(embed=embed)
async def _banlook(self, ctx, user: discord.Member = None): """Check if user is banned on bans.discordlist.com""" if not user: e = discord.Embed( title="No User/ID found. Did you forgot to mention one?", colour=discord.Colour.red()) return await ctx.send(embed=e) checkID = user.id name = user avatar = user is_banned = await dBans.lookup(user_id=checkID) name = user avatar = user.avatar_url_as(format='png') if is_banned: try: infomessage = "This user has one or more registered bans which means he participated in an illegal activity, raiding or spamming of servers. Proceed with caution." e = discord.Embed(title="Ban's Found!", colour=discord.Colour.red()) e.description = "For proof and more info go to http://bans.discordlist.net" e.add_field(name="Information:", value=infomessage, inline=False) e.set_author(name=name, icon_url=avatar) e.set_footer(text="User ID: {}".format(user.id)) e.set_thumbnail(url=avatar) return await ctx.send(embed=e) except KeyError: return try: infomessage = "This user has no registered bans but this doesn't mean he is harmless!" e = discord.Embed(title="No Ban's Found.", colour=discord.Colour.green()) e.description = "For more info goto http://bans.discordlist.net" e.add_field(name="Information:", value=infomessage, inline=False) e.set_author(name=name, icon_url=avatar) e.set_footer(text="User ID: {}".format(user.id)) e.set_thumbnail(url=avatar) return await ctx.send(embed=e) except KeyError: return
async def shadow_kick(self, ctx: Context, user: Member, *, reason: str = None): """ Kicks a user. :param user: accepts user mention, ID, etc. :param reason: The reason for the kick. """ response_object = await post_infraction(ctx, user, type="kick", reason=reason, hidden=True) if response_object is None: return self.mod_log.ignore(Event.member_remove, user.id) await user.kick(reason=reason) if reason is None: result_message = f":ok_hand: kicked {user.mention}." else: result_message = f":ok_hand: kicked {user.mention} ({reason})." await ctx.send(result_message) # Send a log message to the mod log await self.mod_log.send_log_message( icon_url=Icons.sign_out, colour=Colour(Colours.soft_red), title="Member shadow kicked", thumbnail=user.avatar_url_as(static_format="png"), text=textwrap.dedent(f""" Member: {user.mention} (`{user.id}`) Actor: {ctx.message.author} Reason: {reason} """))
async def member(self, ctx: context.Context, *, member: discord.Member = None): """ Displays a member's account information. `member`: The member of which to get information for. Can be their ID, Username, Nickname or Mention. Defaults to you. """ if member is None: member = ctx.author embed = discord.Embed(colour=self.bot.utils.colours[member.status], title=f'{member}\'s information.') embed.description = f'`Discord Name:` {member} {"<:owner:738961071729278987>" if member.id == member.guild.owner.id else ""}\n' \ f'`Created on:` {self.bot.utils.format_datetime(datetime=member.created_at)}\n' \ f'`Created:` {self.bot.utils.format_difference(datetime=member.created_at)} ago\n' \ f'`Badges:` {self.bot.utils.badges(person=member)}\n' \ f'`Status:` {member.status.name.replace("dnd", "Do Not Disturb").title()}' \ f'{"<:phone:738961150343118958>" if member.is_on_mobile() else ""}\n' \ f'`Bot:` {str(member.bot).replace("True", "Yes").replace("False", "No")}\n' \ f'`Activity:` {self.bot.utils.activities(person=member)}' embed.add_field( name='Server related information:', value=f'`Server nickname:` {member.nick}\n' f'`Joined on:` {self.bot.utils.format_datetime(datetime=member.joined_at)}\n' f'`Joined:` {self.bot.utils.format_difference(datetime=member.joined_at)} ago\n' f'`Join Position:` {sorted(ctx.guild.members, key=lambda m: m.joined_at).index(member) + 1}\n' f'`Top role:` {member.top_role.mention}\n' f'`Role count:` {len(member.roles) - 1}', inline=False) embed.set_thumbnail(url=str( member.avatar_url_as( format='gif' if member.is_avatar_animated() is True else 'png') )) embed.set_footer(text=f'ID: {member.id}') return await ctx.send(embed=embed)
async def softban(self, ctx, user: discord.Member, *, reason="No reason specified."): assert self.bot.higher_role(ctx.author, user), "Invalid permissions." try: await user.send( embed=discord.Embed( color=discord.Color.blurple(), timestamp=datetime.utcnow(), description=f"""You were kicked from **{ctx.guild}** Responsible Moderator: **{ctx.author}** Reason: ```\n{reason}\n```""" ) ) dm = True except discord.Forbidden: dm = False await user.ban(reason=reason, delete_message_days=7) await user.unban() await ctx.send( embed=discord.Embed( color=discord.Color.blurple(), description=f"<:nano_check:484247886461403144> {user} was kicked." ), delete_after=5 ) channel = await self.bot.get_logging_channel(ctx.guild) if not channel: return embed = discord.Embed( color=discord.Color.blurple(), title=f"{user}", timestamp=datetime.utcnow() ) embed.set_author( name="User was kicked", icon_url=user.avatar_url_as(static_format="png") ) embed.set_footer( text=f"DMed user? {dm}" ) await channel.send(embed=embed)
async def avatar(ctx, *, member: discord.Member = None): author = ctx.author if not member: member = author if member.avatar: if member.avatar_url[54:].startswith('a_'): avi = 'https://cdn.discordapp.com/avatars/' + member.avatar_url[ 35:-10] avi_description = f"**{member.name}'s** avatar!\n[Click to open avatar!]({avi})" else: avi = member.avatar_url_as(static_format="png", size=1024) avi_description = f"**{member.name}'s** avatar!\n[Click to open avatar!]({avi})" else: avi_description = f"**{member.name}** has no avatar!\n" avi = "https://i.imgur.com/lkeELEJ.png" embed = discord.Embed(description=f"{avi_description}", color=discord.Colour(0xE4D7FF)) embed.set_image(url=f"{avi}") await ctx.send(embed=embed)
async def on_member_remove(self, member: discord.Member): """Welcome/Leave message handler.""" # Fetch the welcome channel id from the database. welcome_status = await self.bot.database.get_welcome_channel(member.guild) if welcome_status is None: return # Get channel and check if it is None. channel = self.bot.get_channel(int(welcome_status)) if channel is None: return # Fetch avatar avatar = await (member.avatar_url_as(size=256)).read() # With lock make image. async with self.lock: func = functools.partial(canvas.welcome_leave_image, avatar, member, False) image = await self.bot.loop.run_in_executor(None, func) file_buffer = discord.File(image, "goodbye.png") await channel.send(file=file_buffer)
async def userinfo(self, ctx, *, member: discord.Member = None): '''Get information about a member.''' if member is None: member = ctx.author activity = '`None`' if len(member.activities) > 0: for activity in member.activities: if isinstance(activity, discord.Spotify): activity = 'Listening to `Spotify`' elif isinstance(activity, discord.Game): activity = f'Playing `{activity.name}``' elif isinstance(activity, discord.Streaming): activity = f'Streaming `{activity.name}`' embed = discord.Embed(title=f"{member}", colour=self.colour) embed.add_field( name='**General:**', value=f'Name: `{member}`\n' f'Activity: {activity}\n' f'Desktop Status: `{member.desktop_status}`\n' f'Mobile Status: `{member.mobile_status}`\n' f'Browser Status: `{member.web_status}`\n' f'Created on: `{datetime.datetime.strftime(member.created_at, "%A %d %B %Y at %H:%M")}`', inline=False) embed.add_field( name='**Guild related information:**', value= f'Joined guild: `{datetime.datetime.strftime(member.joined_at, "%A %d %B %Y at %H:%M")}`\n' f'Nickname: `{member.nick}`\n' f'Top role: {member.top_role.mention}', inline=False) embed.set_thumbnail(url=member.avatar_url_as(static_format='png')) embed.set_footer( text= f'Member ID: {member.id} | Requested by: {ctx.author.name}#{ctx.author.discriminator}' ) return await ctx.send(embed=embed)
async def stab(self,ctx,member:discord.Member=None): if member == None: member = ctx.author if member.id in [793433316258480128, 800219427928801290, 747451011484090479]: await ctx.send('HAHA U CANT SLAP TOO GOOD PEOPLE TRY TO SLAP SOMEONE ELSE LOL') else: im = Image.open('stab.jpg') asset = member.avatar_url_as(format=None, static_format='jpg', size=128) data = BytesIO(await asset.read()) pfp = Image.open(data) asset2 = ctx.author.avatar_url_as(format=None, static_format='jpg', size=128) data2 = BytesIO(await asset2.read()) pfp2 = Image.open(data2) pfp = pfp.resize((99,92)) pfp2 = pfp2.resize((99, 92)) im = im.copy() im.paste(pfp, (138, 81)) im.paste(pfp2, (13, 35)) im.save('stabbed.png') await ctx.send(file=discord.File('stabbed.png'))
async def perms(self, ctx, target: discord.Member = None): """Show the allowed and denied permissions for a user""" target = target or ctx.author embed = discord.Embed(color=discord.Color.main) ls = sorted([p for p in ctx.channel.permissions_for(target)], key=lambda x: x[1], reverse=True) for key, group in itertools.groupby(ls, lambda x: x[1]): joined = '\n'.join([ f'{ctx.tick(g[1])} {discord.utils.escape_markdown(g[0])}' for g in group if g[0] in [ a[0] for a in filter(lambda p: p[1] is True, discord.Permissions(2080898303)) ] ]) embed.add_field(name='_ _', value=joined or '_ _') embed.set_field_at(0, name=ctx.channel.permissions_for(ctx.author).value, value=embed.fields[0].value) embed.set_author(name=target.display_name, icon_url=target.avatar_url_as(static_format='png')) await ctx.send(embed=embed)
async def _mike(self, ctx, member: discord.Member = None): "Mike Bruhzowski" member = member or ctx.author async with ctx.typing(): if ctx.message.attachments: url = ctx.message.attachments[0].url else: url = str(member.avatar_url_as(format="png")) async with aiohttp.ClientSession() as cs: async with cs.get(url) as r: res = await r.read() b = await self.mike(res) await ctx.send(file=discord.File(fp=b, filename="mike.png")) await cs.close()
async def rank(self, ctx, *, member: discord.Member = None): """Get a user's ranking on the XP leaderboard. If no member is passed, the caller's ranking is shown. """ member = member or ctx.author embed = discord.Embed(color=member.color) guild_settings = self.guild_settings.get(ctx.guild.id) if guild_settings is None or not guild_settings.enabled: embed.description = "Levels are not enabled in this server" else: cache_record = await self.load_member(ctx.guild.id, member.id) # Grab member from cache to make sure we have the most up to date values # Make Postgres compute the rank for us (need WITH-query so rank() sees records for every user) db_record = await db.Pool.fetchrow(f""" WITH ranked_xp AS ( SELECT user_id, rank() OVER (ORDER BY total_xp DESC, user_id) FROM {MemberXP.__tablename__} WHERE guild_id = $1 ) SELECT rank FROM ranked_xp WHERE user_id = $2; """, ctx.guild.id, member.id) total_xp = cache_record.total_xp db_count = await db.Pool.fetchval(f"""SELECT count(*) FROM {MemberXP.__tablename__} WHERE guild_id = $1; """, ctx.guild.id) # Prevents 1/1 in servers of ~100 and 50/40 in shrunk servers count = ctx.guild.member_count if ctx.guild.member_count > db_count else db_count level = self.level_for_total_xp(total_xp) level_floor = self.total_xp_for_level(level) level_xp = self.total_xp_for_level(level + 1) - level_floor if db_record: # If member does not exist in the db, then return rank as the lowest rank rank = db_record.get("rank") else: rank = count embed.description = (f"Level {level}, {total_xp - level_floor}/{level_xp} XP to level up ({total_xp} total)\n" f"#{rank} of {count} in this server") embed.set_author(name=member.display_name, icon_url=member.avatar_url_as(format='png', size=64)) await ctx.send(embed=embed)
async def magik(self, ctx, member: discord.Member, intensity: int = 5): avatar = member.avatar_url_as(size=1024, format=None, static_format='png') emoji = ":penguin:" message = await ctx.send( f"{emoji} — **Processing the image please wait!**") await message.delete(delay=3) async with aiohttp.ClientSession() as cs: async with cs.get( f"https://nekobot.xyz/api/imagegen?type=magik&image={avatar}&intensity={intensity}" ) as r: res = await r.json() embed = discord.Embed(color=self.bot.embed_color, title="→ Magik") embed.set_image(url=res["message"]) await ctx.send(embed=embed) logger.info(f"Images | Sent Magik: {ctx.author}")
async def member(self, ctx, member: discord.Member = None): """ Retrieve information about a member of the guild. If no arguments are passed, information about the author is used. **This command works without mentions.** Remove the '@' before your mention so you don't ping the person unnecessarily. You can pick a member by: - Username (`cooldude`) - Username and discriminator (`cooldude#1234`) - ID (`326749693969301506`) - Nickname - must be exact and is case-sensitive (`"Mr. Cool Dude III | Team 1234"`) - Mention (not recommended) (`@Mr Cool Dude III | Team 1234`) """ async with ctx.typing(): member = member or ctx.author icon_url = member.avatar_url_as(static_format='png') e = discord.Embed(color=member.color) e.set_thumbnail(url=icon_url) e.add_field(name='Name', value=str(member)) e.add_field(name='ID', value=member.id) e.add_field(name='Nickname', value=member.nick, inline=member.nick is None) e.add_field( name='Bot Created' if member.bot else 'User Joined Discord', value=member.created_at.strftime(datetime_format)) e.add_field(name='Joined Guild', value=member.joined_at.strftime(datetime_format)) e.add_field(name='Color', value=str(member.color).upper()) e.add_field(name='Status and Game', value='%s, playing %s' % (str(member.status).title(), member.game), inline=False) roles = sorted(member.roles, reverse=True)[:-1] # Remove @everyone e.add_field(name='Roles', value=', '.join(role.name for role in roles), inline=False) e.add_field(name='Icon URL', value=icon_url, inline=False) await ctx.send(embed=e)
async def rank(self, ctx, member: discord.Member = None): if member is None: member = ctx.author args = { 'bg_image': '', # Background image link (Optional) 'profile_image': str(member.avatar_url_as( format='png')), # User profile picture link 'level': 1, # User current level 'current_xp': 0, # Current level minimum xp 'user_xp': 10, # User current xp 'next_xp': 100, # xp required for next level 'user_position': 1, # User position in leaderboard 'user_name': str(member), # user name with descriminator 'user_status': member.status. name, # User status eg. online, offline, idle, streaming, dnd } func = functools.partial(self.get_card, args) image = await asyncio.get_event_loop().run_in_executor(None, func) file = discord.File(fp=image, filename='image.png') await ctx.send(file=file)
async def level(ctx, member: discord.Member = None): await levelon_open(ctx.guild) users = await levelon_data() server = ctx.guild if users[str(server.id)]["levelon"] == "on": if member == None: member = ctx.author level = Image.open("level.png") asset = member.avatar_url_as(size=128) data = BytesIO(await asset.read()) pfp = Image.open(data) pfp = pfp.resize((128,127)) level.paste(pfp, (105,34)) await open_lvl(member) users = await get_lvl_data() draw = ImageDraw.Draw(level) font = ImageFont.truetype("level.ttf", 40) l = users[str(member.id)]["level"] e = users[str(member.id)]["experience"] draw.text((355, 75), f": {member.name}", (0, 0, 0), font=font) draw.text((232, 180), f": {l}", (0, 0, 0), font=font) draw.text((220, 242), f": {e}", (0, 0, 0), font=font) level.save("lev.png") await ctx.send(file=discord.File("lev.png")) return await ctx.send("The leveling system is currently off! Inorder to use it turn it on!")
async def slap(self, ctx, user : discord.Member = None): if user == None: user = ctx.author wanted = Image.open("assets/slap.png") asset = user.avatar_url_as(size = 128) asset2 = ctx.author.avatar_url_as(size = 128) data = BytesIO(await asset.read()) data2 = BytesIO(await asset2.read()) pfp = Image.open(data) pfp2 = Image.open(data2) pfp = pfp.resize((219,219)) pfp2 = pfp2.resize((200,200)) wanted.paste(pfp2, (350,70)) wanted.paste(pfp, (581,261)) wanted.save("assets/Spic.png") await ctx.send(file = discord.File("assets/Spic.png"))
async def deepfry(ctx, member: discord.Member = None): if member == None: member = ctx.author asset = member.avatar_url_as(size =128) data = BytesIO(await asset.read()) im = Image.open(data).convert('RGB') enhancer = ImageEnhance.Brightness(im) im = enhancer.enhance(0.5) im = im.filter(ImageFilter.GaussianBlur(radius = 1.4)) converter = ImageEnhance.Color(im) im = converter.enhance(7) im.save('rev.png') image = cv2.imread('rev.png') noise_img = sp_noise(image,0.05) cv2.imwrite('output.png', noise_img) await ctx.send(file = discord.File("output.png")) os.remove("output.png") os.remove("rev.png")
async def upsidedown(self, ctx, *, member: discord.Member = None): await ctx.trigger_typing() member = member or ctx.author if not ctx.message.attachments: await ctx.trigger_typing() async with aiohttp.ClientSession() as cs: async with cs.get(member.avatar_url_as(format='png', size=1024)) as image: avatar_bytes = await image.read() with Image.open(BytesIO(avatar_bytes)) as image: output_buffer = BytesIO() image = image.rotate(180) image.save(output_buffer, 'png') output_buffer.seek(0) await ctx.send( file=discord.File(fp=output_buffer, filename='test.png')) else: atc = ctx.message.attachments[0] try: attachment_bytes = BytesIO() file_format = ctx.message.attachments[0].filename.split('.') await ctx.message.attachments[0].save(attachment_bytes) attachment_bytes.seek(0) with Image.open(attachment_bytes) as image: output_buffer = BytesIO() image = image.rotate(180) image.save(output_buffer, atc.filename.split('.')[-1]) output_buffer.seek(0) await ctx.send(file=discord.File( fp=output_buffer, filename=ctx.message.attachments[0].filename)) except ValueError: await ctx.send('That format is not supported.')
async def blur(self, ctx, *, member: discord.Member = None, amount: float = 0.5): """Makes a blur version of your or someone you specify profile picture.""" member = member or ctx.author if not ctx.message.attachments: await ctx.trigger_typing() async with aiohttp.ClientSession() as cs: async with cs.get(member.avatar_url_as(format='png', size=1024)) as image: avatar_bytes = await image.read() with Image.open(BytesIO(avatar_bytes)) as image: output_buffer = BytesIO() image = image.filter(ImageFilter.GaussianBlur(5)) image.save(output_buffer, 'png') output_buffer.seek(0) await ctx.send( file=discord.File(fp=output_buffer, filename='test.png')) else: try: attachment_bytes = BytesIO() file_format = ctx.message.attachments[0].filename.split('.') await ctx.message.attachments[0].save(attachment_bytes) attachment_bytes.seek(0) with Image.open(attachment_bytes) as image: output_buffer = BytesIO() image = image.filter(ImageFilter.GaussianBlur(5)) image.save(output_buffer, 'gif') output_buffer.seek(0) await ctx.send(file=discord.File( fp=output_buffer, filename=ctx.message.attachments[0].filename)) except ValueError: await ctx.send('That format is not supported.')
async def user(self, ctx: Context, member: discord.Member = None) -> NoReturn: """Shows user information. Attributes: ----------- - `member` - user """ s = await Settings(ctx.guild.id) lang = await s.get_field("locale", CONFIG["default_locale"]) STRINGS = Strings(lang) if member is None: member = ctx.message.author id = str(member.id) name = member.name tag = member.discriminator username = member.nick joined_at = member.joined_at.strftime("%d.%m.%Y %H:%M") created_at = member.created_at.strftime("%d.%m.%Y %H:%M") stat = member.status activ = member.activity color = member.color avatar = member.avatar_url_as() embed = discord.Embed( description=STRINGS["utilities"]["user_info"].format( id, created_at, joined_at, username, stat, activ, color), color=color, ) embed.set_author( name=STRINGS["utilities"]["user_info_title"].format(name, tag)) embed.set_thumbnail(url=avatar) await ctx.send(embed=embed)