Skip to content

Commit

Permalink
Updates for pycord 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tiltowait committed Jun 7, 2024
1 parent 6e5f665 commit 5540a64
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 124 deletions.
8 changes: 4 additions & 4 deletions inconnu/character/display/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,21 @@ async def __get_embed(
if title == character.name:
profile_url = inconnu.profile_url(character.id)
else:
profile_url = discord.Embed.Empty
profile_url = None

embed = discord.Embed(
title=title,
description=message or "",
color=color or discord.Embed.Empty,
color=color or None,
url=profile_url,
)

embed.set_author(
name=owner.display_name if title in (None, character.name) else character.name,
icon_url=inconnu.get_avatar(owner),
)
embed.set_footer(text=footer or discord.Embed.Empty)
embed.set_thumbnail(url=thumbnail or discord.Embed.Empty)
embed.set_footer(text=footer or None)
embed.set_thumbnail(url=thumbnail or None)

can_emoji = await inconnu.settings.can_emoji(ctx)

Expand Down
12 changes: 3 additions & 9 deletions inconnu/character/images/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,6 @@ def add_pager_buttons(self):
if self.character.user == self.ctx.user.id:
self.add_item(self.manage_button)

def remove_all_items(self):
"""Remove all buttons."""
children = list(self.children)
for child in children:
self.remove_item(child)

async def respond(self):
"""Display the pager."""
embed = inconnu.utils.VCharEmbed(
Expand Down Expand Up @@ -225,11 +219,11 @@ async def _display_no_images(self, interaction: discord.Interaction):

async def mode_toggle(self, interaction: discord.Interaction | None):
"""Toggle between management and normal modes."""
self.clear_items()

if self.management_mode:
self.remove_all_items()
self.add_pager_buttons()
else:
self.remove_all_items()
self.add_item(self.promote_button)
self.add_item(self.demote_button)
self.add_item(self.delete_button)
Expand Down Expand Up @@ -304,6 +298,6 @@ async def on_timeout(self):
"""Delete the components."""
if self.children:
Logger.debug("IMAGES: View timed out; deleting components")
await self.message.edit_original_response(view=None)
await self.message.edit(view=None)
else:
Logger.debug("IMAGES: View timed out, but no components")
2 changes: 1 addition & 1 deletion inconnu/character/update/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def __update_character(ctx, character: "VChar", param: str, value: str) ->

async def update_help(ctx, err=None, ephemeral=True):
"""Display a help message that details the available keys."""
color = discord.Embed.Empty if err is None else 0xFF0000
color = None if err is None else 0xFF0000
embed = discord.Embed(title="Character Tracking", color=color)
embed.set_author(name=inconnu.bot.user.display_name)
embed.set_thumbnail(url=inconnu.bot.user.avatar)
Expand Down
4 changes: 2 additions & 2 deletions inconnu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __error_text(
async def report_update(*, ctx, character, title, message, **kwargs):
"""Display character updates in the update channel."""
if update_channel := await inconnu.settings.update_channel(ctx.guild):
msg = kwargs.pop("msg", discord.Embed.Empty)
msg = kwargs.pop("msg", None)
if msg:
msg = msg.jump_url

Expand All @@ -150,7 +150,7 @@ async def report_update(*, ctx, character, title, message, **kwargs):
title=title,
description=message,
url=msg,
color=kwargs.pop("color", discord.Embed.Empty),
color=kwargs.pop("color", None),
)
embed.set_author(name=character.name, icon_url=inconnu.get_avatar(ctx.user))
content = ""
Expand Down
2 changes: 1 addition & 1 deletion inconnu/misc/frenzy.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ async def __generate_report_task(ctx, msg, character, outcome):
character=character,
title="Frenzy Success" if outcome.is_successful else "Frenzy Failure",
message=f"**{character.name}** {verbed} a frenzy check.",
color=0x880000 if outcome.is_failure else discord.Embed.Empty,
color=0x880000 if outcome.is_failure else None,
)
2 changes: 1 addition & 1 deletion inconnu/misc/remorse.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ async def __report(ctx, inter, character, remorseful):
character=character,
title="Remorse Success" if remorseful else "Remorse Failure",
message=f"**{character.name}** {verbed} a Remorse test.\n{humanity_str}",
color=0x5E005E if not remorseful else discord.Embed.Empty,
color=0x5E005E if not remorseful else None,
)
2 changes: 1 addition & 1 deletion inconnu/misc/rouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def rouse(
if character.hunger >= 4:
color = inconnu.constants.ROUSE_FAIL_COLOR
else:
color = discord.Embed.Empty
color = None

await inconnu.common.report_update(
ctx=ctx,
Expand Down
4 changes: 2 additions & 2 deletions inconnu/models/vchar.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ def has_biography(self) -> bool:
@property
def profile_image_url(self) -> str:
"""Get the URL of the first profile image."""
return self.profile.images[0] if self.profile.images else Embed.Empty
return self.profile.images[0] if self.profile.images else None

def random_image_url(self) -> str:
"""Get a random image URL."""
return random.choice(self.profile.images) if self.profile.images else Embed.Empty
return random.choice(self.profile.images) if self.profile.images else None

@property
def aggravated_hp(self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion inconnu/roleplay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def post_embed(
post_doc: inconnu.models.RPPost,
author: str = None,
footer: str = None,
icon_url=discord.Embed.Empty,
icon_url=None,
) -> discord.Embed:
"""Generate a Rolepost embed."""
embed = discord.Embed(
Expand Down
2 changes: 1 addition & 1 deletion inconnu/traits/add_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def __results_embed(ctx, outcome, character: "VChar", disciplines: bool):
# No color if no mistakes
# Black if some mistakes
# Red if only mistakes
color = discord.Embed.Empty
color = None
if unassigned + errors:
color = 0x000000 if assigned else 0xFF0000

Expand Down
2 changes: 1 addition & 1 deletion inconnu/traits/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def __outcome_embed(ctx, character, outcome, disciplines: bool):
if outcome.deleted:
deleted = ", ".join(map(lambda trait: f"`{trait}`", outcome.deleted))
embed.add_field(name="Removed", value=deleted)
embed.color = discord.Embed.Empty
embed.color = None

if outcome.errors:
errs = ", ".join(map(lambda error: f"`{error}`", outcome.errors))
Expand Down
4 changes: 2 additions & 2 deletions inconnu/utils/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def __init__(self, author, err: str, *fields, **kwargs):
self.add_field(name=name, value=value, inline=False)

self.set_footer(
text=kwargs.get("footer", discord.Embed.Empty),
icon_url=kwargs.get("footer_icon", discord.Embed.Empty),
text=kwargs.get("footer", None),
icon_url=kwargs.get("footer_icon", None),
)
Loading

0 comments on commit 5540a64

Please sign in to comment.