mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 20:23:12 +00:00
chore: Update error messages for invalid image URLs
This commit is contained in:
parent
9a08d346c5
commit
c94f7d0d5a
4 changed files with 7 additions and 18 deletions
|
@ -176,5 +176,7 @@
|
|||
"xp_lb_field_value": "level: **{0}**\nxp: `{1}/{2}`",
|
||||
"xp_level": "Level {0}",
|
||||
"xp_progress": "Progress to next level",
|
||||
"xp_server_rank": "Server Rank: #{0}"
|
||||
"xp_server_rank": "Server Rank: #{0}",
|
||||
"error_image_url_invalid": "invalid image URL.",
|
||||
"error_boost_image_url_invalid": "the image URL must end with `.jpg` or `.png`."
|
||||
}
|
||||
|
|
|
@ -5,13 +5,11 @@ from lib.constants import CONST
|
|||
|
||||
|
||||
def clean_error_embed(ctx):
|
||||
embed = discord.Embed(
|
||||
return discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description=f"**{ctx.author.name}** ",
|
||||
)
|
||||
|
||||
return embed
|
||||
|
||||
|
||||
class GenericErrors:
|
||||
@staticmethod
|
||||
|
@ -28,16 +26,6 @@ class GenericErrors:
|
|||
|
||||
return embed
|
||||
|
||||
@staticmethod
|
||||
def bad_url(ctx, error="the image URL must end with `.jpg` or `.png`."):
|
||||
embed = clean_error_embed(ctx)
|
||||
if embed.description is None:
|
||||
embed.description = formatter.shorten(str(error), 100)
|
||||
else:
|
||||
embed.description += formatter.shorten(str(error), 100)
|
||||
|
||||
return embed
|
||||
|
||||
@staticmethod
|
||||
def private_message_only(ctx):
|
||||
embed = clean_error_embed(ctx)
|
||||
|
|
|
@ -85,7 +85,6 @@ class Config(commands.Cog):
|
|||
- Boosts
|
||||
- Levels
|
||||
- Modlog channel
|
||||
- XP rewards
|
||||
- Permissions preset (coming soon)
|
||||
|
||||
Running '/config show' will show a list of all available configuration types.
|
||||
|
|
|
@ -2,8 +2,8 @@ import discord
|
|||
from lib.embed_builder import EmbedBuilder
|
||||
from lib.constants import CONST
|
||||
from services.config_service import GuildConfig
|
||||
from lib.exceptions.LumiExceptions import LumiException
|
||||
from lib.embeds.boost import Boost
|
||||
from lib.embeds.error import GenericErrors
|
||||
|
||||
|
||||
async def set_boost_channel(ctx, channel: discord.TextChannel):
|
||||
|
@ -73,9 +73,9 @@ async def set_boost_image(ctx, image_url: str | None):
|
|||
guild_config.push()
|
||||
image_url = None
|
||||
elif not image_url.endswith((".jpg", ".png")):
|
||||
return await ctx.respond(embed=GenericErrors.bad_url(ctx))
|
||||
raise LumiException(CONST.STRINGS["error_boost_image_url_invalid"])
|
||||
elif not image_url.startswith(("http://", "https://")):
|
||||
return await ctx.respond(embed=GenericErrors.bad_url(ctx, "invalid URL."))
|
||||
raise LumiException(CONST.STRINGS["error_image_url_invalid"])
|
||||
else:
|
||||
guild_config.boost_image_url = image_url
|
||||
guild_config.push()
|
||||
|
|
Loading…
Reference in a new issue