2024-03-17 18:49:12 +00:00
|
|
|
import discord
|
2024-03-25 12:46:55 +00:00
|
|
|
|
2024-03-17 18:49:12 +00:00
|
|
|
from lib import formatter
|
2024-07-17 12:01:12 +00:00
|
|
|
from lib.constants import CONST
|
2024-03-17 18:49:12 +00:00
|
|
|
|
|
|
|
|
2024-03-17 19:24:54 +00:00
|
|
|
def clean_error_embed(ctx):
|
2024-03-17 18:49:12 +00:00
|
|
|
embed = discord.Embed(
|
2024-07-17 11:47:26 +00:00
|
|
|
color=discord.Color.red(),
|
|
|
|
description=f"**{ctx.author.name}** ",
|
2024-03-17 18:49:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
return embed
|
|
|
|
|
|
|
|
|
2024-03-18 14:11:22 +00:00
|
|
|
class GenericErrors:
|
2024-03-29 11:14:41 +00:00
|
|
|
@staticmethod
|
|
|
|
def bad_arg(ctx, error):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = formatter.shorten(str(error), 100)
|
|
|
|
else:
|
|
|
|
embed.description += formatter.shorten(str(error), 100)
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
|
|
|
text=f"For more info do {formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}",
|
2024-07-12 17:42:06 +00:00
|
|
|
icon_url=CONST.QUESTION_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-18 14:11:22 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-04-26 12:54:08 +00:00
|
|
|
@staticmethod
|
|
|
|
def bad_url(ctx, error="the image URL must end with `.jpg` or `.png`."):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = formatter.shorten(str(error), 100)
|
|
|
|
else:
|
|
|
|
embed.description += formatter.shorten(str(error), 100)
|
2024-04-26 12:54:08 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-03-18 17:48:12 +00:00
|
|
|
@staticmethod
|
|
|
|
def private_message_only(ctx):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = "this command can only be used in private messages."
|
|
|
|
else:
|
|
|
|
embed.description += "this command can only be used in private messages."
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
|
|
|
text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
2024-07-12 17:42:06 +00:00
|
|
|
icon_url=CONST.QUESTION_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-18 17:48:12 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-03-19 07:34:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def guild_only(ctx):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = "this command can only be used in a server."
|
|
|
|
else:
|
|
|
|
embed.description += "this command can only be used in a server."
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
|
|
|
text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
2024-07-12 17:42:06 +00:00
|
|
|
icon_url=CONST.QUESTION_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-19 07:34:29 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-03-19 12:13:17 +00:00
|
|
|
@staticmethod
|
|
|
|
def channel_not_allowed(ctx, channel):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = f"you can only do that command in {channel.mention}."
|
|
|
|
else:
|
|
|
|
embed.description += f"you can only do that command in {channel.mention}."
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
2024-07-17 11:47:26 +00:00
|
|
|
text="This message will delete itself after 5s",
|
|
|
|
icon_url=CONST.EXCLAIM_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-19 12:13:17 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-03-18 14:11:22 +00:00
|
|
|
|
2024-03-17 18:49:12 +00:00
|
|
|
class EconErrors:
|
2024-03-17 19:24:54 +00:00
|
|
|
@staticmethod
|
|
|
|
def out_of_time(ctx):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = "you ran out of time."
|
|
|
|
else:
|
|
|
|
embed.description += "you ran out of time."
|
|
|
|
embed.set_footer(text="Your bet was forfeited", icon_url=CONST.EXCLAIM_ICON)
|
2024-03-17 19:24:54 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def already_playing(ctx):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
2024-07-15 12:36:18 +00:00
|
|
|
embed.description = (
|
|
|
|
f"you already have a game of {ctx.command.name} running."
|
|
|
|
)
|
2024-07-12 17:42:06 +00:00
|
|
|
else:
|
2024-07-15 12:36:18 +00:00
|
|
|
embed.description += (
|
|
|
|
f"you already have a game of {ctx.command.name} running."
|
|
|
|
)
|
|
|
|
embed.set_footer(
|
2024-07-17 11:47:26 +00:00
|
|
|
text="Please finish this game first",
|
|
|
|
icon_url=CONST.EXCLAIM_ICON,
|
2024-07-15 12:36:18 +00:00
|
|
|
)
|
2024-03-17 19:24:54 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
2024-03-17 20:44:21 +00:00
|
|
|
|
2024-03-19 17:35:51 +00:00
|
|
|
class MiscErrors:
|
|
|
|
@staticmethod
|
|
|
|
def prefix_too_long(ctx):
|
|
|
|
embed = clean_error_embed(ctx)
|
2024-07-12 17:42:06 +00:00
|
|
|
if embed.description is None:
|
|
|
|
embed.description = "this prefix is too long."
|
|
|
|
else:
|
|
|
|
embed.description += "this prefix is too long."
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
|
|
|
text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
2024-07-12 17:42:06 +00:00
|
|
|
icon_url=CONST.QUESTION_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-19 17:35:51 +00:00
|
|
|
|
|
|
|
return embed
|
|
|
|
|
|
|
|
|
2024-03-18 14:40:58 +00:00
|
|
|
class HelpErrors:
|
|
|
|
@staticmethod
|
|
|
|
def error_message(ctx, error):
|
|
|
|
"""
|
|
|
|
See discord.ext.commands.HelpCommand.send_error_message
|
|
|
|
"""
|
|
|
|
embed = clean_error_embed(ctx)
|
|
|
|
embed.description += error
|
2024-07-08 17:22:17 +00:00
|
|
|
embed.set_footer(
|
2024-07-17 11:47:26 +00:00
|
|
|
text=f"See '{formatter.get_prefix(ctx)}help'",
|
|
|
|
icon_url=CONST.EXCLAIM_ICON,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2024-03-18 14:40:58 +00:00
|
|
|
|
2024-03-25 14:48:00 +00:00
|
|
|
return embed
|