mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 22:23:13 +00:00
Fix a bunch of error outputs
This commit is contained in:
parent
243bad0e53
commit
9c79db5ec3
11 changed files with 27 additions and 146 deletions
|
@ -31,7 +31,7 @@ class GenericErrors:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bad_arg(ctx, error):
|
def bad_arg(ctx, error):
|
||||||
embed = clean_error_embed(ctx)
|
embed = clean_error_embed(ctx)
|
||||||
embed.description += str(error).lower()
|
embed.description += str(error)
|
||||||
embed.set_footer(text=f"For more info do {formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}",
|
embed.set_footer(text=f"For more info do {formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}",
|
||||||
icon_url=question_icon)
|
icon_url=question_icon)
|
||||||
|
|
||||||
|
@ -98,57 +98,6 @@ class GenericErrors:
|
||||||
|
|
||||||
|
|
||||||
class EconErrors:
|
class EconErrors:
|
||||||
@staticmethod
|
|
||||||
def missing_bet(ctx):
|
|
||||||
"""
|
|
||||||
See MissingRequiredArgument
|
|
||||||
"""
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "please enter a bet."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def missing_argument(ctx):
|
|
||||||
"""
|
|
||||||
See MissingRequiredArgument
|
|
||||||
"""
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "your command is missing an argument."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def bad_bet_argument(ctx):
|
|
||||||
"""
|
|
||||||
See BadArgument
|
|
||||||
"""
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "the bet you entered is invalid."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def bad_argument(ctx):
|
|
||||||
"""
|
|
||||||
See BadArgument
|
|
||||||
"""
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "the argument you entered is invalid."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def insufficient_balance(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "you don't have enough cash."
|
|
||||||
embed.set_footer(text=f"Do '{formatter.get_prefix(ctx)}balance' to see how much you can spend",
|
|
||||||
icon_url=question_icon)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def daily_already_claimed(ctx, unix_time):
|
def daily_already_claimed(ctx, unix_time):
|
||||||
|
@ -184,40 +133,6 @@ class BdayErrors:
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def invalid_date(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "the date you entered is invalid."
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def slash_command_only(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "you can use only slash commands for the birthday system."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def bad_month(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "I couldn't recognize that month."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def missing_arg(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "please enter a month and a day, in that order."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
class MiscErrors:
|
class MiscErrors:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -229,15 +144,6 @@ class MiscErrors:
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prefix_missing(ctx):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += "please specify a new prefix."
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def intro_no_guild(ctx):
|
def intro_no_guild(ctx):
|
||||||
embed = clean_error_embed(ctx)
|
embed = clean_error_embed(ctx)
|
||||||
|
@ -279,14 +185,3 @@ class IntroErrors:
|
||||||
icon_url=exclam_icon)
|
icon_url=exclam_icon)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
class ModErrors:
|
|
||||||
@staticmethod
|
|
||||||
def mod_error(ctx, error):
|
|
||||||
embed = clean_error_embed(ctx)
|
|
||||||
embed.description += error
|
|
||||||
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
|
|
||||||
icon_url=question_icon)
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
2
main.py
2
main.py
|
@ -35,7 +35,6 @@ logs = LoggingHandler.setup_logger()
|
||||||
|
|
||||||
@client.listen()
|
@client.listen()
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
|
|
||||||
if (
|
if (
|
||||||
message.author.bot or
|
message.author.bot or
|
||||||
message.guild is None or
|
message.guild is None or
|
||||||
|
@ -116,7 +115,6 @@ async def on_error(event: str, *args, **kwargs) -> None:
|
||||||
|
|
||||||
|
|
||||||
def load_modules():
|
def load_modules():
|
||||||
|
|
||||||
module_list = [d for d in os.listdir("modules") if os.path.isdir(os.path.join("modules", d))]
|
module_list = [d for d in os.listdir("modules") if os.path.isdir(os.path.join("modules", d))]
|
||||||
loaded_modules = set()
|
loaded_modules = set()
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ async def cmd(ctx, month, month_index, day):
|
||||||
max_days = calendar.monthrange(leap_year, month_index)[1]
|
max_days = calendar.monthrange(leap_year, month_index)[1]
|
||||||
|
|
||||||
if not (1 <= day <= max_days):
|
if not (1 <= day <= max_days):
|
||||||
return await ctx.respond(embed=BdayErrors.invalid_date(ctx))
|
raise commands.BadArgument("the date you entered is invalid.")
|
||||||
|
|
||||||
date_str = f"{leap_year}-{month_index:02d}-{day:02d}"
|
date_str = f"{leap_year}-{month_index:02d}-{day:02d}"
|
||||||
date_obj = datetime.datetime.strptime(date_str, '%Y-%m-%d')
|
date_obj = datetime.datetime.strptime(date_str, '%Y-%m-%d')
|
||||||
|
@ -32,7 +32,7 @@ async def get_month_name(string, mapping):
|
||||||
if string.startswith(month):
|
if string.startswith(month):
|
||||||
return mapping[month]
|
return mapping[month]
|
||||||
|
|
||||||
raise commands.BadArgument
|
raise commands.BadArgument("I couldn't recognize that month.")
|
||||||
|
|
||||||
|
|
||||||
async def get_month_index(string, mapping):
|
async def get_month_index(string, mapping):
|
||||||
|
|
|
@ -8,7 +8,7 @@ from config.parser import JsonCache
|
||||||
from lib import formatter
|
from lib import formatter
|
||||||
from lib.embeds.error import MiscErrors
|
from lib.embeds.error import MiscErrors
|
||||||
from lib.embeds.greet import Greet
|
from lib.embeds.greet import Greet
|
||||||
from modules.config import config, prefix
|
from modules.config import config, set_prefix
|
||||||
from services.GuildConfig import GuildConfig
|
from services.GuildConfig import GuildConfig
|
||||||
|
|
||||||
strings = JsonCache.read_json("strings")
|
strings = JsonCache.read_json("strings")
|
||||||
|
@ -41,13 +41,13 @@ class Config(commands.Cog):
|
||||||
)
|
)
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def setprefix_command(self, ctx, *, new_prefix: str):
|
async def setprefix_command(self, ctx, *, prefix: str):
|
||||||
"""
|
"""
|
||||||
Set the prefix for Racu in this server. The maximum length of a prefix is 25.
|
Set the prefix for Racu in this server. The maximum length of a prefix is 25.
|
||||||
Requires Manage Channels permissions.
|
Requires Manage Channels permissions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await prefix.set_cmd(ctx, new_prefix)
|
await set_prefix.set_cmd(ctx, prefix)
|
||||||
|
|
||||||
config = SlashCommandGroup("config", "server config commands.", guild_only=True,
|
config = SlashCommandGroup("config", "server config commands.", guild_only=True,
|
||||||
default_member_permissions=discord.Permissions(manage_channels=True))
|
default_member_permissions=discord.Permissions(manage_channels=True))
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Economy(commands.Cog):
|
||||||
try:
|
try:
|
||||||
member = await ctx.guild.fetch_member(user.id)
|
member = await ctx.guild.fetch_member(user.id)
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
raise commands.BadArgument
|
raise commands.BadArgument("I couldn't find that user in this server.")
|
||||||
|
|
||||||
return await give.cmd(ctx, member, amount)
|
return await give.cmd(ctx, member, amount)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
import pytz
|
import pytz
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
@ -43,9 +44,9 @@ async def cmd(ctx, bet: int):
|
||||||
# check if the user has enough cash
|
# check if the user has enough cash
|
||||||
player_balance = ctx_currency.balance
|
player_balance = ctx_currency.balance
|
||||||
if bet > player_balance:
|
if bet > player_balance:
|
||||||
return await ctx.respond(embed=EconErrors.insufficient_balance(ctx))
|
raise commands.BadArgument("you don't have enough cash.")
|
||||||
elif bet <= 0:
|
elif bet <= 0:
|
||||||
return await ctx.respond(embed=EconErrors.bad_bet_argument(ctx))
|
raise commands.BadArgument("the bet you entered is invalid.")
|
||||||
|
|
||||||
active_blackjack_games[ctx.author.id] = True
|
active_blackjack_games[ctx.author.id] = True
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,24 @@
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
|
from discord.ext import commands
|
||||||
from lib.embeds.error import EconErrors
|
from lib.embeds.error import EconErrors
|
||||||
from services.Currency import Currency
|
from services.Currency import Currency
|
||||||
|
|
||||||
|
|
||||||
async def cmd(ctx, user, amount):
|
async def cmd(ctx, user, amount):
|
||||||
if ctx.author.id == user.id:
|
if ctx.author.id == user.id:
|
||||||
embed = discord.Embed(
|
raise commands.BadArgument("you can't give money to yourself.")
|
||||||
color=discord.Color.red(),
|
|
||||||
description=f"You can't give money to yourself, silly."
|
|
||||||
)
|
|
||||||
return await ctx.respond(embed=embed)
|
|
||||||
elif user.bot:
|
elif user.bot:
|
||||||
embed = discord.Embed(
|
raise commands.BadArgument("you can't give money to a bot.")
|
||||||
color=discord.Color.red(),
|
|
||||||
description=f"You can't give money to a bot, silly."
|
|
||||||
)
|
|
||||||
return await ctx.respond(embed=embed)
|
|
||||||
|
|
||||||
# Currency handler
|
# Currency handler
|
||||||
ctx_currency = Currency(ctx.author.id)
|
ctx_currency = Currency(ctx.author.id)
|
||||||
target_currency = Currency(user.id)
|
target_currency = Currency(user.id)
|
||||||
|
|
||||||
try:
|
|
||||||
author_balance = ctx_currency.balance
|
author_balance = ctx_currency.balance
|
||||||
|
|
||||||
if author_balance < amount or author_balance <= 0:
|
if author_balance < amount or author_balance <= 0:
|
||||||
return await ctx.respond(embed=EconErrors.insufficient_balance(ctx))
|
raise commands.BadArgument("you don't have enough cash.")
|
||||||
|
|
||||||
target_currency.add_balance(amount)
|
target_currency.add_balance(amount)
|
||||||
ctx_currency.take_balance(amount)
|
ctx_currency.take_balance(amount)
|
||||||
|
@ -34,15 +26,9 @@ async def cmd(ctx, user, amount):
|
||||||
ctx_currency.push()
|
ctx_currency.push()
|
||||||
target_currency.push()
|
target_currency.push()
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
await ctx.respond("Something funky happened.. Sorry about that.", ephemeral=True)
|
|
||||||
print(e)
|
|
||||||
return
|
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
color=discord.Color.green(),
|
color=discord.Color.green(),
|
||||||
description=f"**{ctx.author.name}** gave **${Currency.format(amount)}** to {user.name}."
|
description=f"**{ctx.author.name}** gave **${Currency.format(amount)}** to {user.name}."
|
||||||
)
|
)
|
||||||
embed.set_footer(text="Say thanks! :)")
|
|
||||||
|
|
||||||
await ctx.respond(embed=embed)
|
await ctx.respond(embed=embed)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import random
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from lib.embeds.error import EconErrors
|
from lib.embeds.error import EconErrors
|
||||||
|
@ -22,9 +23,9 @@ async def cmd(self, ctx, bet):
|
||||||
# check if the user has enough cash
|
# check if the user has enough cash
|
||||||
player_balance = ctx_currency.balance
|
player_balance = ctx_currency.balance
|
||||||
if bet > player_balance:
|
if bet > player_balance:
|
||||||
return await ctx.respond(embed=EconErrors.insufficient_balance(ctx))
|
raise commands.BadArgument("you don't have enough cash.")
|
||||||
elif bet <= 0:
|
elif bet <= 0:
|
||||||
return await ctx.respond(embed=EconErrors.bad_bet_argument(ctx))
|
raise commands.BadArgument("the bet you entered is invalid.")
|
||||||
|
|
||||||
# # check if the bet exceeds the bet limit
|
# # check if the bet exceeds the bet limit
|
||||||
# bet_limit = int(resources["bet_limit"])
|
# bet_limit = int(resources["bet_limit"])
|
||||||
|
|
|
@ -5,7 +5,7 @@ from discord.ext import commands, bridge, tasks
|
||||||
from lib import checks
|
from lib import checks
|
||||||
from lib.embeds.info import MiscInfo
|
from lib.embeds.info import MiscInfo
|
||||||
from modules.misc import introduction, invite, backup, info
|
from modules.misc import introduction, invite, backup, info
|
||||||
from modules.config import prefix
|
from modules.config import set_prefix
|
||||||
|
|
||||||
|
|
||||||
class Misc(commands.Cog):
|
class Misc(commands.Cog):
|
||||||
|
@ -57,7 +57,7 @@ class Misc(commands.Cog):
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@checks.allowed_in_channel()
|
@checks.allowed_in_channel()
|
||||||
async def prefix_command(self, ctx):
|
async def prefix_command(self, ctx):
|
||||||
return await prefix.get_cmd(ctx)
|
return await set_prefix.get_cmd(ctx)
|
||||||
|
|
||||||
@bridge.bridge_command(
|
@bridge.bridge_command(
|
||||||
name="info",
|
name="info",
|
||||||
|
|
|
@ -8,7 +8,7 @@ from lib.embeds.error import ModErrors
|
||||||
from lib import checks
|
from lib import checks
|
||||||
from lib.embeds.info import MiscInfo
|
from lib.embeds.info import MiscInfo
|
||||||
from modules.misc import introduction, invite, backup, info
|
from modules.misc import introduction, invite, backup, info
|
||||||
from modules.config import prefix
|
from modules.config import set_prefix
|
||||||
|
|
||||||
|
|
||||||
class Moderation(commands.Cog):
|
class Moderation(commands.Cog):
|
||||||
|
|
Loading…
Reference in a new issue