Changing from "target" to "member"

Made member an optional argument
pull/8/head
sgoudham 4 years ago
parent 188459ae8b
commit e8c66a5b2d

@ -5,7 +5,7 @@ from asyncio.subprocess import Process
from platform import python_version from platform import python_version
from time import time from time import time
from discord import Colour from discord import Colour, Member
from discord import Embed from discord import Embed
from discord import __version__ as discord_version from discord import __version__ as discord_version
from discord.ext import commands from discord.ext import commands
@ -63,25 +63,25 @@ class Info(commands.Cog):
@command(name="userinfo", aliases=["ui"]) @command(name="userinfo", aliases=["ui"])
@cooldown(1, 5, BucketType.user) @cooldown(1, 5, BucketType.user)
async def user_info(self, ctx, target=None): async def user_info(self, ctx, member: Member = None):
"""User Information! (Created At/Joined/Roles etc)""" """User Information! (Created At/Joined/Roles etc)"""
# If a target has been specified, set them as the user # If a member has been specified, set them as the user
if target: if member:
target = target member = member
# If no target has been specified, choose the author # If no member has been specified, choose the author
else: else:
target = ctx.author member = ctx.author
# Get the member avatar # Get the member avatar
userAvatar = target.avatar_url userAvatar = member.avatar_url
# Store all the roles that the user has # Store all the roles that the user has
# (Skipping the first element as it's always going to be @everyone) # (Skipping the first element as it's always going to be @everyone)
roles = f"{' '.join(map(str, (role.mention for role in target.roles[1:])))}" roles = f"{' '.join(map(str, (role.mention for role in member.roles[1:])))}"
# Returns the permissions that the user has within the guild # Returns the permissions that the user has within the guild
filtered = filter(lambda x: x[1], target.guild_permissions) filtered = filter(lambda x: x[1], member.guild_permissions)
# Replace all "_" with " " in each item and join them together # Replace all "_" with " " in each item and join them together
permission = ",".join(map(lambda x: x[0].replace("_", " "), filtered)) permission = ",".join(map(lambda x: x[0].replace("_", " "), filtered))
@ -95,20 +95,20 @@ class Info(commands.Cog):
timestamp=datetime.datetime.utcnow() timestamp=datetime.datetime.utcnow()
) )
embed.set_thumbnail(url=userAvatar) embed.set_thumbnail(url=userAvatar)
embed.set_footer(text=f"ID: {target.id}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"ID: {member.id}", icon_url='{}'.format(userAvatar))
# Define fields to be added into the embed # Define fields to be added into the embed
embed_fields = [("Name", str(target.mention), True), embed_fields = [("Name", str(member.mention), True),
("Tag", target.name, True), ("Tag", member.name, True),
("Discrim", "#" + target.discriminator, True), ("Discrim", "#" + member.discriminator, True),
("Registered", target.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True), ("Registered", member.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True),
("Joined", target.joined_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True), ("Joined", member.joined_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True),
("Top Role", target.top_role.mention, False), ("Top Role", member.top_role.mention, False),
("Roles", roles, False), ("Roles", roles, False),
("Key Permissions", permissions, False), ("Key Permissions", permissions, False),
("Status", str(target.status).title(), True), ("Status", str(member.status).title(), True),
("Boosting Server", bool(target.premium_since), True), ("Boosting Server", bool(member.premium_since), True),
("Bot", target.bot, True)] ("Bot", member.bot, True)]
# Add fields to the embed # Add fields to the embed
for name, value, inline in embed_fields: for name, value, inline in embed_fields:

Loading…
Cancel
Save