From 5b0e8d3beebb21f99b7ceccf5499441dc9f8270b Mon Sep 17 00:00:00 2001 From: Giovani Date: Thu, 29 Jul 2021 11:36:21 -0400 Subject: [PATCH] feat: add message with prefix on mention --- pyvis.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pyvis.py b/pyvis.py index d7c49ac..cb49e4f 100644 --- a/pyvis.py +++ b/pyvis.py @@ -11,8 +11,9 @@ load_dotenv() DISCORD_BOT_TOKEN = os.getenv('DISCORD_BOT_TOKEN') DISCORD_GUILD_NAME = os.getenv('DISCORD_GUILD_NAME') +PREFIX = "!" -bot = commands.Bot(command_prefix='!') +bot = commands.Bot(command_prefix=PREFIX) @bot.event async def on_ready(): @@ -27,6 +28,19 @@ async def on_ready(): async def on_member_join(member): pass # TODO +@bot.event +async def on_message(message): + # avoid bot self trigger + if message.author == bot.user: + return + + # repsond with command prefix + if bot.user.mentioned_in(message) and not message.mention_everyone: + await message.channel.send(f"**My prefix in this server is:** `{PREFIX}`") + + # allow cogs to handle messages too + await bot.process_commands(message) + # override default help command menu = DefaultMenu('◀️', '▶️', '❌') bot.help_command = PrettyHelp(navigation=menu, color=discord.Colour.green())