create error_msg function (+utils.py)
This commit is contained in:
parent
8f8eb83b43
commit
45ab8ce67a
2 changed files with 8 additions and 3 deletions
9
main.py
9
main.py
|
|
@ -3,6 +3,8 @@ import tomllib
|
|||
import nerimity
|
||||
import pylast
|
||||
|
||||
import utils
|
||||
|
||||
with open("config.toml", "rb") as f:
|
||||
config = tomllib.load(f)
|
||||
|
||||
|
|
@ -54,13 +56,14 @@ async def fm(ctx: nerimity.Context, params: str = ""):
|
|||
await ctx.send(f"Now playing for **{username}**: [{track_name}]({track_url}) by [{track_artist}]({track_artist_url})")
|
||||
else:
|
||||
await ctx.send(f"Last played for **{username}**: [{track_name}]({track_url}) by [{track_artist}]({track_artist_url})")
|
||||
|
||||
except IndexError:
|
||||
await ctx.send("[#e5323b]Error: User has no recent tracks or they're set to private.")
|
||||
await ctx.send(utils.error_msg("User has no recent tracks or they're set to private."))
|
||||
except pylast.WSError:
|
||||
await ctx.send("[#e5323b]Error: User not found.")
|
||||
await ctx.send(utils.error_msg("User not found."))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
await ctx.send("[#e5323b]Unknown error.")
|
||||
await ctx.send(utils.error_msg("Unknown error."))
|
||||
|
||||
@client.listen("on_ready")
|
||||
async def on_ready(params):
|
||||
|
|
|
|||
2
utils.py
Normal file
2
utils.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def error_msg(message: str):
|
||||
return f"[#e5323b][Error] [#reset]{message}"
|
||||
Loading…
Add table
Reference in a new issue