diff --git a/config/JSON/strings.json b/config/JSON/strings.json index b59bc55..1ea8acf 100644 --- a/config/JSON/strings.json +++ b/config/JSON/strings.json @@ -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`." } diff --git a/lib/embeds/error.py b/lib/embeds/error.py index 3ea5459..bf80dac 100644 --- a/lib/embeds/error.py +++ b/lib/embeds/error.py @@ -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) diff --git a/modules/config/__init__.py b/modules/config/__init__.py index 35bd855..5e4837f 100644 --- a/modules/config/__init__.py +++ b/modules/config/__init__.py @@ -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. diff --git a/modules/config/c_boost.py b/modules/config/c_boost.py index 68e0231..4f1000a 100644 --- a/modules/config/c_boost.py +++ b/modules/config/c_boost.py @@ -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()