lunarflu HF staff commited on
Commit
b049cc9
1 Parent(s): 0aa24a3

avatar url fixes for people without avatars

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -81,7 +81,7 @@ async def on_message_edit(before, after):
81
 
82
  if before.content != after.content:
83
  embed = Embed(color=Color.orange())
84
- embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url)
85
  embed.title = "Message Edited"
86
  embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
87
  embed.add_field(name="Author Username", value=before.author.name, inline=True)
@@ -107,7 +107,7 @@ async def on_message_delete(message):
107
  return
108
 
109
  embed = Embed(color=Color.red())
110
- embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url)
111
  embed.title = "Message Deleted"
112
  embed.description = message.content or "*(empty message)*"
113
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
@@ -137,7 +137,7 @@ async def on_member_update(before, after):
137
  """
138
  if before.nick != after.nick:
139
  embed = Embed(color=Color.orange())
140
- embed.set_author(name=f"{after} ID: {after.id}", icon_url=after.avatar.url)
141
  embed.title = "Nickname Modified"
142
  embed.add_field(name="Mention", value=after.mention, inline=True)
143
  embed.add_field(name="Old", value=before.nick, inline=True)
@@ -165,7 +165,7 @@ async def on_member_ban(guild, banned_user):
165
  # test 1106995261487710411
166
  content = "<@&1108342563628404747>" # @alerts role
167
  embed = Embed(color=Color.red())
168
- embed.set_author(name=f"{banned_user} ID: {banned_user.id}", icon_url=banned_user.avatar.url)
169
  embed.title = "User Banned"
170
  embed.add_field(name="User", value=banned_user.mention, inline=True)
171
  embed.add_field(name="Nickname", value=banned_user.nick, inline=True)
@@ -193,7 +193,7 @@ async def on_member_unban(guild, unbanned_user):
193
  created_and_age = f"{unbanned_user.created_at}"
194
  content = "<@&1108342563628404747>" # @alerts role
195
  embed = Embed(color=Color.red())
196
- embed.set_author(name=f"{unbanned_user} ID: {unbanned_user.id}", icon_url=unbanned_user.avatar.url)
197
  embed.title = "User Unbanned"
198
  embed.add_field(name="User", value=unbanned_user.mention, inline=True)
199
  embed.add_field(name="Account Created At", value=created_and_age, inline=True)
@@ -232,7 +232,7 @@ async def on_member_join(member):
232
  async def on_member_remove(member):
233
  try:
234
  embed = Embed(color=Color.blue())
235
- embed.set_author(name=f"{member} ID: {member.id}", icon_url=member.avatar.url)
236
  embed.title = "User Left"
237
  embed.add_field(name="Mention", value=member.mention, inline=True)
238
  embed.add_field(name="Nickname", value=member.nick, inline=True)
 
81
 
82
  if before.content != after.content:
83
  embed = Embed(color=Color.orange())
84
+ embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url if before.author.avatar else bot.user.avatar.url)
85
  embed.title = "Message Edited"
86
  embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
87
  embed.add_field(name="Author Username", value=before.author.name, inline=True)
 
107
  return
108
 
109
  embed = Embed(color=Color.red())
110
+ embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url if message.author.avatar else bot.user.avatar.url)
111
  embed.title = "Message Deleted"
112
  embed.description = message.content or "*(empty message)*"
113
  embed.add_field(name="Author Username", value=message.author.name, inline=True)
 
137
  """
138
  if before.nick != after.nick:
139
  embed = Embed(color=Color.orange())
140
+ embed.set_author(name=f"{after} ID: {after.id}", icon_url=after.avatar.url if after.avatar else bot.user.avatar.url)
141
  embed.title = "Nickname Modified"
142
  embed.add_field(name="Mention", value=after.mention, inline=True)
143
  embed.add_field(name="Old", value=before.nick, inline=True)
 
165
  # test 1106995261487710411
166
  content = "<@&1108342563628404747>" # @alerts role
167
  embed = Embed(color=Color.red())
168
+ embed.set_author(name=f"{banned_user} ID: {banned_user.id}", icon_url=banned_user.avatar.url if banned_user.avatar else bot.user.avatar.url)
169
  embed.title = "User Banned"
170
  embed.add_field(name="User", value=banned_user.mention, inline=True)
171
  embed.add_field(name="Nickname", value=banned_user.nick, inline=True)
 
193
  created_and_age = f"{unbanned_user.created_at}"
194
  content = "<@&1108342563628404747>" # @alerts role
195
  embed = Embed(color=Color.red())
196
+ embed.set_author(name=f"{unbanned_user} ID: {unbanned_user.id}", icon_url=unbanned_user.avatar.url if unbanned_user.avatar else bot.user.avatar.url)
197
  embed.title = "User Unbanned"
198
  embed.add_field(name="User", value=unbanned_user.mention, inline=True)
199
  embed.add_field(name="Account Created At", value=created_and_age, inline=True)
 
232
  async def on_member_remove(member):
233
  try:
234
  embed = Embed(color=Color.blue())
235
+ embed.set_author(name=f"{member} ID: {member.id}", icon_url=member.avatar.url if member.avatar else bot.user.avatar.url)
236
  embed.title = "User Left"
237
  embed.add_field(name="Mention", value=member.mention, inline=True)
238
  embed.add_field(name="Nickname", value=member.nick, inline=True)