mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 20:23:12 +00:00
chore: Update Luminara.py to handle blacklisted users properly
This commit is contained in:
parent
05561495ab
commit
747aa582bd
4 changed files with 19 additions and 3 deletions
|
@ -11,6 +11,7 @@ import services.config_service
|
|||
import services.help_service
|
||||
from lib.constants import CONST
|
||||
from services.blacklist_service import BlacklistUserService
|
||||
from lib.exceptions.LumiExceptions import Blacklisted
|
||||
from db.database import run_migrations
|
||||
|
||||
# Remove the default logger configuration
|
||||
|
@ -42,7 +43,9 @@ client = Client.LumiBot(
|
|||
|
||||
@client.check
|
||||
async def blacklist_check(ctx):
|
||||
return not BlacklistUserService.is_user_blacklisted(ctx.author.id)
|
||||
if BlacklistUserService.is_user_blacklisted(ctx.author.id):
|
||||
raise Blacklisted
|
||||
return True
|
||||
|
||||
|
||||
def load_modules():
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"lumi_exception_generic": "An error occurred.",
|
||||
"lumi_exception_blacklisted": "User is blacklisted",
|
||||
"admin_award_description": "awarded **${0}** to {1}.",
|
||||
"admin_award_title": "Awarded Currency",
|
||||
"admin_blacklist_author": "User Blacklisted",
|
||||
|
|
|
@ -11,7 +11,7 @@ from lib.exceptions import LumiExceptions
|
|||
|
||||
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.CommandNotFound):
|
||||
if isinstance(error, (commands.CommandNotFound, LumiExceptions.Blacklisted)):
|
||||
return
|
||||
|
||||
author_text = None
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from discord.ext import commands
|
||||
from lib.constants import CONST
|
||||
|
||||
|
||||
class BirthdaysDisabled(commands.CheckFailure):
|
||||
|
@ -14,6 +15,16 @@ class LumiException(commands.CommandError):
|
|||
A generic exception to raise for quick error handling.
|
||||
"""
|
||||
|
||||
def __init__(self, message="An error occurred."):
|
||||
def __init__(self, message=CONST.STRINGS["lumi_exception_generic"]):
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class Blacklisted(commands.CommandError):
|
||||
"""
|
||||
Raised when a user is blacklisted.
|
||||
"""
|
||||
|
||||
def __init__(self, message=CONST.STRINGS["lumi_exception_blacklisted"]):
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
|
|
Loading…
Reference in a new issue