add automatic help message

This commit is contained in:
Infinidoge 2025-06-13 17:18:05 -04:00
parent cbe17c1bab
commit 684ba106d4
Signed by: Infinidoge
SSH key fingerprint: SHA256:GT2StvPQMMfFHyiiFJymQxfTG/z6EWLJ6NWItf5K5sA

View file

@ -1,3 +1,4 @@
import datetime
import io
import logging
import os
@ -7,6 +8,7 @@ import textwrap
import traceback
from contextlib import redirect_stdout
import disnake
from disnake import Embed, Guild, Intents, Message, Thread
from disnake.ext import commands
from disnake.ext.commands import Bot, Paginator
@ -189,6 +191,51 @@ async def on_error(event, *args, **kwargs):
log.error(f"Error in event {event}.\nargs={pargs}\nkwargs={pkwargs}", exc_info=sys.exc_info())
help_timeouts = {}
@bot.listen()
async def on_message(message: Message):
if message.author == bot.user:
return
ctx = await bot.get_context(message)
if ctx.valid:
return
now = disnake.utils.utcnow()
if timeout := help_timeouts.get(ctx.channel.id, None):
if now < timeout:
return
c = message.content.lower()
prefix = await bot.get_guild_prefix(ctx.guild) or "@nomen "
if "help" in c and "nomen" in c:
help_timeouts[ctx.channel.id] = now + datetime.timedelta(minutes=5)
await message.reply(f"""\
Heya!
- To add a keyword, use the command `{prefix}keyword add <words here>`
(`{prefix}keyword` can be shortened to `{prefix}kw`)
- To remove a keyword, use `{prefix}keyword remove <keyword>`
- To view all of your keywords, use `{prefix}keyword list`
- To ignore a person/channel/category, use `{prefix}keyword ignore <target>`
To unignore, `{prefix}keyword unignore <target>`
- To block a person across all servers, `{prefix}keyword block <target>`
To unblock, `{prefix}keyword unblock <target>`
- To pause/unpause notifications in a server, use `{prefix}keyword pause`/`{prefix}keyword unpause`
For other commands, see `{prefix}help`. Use `{prefix}help <command>` for detailed help.
If you are familiar with the Dusty bot (almost) all commands for Dusty work with Nomen, just replace `>` with `{prefix}`.
If you already have keywords in Dusty, you can import them into Nomen easily by:
1. Use `>notif list` to get your list of keywords from Dusty
2. Copy the list (**without the header/title**)
3. Run `{prefix}nomen import <paste list here>`
""")
@bot.command(hidden=True)
@commands.is_owner()
async def echo(ctx, arg):