2024-01-09 01:27:09 +00:00
|
|
|
# on_message.py
|
2024-01-02 17:11:54 +00:00
|
|
|
import discord
|
2023-12-12 19:51:09 +00:00
|
|
|
from discord.ext import commands
|
2024-01-09 02:01:17 +00:00
|
|
|
|
2024-01-09 01:27:09 +00:00
|
|
|
from tux.utils.tux_logger import TuxLogger
|
2023-12-12 19:51:09 +00:00
|
|
|
|
2023-12-30 07:20:20 +00:00
|
|
|
logger = TuxLogger(__name__)
|
2023-12-12 19:51:09 +00:00
|
|
|
|
2023-12-30 07:28:25 +00:00
|
|
|
|
2023-12-12 19:51:09 +00:00
|
|
|
class OnMessage(commands.Cog):
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@commands.Cog.listener()
|
2024-01-02 17:11:54 +00:00
|
|
|
async def on_message(self, message: discord.Message):
|
2024-01-01 03:12:27 +00:00
|
|
|
"""This event is triggered whenever a message is sent in a channel.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
message (discord.Message): Represents a Discord message.
|
|
|
|
""" # noqa E501
|
2023-12-12 19:51:09 +00:00
|
|
|
if message.author == self.bot.user:
|
|
|
|
return
|
|
|
|
|
2023-12-29 15:28:47 +00:00
|
|
|
if message.content.startswith("!hello"):
|
|
|
|
await message.channel.send("Hello!")
|
2023-12-12 19:51:09 +00:00
|
|
|
|
|
|
|
|
2023-12-13 20:36:52 +00:00
|
|
|
async def setup(bot):
|
2023-12-30 07:28:25 +00:00
|
|
|
await bot.add_cog(OnMessage(bot))
|