Привет. Я пытаюсь решить проблему с модулем журнала с моим ботом разногласий.Я получаю сообщение об ошибке TypeError: format() argument after ** must be a mapping, not Attachment
cogs\core.py", line 351, in on_message_delete
delmessage.add_field(name='**Attachment**', value='[{filename}]({url})'.format(**attachment), inline=True)
TypeError: format() argument after ** must be a mapping, not Attachment
Я не уверен, что вызывает это.
Вот с чем я работаю:
async def on_message_delete(self, message):
guild = message.guild
author = message.author
bot_member = guild.me
time = dt.datetime.utcnow()
now = dt.datetime.utcnow()
if author.bot:
return
if not guild:
return
cleanmsg = message.content
for i in message.mentions:
cleanmsg = cleanmsg.replace(i.mention, str(i))
name = author
name = " ~ ".join((name.name, name.nick)) if name.nick else name.name
changes = True
if author.id != self.bot.user.id:
infomessage = "A message by {} was deleted.".format(message.author.mention, message.channel.mention)
delmessage = discord.Embed(description=infomessage, colour=discord.Color.purple(), timestamp=time)
delmessage.add_field(name="Message:", value=cleanmsg)
delmessage.set_footer(text="ID: {}".format(message.author.id))
delmessage.set_author(name=name + "'s message was deleted.", icon_url=message.author.avatar_url)
if message.attachments:
for attachment in message.attachments:
delmessage.add_field(name='**Attachment**', value='[{filename}]({url})'.format(**attachment), inline=True)
await self.bot.send_log_message(guild, embed=delmessage)