diff --git a/bot.py b/bot.py index e70e66e..38fb687 100644 --- a/bot.py +++ b/bot.py @@ -10,6 +10,8 @@ from pyzxz.pyzxz.pyzxz import ZeroXZero # :sob: from lastfmcollagegenerator.collage_generator import CollageGenerator # from catbox_async_uploader.catbox_async_uploader.core import CatboxAsyncUploader +import utils as u + class Bot(nerimity.Client): """Extended client class for extra functionality.""" def __init__(self, lastfm_api_key: str, lastfm_api_secret: str, @@ -101,7 +103,7 @@ class Bot(nerimity.Client): if not username: await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`).")) - elif username.startswith("[@:"): + elif u.is_mention(username): mentioned = self.get_user(username[3:-1]) try: username = await self.get_lastfm(mentioned.id) except Exception as e: diff --git a/utils.py b/utils.py index 08de67a..c4f25c9 100644 --- a/utils.py +++ b/utils.py @@ -37,3 +37,8 @@ def error_msg(message: str) -> str: def good_msg(message: str) -> str: return f"[#52ff54][Success] [#reset]{message}" + +def is_mention(mention: str) -> bool: + if not mention: return None + + return True if mention.startswith("[@:") else False