async def avatar(self, ctx, *, user: discord.Member = None): """Returns user avatar URL. User argument can be user mention, nickname, username, user ID. Default to yourself when no argument is supplied. """ author = ctx.author if not user: user = author if user.is_avatar_animated(): url = user.avatar_url_as(format="gif") if not user.is_avatar_animated(): url = user.avatar_url_as(static_format="png") embed = discord.Embed( colour=await ctx.embed_colour(), description=f"Avatar [URL]({url})", timestamp=datetime.now(), ) embed.set_image(url=f"{url}") embed.set_author(name=f"{user.name}'s Avatar", ) embed.set_footer(text="Avatary™") await ctx.send(embed=embed)
async def avatar(self, ctx, member: discord.Member = None): """Get a member's avatar with links to download/view in higher quality""" member = member or ctx.author embed = discord.Embed( title=f'{member.display_name}\'s avatar', description=f'[PNG]({member.avatar_url_as(format="png")}) | ' f'[JPEG]({member.avatar_url_as(format="jpg")}) | ' f'[WEBP]({member.avatar_url_as(format="webp")})', colour=get_colour(ctx)) if member.is_avatar_animated(): embed.description += f' | [GIF]({member.avatar_url_as(format="gif")})' embed.set_author(name=member.display_name, icon_url=member.avatar_url) embed.set_image(url=member.avatar_url_as( format='gif' if member.is_avatar_animated() else 'png')) await ctx.send(embed=embed)
def get_badges(member: Member) -> str: """ Convenience function that fetches all the badges a member has :param member: Member to fetch the badges from :return: str emotes of badges """ badge_dict = { 'staff': constants.staff, 'partner': constants.partner, 'hypesquad': constants.hs_ev, 'bug_hunter': constants.bg_1, 'hypesquad_bravery': constants.hs_brav, 'hypesquad_brilliance': constants.hs_bril, 'hypesquad_balance': constants.hs_bal, 'early_supporter': constants.ear_supp, 'bug_hunter_level_2': constants.bg_2, 'verified_bot_developer': constants.verified_bot_dev } badges = "" for flag in member.public_flags: if flag[1]: try: badges += badge_dict[flag[0]] except Exception as e: logger.critical(e) if member.is_avatar_animated(): badges += constants.nitro return badges
async def avatar(self, ctx, *, user: discord.Member = None): """ Get yours or a specified users avatar. `user`: The user who you want the avatar of. Can be an ID, mention or name. """ # If the user didnt choose someone. if not user: user = ctx.author embed = discord.Embed( colour=0xFF0000, ) embed.set_author(icon_url=ctx.author.avatar_url, name=ctx.author.name) if user.is_avatar_animated(): embed.add_field(name=f"{user.name}'s Avatar", value=f"[GIF]({user.avatar_url_as(size=1024, format='gif')}) | " f"[PNG]({user.avatar_url_as(size=1024, format='png')}) | " f"[JPEG]({user.avatar_url_as(size=1024, format='jpeg')}) | " f"[WEBP]({user.avatar_url_as(size=1024, format='webp')})", inline=False) embed.set_image(url=f"{user.avatar_url_as(size=1024, format='gif')}") else: embed.add_field(name=f"{user.name}'s Avatar", value=f"[PNG]({user.avatar_url_as(size=1024, format='png')}) | " f"[JPEG]({user.avatar_url_as(size=1024, format='jpeg')}) | " f"[WEBP]({user.avatar_url_as(size=1024, format='webp')})", inline=False) embed.set_image(url=f"{user.avatar_url_as(size=1024, format='png')}") return await ctx.send(embed=embed)
async def avatar(self, ctx: context.Context, member: discord.Member = None): """Post large version of a given user's avatar Parameters ---------- member : discord.Member, optional "Member to get avatar of, default to command invoker" """ if member is None: member = ctx.author await ctx.message.delete() embed = discord.Embed(title=f"{member}'s avatar") animated = ["gif", "png", "jpeg", "webp"] not_animated = ["png", "jpeg", "webp"] def fmt(format_): return f"[{format_}]({member.avatar_url_as(format=format_, size=4096)})" # add links to various formats of the profile picture URL, depending on if it's a gif if member.is_avatar_animated(): embed.description = f"View As\n {' '.join([fmt(format_) for format_ in animated])}" else: embed.description = f"View As\n {' '.join([fmt(format_) for format_ in not_animated])}" embed.set_image(url=str(member.avatar_url_as(size=4096))) embed.color = discord.Color.random() embed.set_footer(text=f"Requested by {ctx.author}") await ctx.send(embed=embed)
async def avatar(self, ctx, *, member: discord.Member = None): """ Get yours or a specified members avatar. `member`: The member who you want the avatar of. Can be a Mention, Name or ID """ if not member: member = ctx.author embed = discord.Embed( colour=discord.Color.gold(), title=f"{member.name}'s Avatar", description=f"[PNG]({member.avatar_url_as(size=1024, format='png')}) | " f"[JPEG]({member.avatar_url_as(size=1024, format='jpeg')}) | " f"[WEBP]({member.avatar_url_as(size=1024, format='webp')})" ) embed.set_author(icon_url=ctx.author.avatar_url_as(format="png"), name=ctx.author.name) if member.is_avatar_animated(): embed.description += f" | [GIF]({member.avatar_url_as(size=1024, format='gif')})" embed.set_image(url=f"{member.avatar_url_as(size=1024, format='gif')}") else: embed.set_image(url=f"{member.avatar_url_as(size=1024, format='png')}") return await ctx.send(embed=embed)
async def userinfo(self, ctx, *, user: discord.Member = None): """ Get a users info from the server """ # If user isnt specified default to author if user is None: user = ctx.author # Creating embed embed = discord.Embed(colour=discord.Colour.purple(), title=f"{user.name}'s Info'") embed.set_footer(text=f"ID: {user.id}") ft = "gif" if user.is_avatar_animated() else "png" embed.set_thumbnail(url=user.avatar_url_as(format=ft)) # These fields are from a website called programcreek.com / https://www.programcreek.com/python/example/107400/discord.Embed embed.add_field( name="__**General Info**__", value=f"**Discord Name:** {user}\n" f"**Account created:** {user.created_at.__format__('%A %d %B %Y at %H:%M')}\n" ) embed.add_field( name="__**Server-related Information:**__", value=f"**Nickname:** {user.nick}\n" f"**Joined server:** {user.joined_at.__format__('%A %d %B %Y at %H:%M')}\n" f"**Roles:** {' '.join([r.mention for r in user.roles[1:]])}") await ctx.send(embed=embed)
async def avatar(ctx, *, user: discord.Member = None ): # Avatar yani profil fotoğrafı büyütme komutudur. author = ctx.author if not user: user = author if user.is_avatar_animated(): url = user.avatar_url_as(format="gif") if not user.is_avatar_animated(): url = user.avatar_url_as(static_format="png") await ctx.send("{}".format(url))
async def avatar(self, ctx, *, user: Member=None): user = user or ctx.author _format = "gif" if user.is_avatar_animated() else "png" avatar = user.avatar_url_as(format=_format) resp = await self.session.get(str(avatar)) image = await resp.read() await ctx.send(file=File(BytesIO(image), f"Avatar.{_format}"))
async def avatar(self, ctx, *, user: discord.Member = None): """Returns user avatar URL. User argument can be user mention, nickname, username, user ID. Default to yourself when no argument is supplied. """ author = ctx.author if not user: user = author if user.is_avatar_animated(): url = user.avatar_url_as(format="gif") if not user.is_avatar_animated(): url = user.avatar_url_as(static_format="png") await ctx.send("{}'s Avatar URL : {}".format(user.name, url))
async def get_avatar(self, ctx, *, user: Member): url = str(user.avatar_url) response = await self.bot.session.get(url) ext = 'png' if user.is_avatar_animated(): ext = 'gif' img_stream = BytesIO(await response.read()) await ctx.send(file=File(fp=img_stream, filename=f'avatar.{ext}'))
async def avatar(self, ctx, member: discord.Member = None): async with ctx.channel.typing(): if member is None: member = ctx.message.author if member.is_avatar_animated(): async with self.session.get( member.avatar_url_as(format="gif")) as resp: data = await resp.read() file = discord.File(io.BytesIO(data), filename="{}.gif".format(member.name)) if not member.is_avatar_animated(): async with self.session.get( member.avatar_url_as(static_format="png")) as resp: data = await resp.read() file = discord.File(io.BytesIO(data), filename="{}.png".format(member.name)) await ctx.send(file=file)
async def user_info(self, ctx, user: discord.Member): """ Gives info about a user Name: The user's name Discriminator: 4 digits after the user's name #XXXX Display name: The user's nickname on this server, if the user doesn't have a nickname it's just the name ID: The unique user ID Is bot?: True if the user is a bot, False otherwise Created at: The date and time the user's account was created Joined at: The date and time the user joined this server Is avatar animated?: True if user's avatar is animated, False if not Is mobile: True if user is on mobile, False otherwise Status: The user's overall status Mobile status: The user's status on mobile Desktop status: The user's status on desktop Web status: The user's status on web Top role: User's highest role on this server Voice state: Returs the user's curent voice state in this server """ embed = discord.Embed(title="User info", color=0x00fff2) embed.set_author(name=f"{user.name}#{user.discriminator}", icon_url=user.avatar_url) embed.add_field(name="Name:", value=user.name, inline=False) embed.add_field(name="Discriminator:", value=user.discriminator, inline=False) embed.add_field(name="Display name (nickname):", value=user.display_name, inline=False) embed.add_field(name="ID:", value=user.id, inline=False) embed.add_field(name="Is avatar animated?:", value=user.is_avatar_animated(), inline=False) embed.add_field(name="Is bot?:", value=user.bot, inline=False) embed.add_field(name="Created at:", value=user.created_at, inline=False) embed.add_field(name="Joined server at:", value=user.joined_at, inline=False) embed.add_field(name="Is Mobile?:", value=user.is_on_mobile(), inline=False) embed.add_field(name="Status:", value=user.status, inline=False) embed.add_field(name="Mobile status:", value=user.mobile_status, inline=False) embed.add_field(name="Desktop status:", value=user.desktop_status, inline=False) embed.add_field(name="Web status:", value=user.web_status, inline=False) embed.add_field(name="Top role:", value=user.top_role, inline=False) embed.add_field(name="Voice state:", value=user.voice, inline=False) await ctx.send(embed=embed)
async def avatar(self, ctx, user: discord.Member = None): """ Gets a users avatar. """ user = ctx.author if not user else user ft = "gif" if user.is_avatar_animated() else "png" embed = discord.Embed(colour=discord.Colour.purple(), title=f"{user.name}'s Avatar", url=f"{user.avatar_url_as(format=ft)}") await ctx.send(embed=embed.set_image( url=f"{user.avatar_url_as(format=ft)}"))
async def about(self, ctx, member: discord.Member = None): """About a member""" if member is None: author = ctx.message.author embed = discord.Embed(colour=author.colour) embed.set_thumbnail(url=author.avatar_url) embed.add_field(name='Joined at', value=author.joined_at, inline=True) embed.add_field(name='Nickname', value=author.nick if author.nick else 'N/A', inline=True) embed.add_field(name='Status', value=author.status, inline=True) embed.add_field( name='Animated Avatar', value='Yes' if author.is_avatar_animated() else 'No', inline=True) roles = [] for role in author.roles: roles.append(role.name) roles.pop(0) embed.add_field( name='Roles', value='N/A' if len(roles) == 0 else ', '.join(roles), inline=True) await ctx.send(content='ℹ About **yourself**!', embed=embed) else: embed = discord.Embed(colour=member.colour) embed.set_thumbnail(url=member.avatar_url) embed.add_field(name='Joined at', value=member.joined_at, inline=True) embed.add_field(name='Nickname', value=member.nick if member.nick else 'N/A', inline=True) embed.add_field(name='Status', value=member.status, inline=True) embed.add_field( name='Animated Avatar', value='Yes' if member.is_avatar_animated() else 'No', inline=True) roles = [] for role in member.roles: roles.append(role.name) roles.pop(0) embed.add_field( name='Roles', value='N/A' if len(roles) == 0 else ', '.join(roles), inline=True) await ctx.send(content=f'ℹ About **{member.display_name}**', embed=embed)
async def userinfo(self, ctx, user: discord.Member = None): """Get a users info.""" lang = await self.bot.redis.get(f"{ctx.message.author.id}-lang") if lang: lang = lang.decode('utf8') else: lang = "english" if user == None: user = ctx.message.author try: playinggame = user.activity.title except: playinggame = None server = ctx.message.guild embed = discord.Embed(color=0xDEADBF) embed.set_author(name=user.name, icon_url=user.avatar_url) embed.add_field(name=getlang(lang)["general"]["userinfo"]["id"], value=user.id) embed.add_field(name=getlang(lang)["general"]["userinfo"]["discrim"], value=user.discriminator) embed.add_field(name=getlang(lang)["general"]["userinfo"]["bot"], value=str(user.bot)) embed.add_field(name=getlang(lang)["general"]["userinfo"]["created"], value=user.created_at.strftime("%d %b %Y %H:%M")) embed.add_field(name=getlang(lang)["general"]["userinfo"]["joined"], value=user.joined_at.strftime("%d %b %Y %H:%M")) embed.add_field( name=getlang(lang)["general"]["userinfo"]["animated_avatar"], value=str(user.is_avatar_animated())) embed.add_field(name=getlang(lang)["general"]["userinfo"]["playing"], value=playinggame) embed.add_field(name=getlang(lang)["general"]["userinfo"]["status"], value=user.status) embed.add_field(name=getlang(lang)["general"]["userinfo"]["color"], value=user.color) try: roles = [x.name for x in user.roles if x.name != "@everyone"] if roles: roles = sorted(roles, key=[ x.name for x in server.role_hierarchy if x.name != "@everyone" ].index) roles = ", ".join(roles) else: roles = "None" embed.add_field(name="Roles", value=roles) except: pass await ctx.send(embed=embed)
async def avatar(self, ctx, *, user: discord.Member = None): format = "gif" user = user or ctx.author if user.is_avatar_animated() != True: format = "png" avatar = user.avatar_url_as(format=format if format != "gif" else None) async with aiohttp.ClientSession() as session: async with session.get(str(avatar)) as resp: image = await resp.read() with io.BytesIO(image) as file: await ctx.send(file=discord.File(file, f"Avatar.{format}"))
async def avatar(self, ctx, *, member: discord.Member = None): format = "gif" member = member or ctx.author if member.is_avatar_animated() != True: format = "png" avatar = member.avatar_url_as( format=format if format is not "gif" else None) async with ctx.session.get(str(avatar)) as resp: image = await resp.read() with io.BytesIO(image) as file: await ctx.send(file=discord.File(file, f"DP.{format}"))
async def avatar(self, ctx, user: discord.Member = None): """Returns user avatar URL.""" author = ctx.author if user is None: user = author user_name = user.name.replace('_', '\_').replace('~', '\~').replace( '|', '\|').replace('*', '\*') embed = discord.Embed(title=f"{user_name}'s Avatar", color=user.color) if user.is_avatar_animated(): embed.set_image(url=user.avatar_url_as(format='gif', size=1024)) else: embed.set_image(url=user.avatar_url_as(format='png', size=1024)) await ctx.send(embed=embed)
async def avatar(self, ctx, user: discord.Member = None): if not user: user = ctx.author ext = 'gif' if user.is_avatar_animated() else 'png' ava = discord.Embed(title=f'{user.name}\'s avatar:', color=self.bot.embed_color, timestamp=ctx.message.created_at) ava.set_image(url=f"attachment://{user.id}.{ext}") ava.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=ava, file=discord.File(BytesIO(await user.avatar_url.read()), f"{user.id}.{ext}"))
async def avatar(self, ctx,member: discord.Member = None ): if member is None: embed = discord.Embed(title="از این دستور اینطور استفاده کن: ```+avatar [member]```", colour=0xff0000) await ctx.send(embed=embed) return else: embed2 = discord.Embed(title=f"آواتار {member} !", colour=0x0000ff) embed2.add_field(name="آواتار متحرک ؟", value=member.is_avatar_animated()) embed2.set_image(url=member.avatar_url) embed2.set_footer(text=f"Avatar requested by: {ctx.message.author} !") await ctx.send(embed=embed2)
async def on_fake_event(self, member: discord.Member): current = time.time() db = await self.get_guild_config(member.guild.id) if not db or not db.get("enabled"): return time_passed = current - self.last_check self.last_check = current self.allowance += time_passed * (self.rate / self.per) member_dict = { 'id': member.id, 'username': str(member), 'created_at': member.created_at, 'joined_at': member.joined_at, 'is_avatar_animated': member.is_avatar_animated(), 'activity': member.activity, 'activities': member.activities, 'is_on_mobile': member.is_on_mobile(), 'public_flags': member.public_flags # NOTE: Requires discord.py 1.4+ } if len(self.last_five) <= 5: self.last_five.append(member_dict) if self.allowance > self.rate: self.allowance = self.rate # throttle if self.allowance < 1.0: if not self.check_once: last_five = self.do_age_comparison(self.last_five) # To see if they all have the sameish creation date. if not len(last_five): # Do notification here return for account in last_five: sus = self.do_suspicious_check(account) if sus >= 0.5: self.raid_cache[member.guild.id]['raiders'].append(account) self.check_once = True self.sample.append(account) else: if len(self.sample): compare = self.sample compare.append(member_dict) if len(self.do_age_comparison(compare)): sus = self.do_suspicious_check(member_dict) # Just to prevent any false positives. if sus >= 0.5: self.raid_cache[member.guild.id]['raiders'].append(member_dict) else: return # If check once has been hit and there's no sample, the age comparison must've failed so nothing to do. else: self.allowance -= 1.0 if self.last_five >= 5: self.last_five = [member_dict] # Clear the last five, but keep the most recent one. Just in case.
async def avatar(self, ctx, user: discord.Member = None): if not user: user = ctx.author ava = ctx.embed(title=f'{user.name}\'s avatar:') types = [ f"[{type}]({str(user.avatar_url_as(format=type))})" for type in ["webp", "png", "jpeg", "jpg"] ] if user.is_avatar_animated(): types.append(f"[gif]({str(user.avatar_url_as(format='gif'))})") ava.description = " | ".join(types) ava.set_image(url=user.avatar_url) await ctx.send(embed=ava)
async def av(ctx, *, user: discord.Member = None): await ctx.message.delete() print("[{:%H:%M:%S}]".format(datetime.datetime.now()), f"| [LOG] AV command executed") format = "gif" user = user or ctx.author if user.is_avatar_animated() != True: format = "png" avatar = user.avatar_url_as(format=format if format != "gif" else None) async with aiohttp.ClientSession() as session: async with session.get(str(avatar)) as resp: image = await resp.read() with io.BytesIO(image) as file: await ctx.send(file=discord.File(file, f"Avatar.{format}"))
async def av(self, ctx, member: discord.Member = None): member = member or ctx.author embed = discord.Embed(title=f"{member}'s avatar",color=member.color, timestamp=datetime.datetime.utcnow()) if not member.is_avatar_animated(): types = self.image_types[:-1] else: types = self.image_types modes = [] for type in types: modes.append([type, str(member.avatar_url_as(static_format=type.lower(), size=512))]) embed.description = ' | '.join(['[%s](%s)' % (i[0], i[1]) for i in modes]) embed.set_image(url=member.avatar_url) await ctx.send(embed=embed)
async def picsu(self, ctx, *, member: discord.Member = None): """gets the Display Picture of a user __**Parameters**__ • member – The tag, name or id of the user """ format = "gif" member = member or ctx.author if member.is_avatar_animated() != True: format = "png" avatar = member.avatar_url_as( format=format if format is not "gif" else None) async with ctx.session.get(str(avatar)) as resp: image = await resp.read() with io.BytesIO(image) as file: await ctx.send(file=discord.File(file, f"DP.{format}"))
async def avatar(self, ctx, *, member: discord.Member = None): """ Get someones or your own avatar """ member = member or ctx.author gif_or_png = f'[PNG]({member.avatar_url_as(format="png")})' if not member.is_avatar_animated() else f'[GIF]({member.avatar_url_as(format="gif")})' av = discord.Embed( title = f"{member.name}'s Avatar", color = 0x40aeff, description = f'{gif_or_png} | ' f'[JPG]({member.avatar_url_as(format="jpg")}) | ' f'[WEBP]({member.avatar_url_as(format="webp")})' ) av.set_image(url=member.avatar_url) await ctx.send(embed=av)
async def avatar(self, ctx, member: discord.Member = None): if member is None: embed = discord.Embed( title=" El comando usado deberia ser **!avatar [miembro]**", color=discord.Color.random(), footer=ctx.message.created_at) await ctx.send(embed=embed) else: embed2 = discord.Embed(title=f"Avatar! de {member}", color=discord.Color.random(), timestamp=ctx.message.created_at) embed2.add_field(name="Animado?", value=member.is_avatar_animated()) embed2.set_image(url=member.avatar_url) await ctx.send(embed=embed2)
async def format_page(self, menu: menus.MenuPages, member: discord.Member) -> discord.Embed: em = discord.Embed(title=_("**Avatar**"), colour=member.colour) url = str(member.avatar_url_as(static_format="png")) if member.is_avatar_animated(): url = str(member.avatar_url_as(format="gif")) em.set_image(url=url) try: em.set_author( name=f"{member} {f'~ {member.nick}' if member.nick else ''}", icon_url=url, url=url, ) except AttributeError: em.set_author(name=f"{member}", icon_url=url, url=url) em.set_footer(text=f"Page {menu.current_page + 1}/{self.get_max_pages()}") return em
async def avatar(self, ctx, member: discord.Member = None): if member is None: embed = discord.Embed( title= " Estas usando un comando erroneo, debes usar **w!avatar [miembro]**", color=discord.Color.random(), footer=ctx.message.created_at) await ctx.send(embed=embed) else: embed2 = discord.Embed(title=f"¡Avatar! del usuario {member}", color=discord.Color.random(), timestamp=ctx.message.created_at) embed2.add_field(name="¿Acaso el avatar es animado?", value=member.is_avatar_animated()) embed2.set_image(url=member.avatar_url) await ctx.send(embed=embed2)