add additional debug logs for adding keywords

This commit is contained in:
Infinidoge 2024-12-20 01:14:52 -05:00
parent 57bf820501
commit ec54e31b5c
Signed by: Infinidoge
SSH key fingerprint: SHA256:GT2StvPQMMfFHyiiFJymQxfTG/z6EWLJ6NWItf5K5sA

View file

@ -152,12 +152,14 @@ class Notifications(Cog):
"""
if test_keyword(keyword, regex):
log.debug("Keyword too common")
await ctx.send(f"{'Regex' if regex else 'Keyword'} matches a word that is too common")
return
conflicts = await fetch_unpacked(ctx.bot.db, existing, params)
if conflicts:
log.debug("Keyword conflicts with existing keyword")
await ctx.send(f"Any instance of `{keyword}` would be matched by existing keywords (check DMs)")
await ctx.author.send(
f"Conflicts with keyword `{keyword}`:\n" + "\n".join(f"- `{conflict}`" for conflict in conflicts)
@ -167,12 +169,15 @@ class Notifications(Cog):
conflicts = await fetch_unpacked(ctx.bot.db, redundant, params)
if conflicts:
log.debug("Keyword renders existing redundant")
await ctx.send(f"Adding `{keyword}` will cause existing keywords to never match (check DMs)")
await ctx.author.send(
f"Keywords redundant from `{keyword}`:\n" + "\n".join(f" - `{conflict}`" for conflict in conflicts)
)
return
log.debug("Keyword valid, adding")
await ctx.bot.db.execute(
"INSERT INTO keywords (guild_id, keyword, user_id, regex) VALUES (:guild_id, :keyword, :user_id, :regex)",
params,