here's a good way to do it:
async def log(
self,
ctx,
desc,
title='**Title**',
color=0xff0000,
**kwargs
):
guild = ctx.guild
log_embed = discord.Embed(
title=title,
description=desc,
color=color
)
for key, value in kwargs.items():
if key == 'fields':
for field in value:
if len(field) == 2:
log_embed.add_field(
name=field[0],
value=field[1]
)
else:
log_embed.add_field(
name=field[0],
value=field[1],
inline=field[2]
)
if key == 'showauth':
if value:
author = ctx.author
disp_name = author.display_name
icon_url = author.avatar_url
log_embed.set_author(
name=disp_name,
icon_url=icon_url
)
log_embed.set_thumbnail(
url=icon_url
)
now = datetime.now()
log_embed.timestamp = now
log_channel = discord.utils.get(guild.text_channels, name="channel_name")
await log_channel.send(embed=log_embed)
also a quick example on using it:
await self.log(
ctx,
'tdescription here',
'title here',
discord.Color.blue(),
fields=[
('**Field**', "field value, you can add more fields")
],
showauth=True
)
# you can use message, title, color, field(s), and the showauth
embed=em
– XPOLKYT STUDIOS