Skip to content

Does better factoid fallback management for failed embed #1323

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
57 changes: 48 additions & 9 deletions techsupport_bot/commands/factoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,23 @@ async def response(
not in config.extensions.factoids.restricted_list.value
):
return
if not config.extensions.factoids.disable_embeds.value:
embed = self.get_embed_from_factoid(factoid)
else:

if config.extensions.factoids.disable_embeds.value:
embed = None
else:
try:
embed = self.get_embed_from_factoid(factoid)
except TypeError as exception:
log_channel = config.get("logging_channel")
await self.bot.logger.send_log(
message=f"Unable to make embed for factoid `{factoid.name}`, sending fallback.",
level=LogLevel.ERROR,
channel=log_channel,
context=LogContext(guild=ctx.guild, channel=ctx.channel),
exception=exception,
)
embed = None

# if the json doesn't include non embed argument, then don't send anything
# otherwise send message text with embed
try:
Expand Down Expand Up @@ -974,10 +987,23 @@ async def factoid_call_command(
)
await interaction.response.send_message(embed=embed, ephemeral=True)
return
if not config.extensions.factoids.disable_embeds.value:
embed = self.get_embed_from_factoid(factoid)
else:
if config.extensions.factoids.disable_embeds.value:
embed = None
else:
try:
embed = self.get_embed_from_factoid(factoid)
except TypeError as exception:
log_channel = config.get("logging_channel")
await self.bot.logger.send_log(
message=f"Unable to make embed for factoid `{factoid.name}`, sending fallback.",
level=LogLevel.ERROR,
channel=log_channel,
context=LogContext(
guild=interaction.guild, channel=interaction.channel
),
exception=exception,
)
embed = None
# if the json doesn't include non embed argument, then don't send anything
# otherwise send message text with embed
try:
Expand Down Expand Up @@ -1164,10 +1190,23 @@ async def cronjob(
return

# Get_embed accepts job as a factoid object
if not config.extensions.factoids.disable_embeds.value:
embed = self.get_embed_from_factoid(factoid)
else:
if config.extensions.factoids.disable_embeds.value:
embed = None
else:
try:
embed = self.get_embed_from_factoid(factoid)
except TypeError as exception:
log_channel = config.get("logging_channel")
await self.bot.logger.send_log(
message=(
f"Unable to make embed for factoid `{factoid.name}`, sending fallback."
),
level=LogLevel.ERROR,
channel=log_channel,
context=LogContext(guild=channel.guild, channel=channel),
exception=exception,
)
embed = None

try:
content = factoid.message if not embed else None
Expand Down
Loading