@Bot.command()
async def infouser(self, ctx, member: discord.Member = None):
member = ctx.author if not member else member
roles = [role for role in member.roles[1:]]
time_to_join_in_discord = member.created_at
time_to_join_in_server = member.joined_at
now = datetime.now()
delta_s = now - time_to_join_in_server
delta_d= now - time_to_join_in_discord
b = delta_d.days
a = delta_s.days
if member.bot is False and member.nick is not None:
emb = discord.Embed(title=format(member), colour=discord.Color.green(), url=f'{member.avatar_url}', timestamp=ctx.message.created_at ,inline=False)
emb.add_field(name='Присоединился к Discord',value=f'{member.created_at.strftime("%d.%m.%Y %H:%M")}\n ({b} дней)',inline=False)
emb.add_field(name='Присоединился к серверу',value=f'{member.joined_at.strftime("%d.%m.%Y %H:%M")}\n ({a} дней)',inline=False)
emb.add_field(name=f'Роли ({(len(roles))})',value=" ".join([role.mention for role in roles]), inline=False)
emb.add_field(name='Самая высокая роль', value=str(member.top_role.mention), inline=False)
emb.add_field(name='Айди', value=member.id, inline=False)
if member.status == discord.Status.online:
emb.add_field(name='Status', value=':green_circle: Онлайн', inline=False)
elif member.status == discord.Status.dnd:
emb.add_field(name='Status', value=':no_entry: Не беспокоить', inline=False)
elif member.status == discord.Status.offline:
emb.add_field(name='Status', value=':black_circle: Нет в сети', inline=False)
elif member.status == discord.Status.idle:
emb.add_field(name='Status', value=':crescent_moon: Отошёл', inline=False)
if member.activity is not None:
emb.add_field(name='Кастом статус', value=member.activity, inline=False)
else:
emb.add_field(name='Кастом статус', value='Нету', inline=False)
emb.set_thumbnail(url=member.avatar_url)
emb.set_author(name=member.nick)
emb.set_footer(text='Запрос от: ' + f'{ctx.author}', icon_url=ctx.author.avatar_url)
await ctx.channel.purge(limit=1)
await ctx.send(embed=emb, delete_after = 120)
if member.bot is False and member.nick is None:
emb = discord.Embed(title=format(member), colour=discord.Color.green(), timestamp=ctx.message.created_at ,inline=False)
emb.add_field(name='Присоединился к Discord', value=f'{member.created_at.strftime("%d.%m.%Y %H:%M")}\n ({b} дней)', inline=False)
emb.add_field(name='Присоединился к серверу', value=f'{member.joined_at.strftime("%d.%m.%Y %H:%M")}\n ({a} дней)', inline=False)
emb.add_field(name=f'Роли ({(len(roles))})',value=" ".join([role.mention for role in roles]), inline=False)
emb.add_field(name='Самая высокая роль', value=str(member.top_role.mention), inline=False)
emb.add_field(name='Айди', value=member.id, inline=False)
if member.status == discord.Status.online:
emb.add_field(name='Status', value=':green_circle: Онлайн', inline=False)
elif member.status == discord.Status.dnd:
emb.add_field(name='Status', value=':no_entry: Не беспокоить', inline=False)
elif member.status == discord.Status.offline:
emb.add_field(name='Status', value=':black_circle: Нет в сети', inline=False)
elif member.status == discord.Status.idle:
emb.add_field(name='Status', value=':crescent_moon: Отошёл', inline=False)
if member.activity is not None:
emb.add_field(name='Кастом статус', value= member.activity,inline=False)
else:
emb.add_field(name='Кастом статус', value='Нету', inline=False)
emb.set_thumbnail(url=member.avatar_url)
emb.set_footer(text='Запрос от: ' + f'{ctx.author}', icon_url=ctx.author.avatar_url)
await ctx.channel.purge(limit=1)
await ctx.send(embed=emb, delete_after = 120)
if member.bot is True and member.nick is None:
emb = discord.Embed(title=format(member), colour=discord.Color.green(), url=f'{member.avatar_url}', timestamp=ctx.message.created_at, inline=False)
emb.add_field(name='Присоединился к Discord', value=f'{member.created_at.strftime("%d.%m.%Y %H:%M")}\n ({b} дней)', inline=False)
emb.add_field(name='Присоединился к серверу', value=f'{member.joined_at.strftime("%d.%m.%Y %H:%M")}\n ({a} дней)', inline=False)
emb.add_field(name=f'Роли ({(len(roles))})',value=" ".join([role.mention for role in roles]), inline=False)
emb.add_field(name='Самая высокая роль', value=str(member.top_role.mention), inline=False)
emb.add_field(name='Айди', value=member.id, inline=False)
if member.status == discord.Status.online:
emb.add_field(name='Status', value=':green_circle: Онлайн', inline=False)
elif member.status == discord.Status.dnd:
emb.add_field(name='Status', value=':no_entry: Не беспокоить', inline=False)
elif member.status == discord.Status.offline:
emb.add_field(name='Status', value=':black_circle: Нет в сети', inline=False)
elif member.status == discord.Status.idle:
emb.add_field(name='Status', value=':crescent_moon: Отошёл', inline=False)
emb.add_field(name='Кастомный статус', value=f'{member.activity}')
emb.set_thumbnail(url=member.avatar_url)
emb.set_footer(text='Запрос от: ' + f'{ctx.author}', icon_url=ctx.author.avatar_url)
await ctx.channel.purge(limit=1)
await ctx.send(embed=emb, delete_after = 120)
if member.bot is True and member.nick is not None:
emb = discord.Embed(title=format(member), colour=discord.Color.green(), url=f'{member.avatar_url}', timestamp=ctx.message.created_at, inline=False)
emb.add_field(name='Присоединился к Discord', value=f'{member.created_at.strftime("%d.%m.%Y %H:%M")}\n ({b} дней)', inline=False)
emb.add_field(name='Присоединился к серверу', value=f'{member.joined_at.strftime("%d.%m.%Y %H:%M")}\n ({a} дней)', inline=False)
emb.add_field(name=f'Роли ({(len(roles))})',value=" ".join([role.mention for role in roles]), inline=False)
emb.add_field(name='Самая высокая роль', value=str(member.top_role.mention), inline=False)
emb.add_field(name='Айди', value=member.id, inline=False)
if member.status == discord.Status.online:
emb.add_field(name='Status', value=':green_circle: Онлайн', inline=False)
elif member.status == discord.Status.dnd:
emb.add_field(name='Status', value=':no_entry: Не беспокоить', inline=False)
elif member.status == discord.Status.offline:
emb.add_field(name='Status', value=':black_circle: Нет в сети', inline=False)
elif member.status == discord.Status.idle:
emb.add_field(name='Status', value=':crescent_moon: Отошёл', inline=False)
emb.add_field(name='Кастомный статус',value=f'{member.activity}', inline=False)
emb.set_thumbnail(url=member.avatar_url)
emb.set_author(name=member.nick)
emb.set_footer(text='Запрос от: ' + f'{ctx.author}', icon_url=ctx.author.avatar_url)
await ctx.channel.purge(limit=1)
await ctx.send(embed=emb, delete_after = 120)
async def cog_command_error(self, ctx: commands.Context, error: commands.CommandError):
await ctx.send('Произошла ошибка: {}'.format(str(error)))
print(f'[{ctx.message.created_at}] [{ctx.message.guild.name}] [{ctx.message.guild.owner}] - [{error}]')
Сама ошибка:
Traceback (most recent call last):
File "D:\Games\Python\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:/Users/User/Desktop/myBot/Bot.py", line 15, in info
member = ctx.author if not member else member
AttributeError: 'str' object has no attribute 'author'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Games\Python\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "D:\Games\Python\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "D:\Games\Python\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'author'