Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update embed #263

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions bot/extensions/custom_roles/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import datetime
from __future__ import annotations

import discord
from discord import app_commands, utils
Expand All @@ -16,16 +16,15 @@ def __init__(self, bot):
self.color_converter = commands.ColorConverter()

@staticmethod
def role_embed(heading: str, user: discord.Member, role: discord.Role):
def role_embed(heading: str, role: discord.Role):
embed = discord.Embed(
title=heading,
color=role.color,
timestamp=datetime.datetime.utcnow(),
timestamp=role.created_at,
)
embed.add_field(name="Name", value=utils.escape_markdown(role.name))
embed.add_field(name="Color", value=str(role.color))
embed.add_field(name="Created at", value=utils.format_dt(role.created_at))
embed.set_thumbnail(url=user.avatar)
embed.set_footer(text="Created at")
return embed

@app_commands.command()
Expand Down Expand Up @@ -71,7 +70,7 @@ async def myrole(
)

return await interaction.response.send_message(
embed=self.role_embed("**Custom Role has been assigned**", interaction.user, role),
embed=self.role_embed("**Custom Role has been assigned**", role),
ephemeral=True,
)

Expand All @@ -80,7 +79,9 @@ async def myrole(
# Return role information if no parameter is passed
if (name is None or name == before.name) and (color is None or color.value == before.color):
return await interaction.response.send_message(
embed=self.role_embed("Custom Role for", interaction.user, interaction.guild.get_role(before.role_id)),
embed=self.role_embed(
f"Custom Role for {interaction.user.mention}", interaction.guild.get_role(before.role_id)
),
ephemeral=True,
)

Expand All @@ -100,9 +101,7 @@ async def myrole(
self.bot.dispatch("custom_role_update", before, after)

return await interaction.response.send_message(
embed=self.role_embed(
"**Custom Role has been updated**", interaction.user, interaction.guild.get_role(before.role_id)
),
embed=self.role_embed("**Custom Role has been updated**", interaction.guild.get_role(before.role_id)),
ephemeral=True,
)

Expand Down
Loading