attributeerror str object has no attribute name

  discord, discord.py, python

import discord

from discord.ext import commands

PREFIX = ‘/’

client = commands.Bot( command_prefix = PREFIX )

@client.command()

@commands.has_permissions( administrator = True )

async def ban( ctx, member: discord.Member, *, reason = None ):

await ctx.channel.purge( limit = 1 )

await member.ban( reason = reason )

emb = discord.Embed( title = 'was banned!', colour = discord.Color.red(), description = 'This player was banned by' )

emb.set_author( name = member.name, icon_url = member.avatar_url )

emb.set_footer( text = ctx.author.name, icon_url = ctx.author.avatar_url )

emb.set_thumbnail( url = 'https://sm.ign.com/t/ign_ap/cover/o/observatio/observation_327s.128.jpg' )

await ctx.send( embed = emb )

print( member.name )

@client.command()

@commands.has_permissions( administrator = True )

async def unban( ctx, *, member ):

await ctx.channel.purge( limit = 1 )

emb = discord.Embed( title = 'was unbanned!', colour = discord.Colour.green() )

emb.set_author( name = member.name, icon_url = member.avatar_url )#проблемная строчка

emb.set_footer( text = ctx.author.name, icon_url = ctx.author.avatar_url )

emb.set_thumbnail( url = 'https://sm.ign.com/t/ign_ap/cover/o/observatio/observation_327s.128.jpg' )

banned_users = await ctx.guild.bans()

for ban_entry in banned_users:
    
    user = ban_entry.user
    
    await ctx.guild.unban( user )
    
    await ctx.send( embed = emb )

token = ‘my_token’

client.run( token )

При попытке забанить кого либо-либо: всё работает идеально, но при попытке разбанить: выдаёт ошибку "attributeerror str object has no attribute name", хотя код для разбана копировался напрямую из бана, и потом редактировался. Помогите пожалуйста и подскажите, как можно решить эту проблему?

Source: Python Questions

LEAVE A COMMENT