Add type hints to message handling functions for improved clarity

This commit is contained in:
Edgar P. Burkhart 2025-03-22 16:13:43 +01:00
parent be1cc61443
commit ef84fccac5
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -81,12 +81,12 @@ async def ai_reply(message):
await message.reply(answer)
async def react(message):
async def react(message: discord.Message) -> None:
await message.add_reaction(random.choice(message.guild.emojis))
@bot.listen("on_message")
async def on_message(message):
async def on_message(message: discord.Message) -> None:
if message.flags.ephemeral:
return
@ -105,7 +105,9 @@ async def on_message(message):
@bot.listen("on_reaction_add")
async def add_more_reaction(reaction, user):
async def add_more_reaction(
reaction: discord.Reaction, user: discord.Member | discord.User
) -> None:
if random.random() < 50 / 100:
logger.info(f"Copy reaction from {user}")
await reaction.message.add_reaction(reaction.emoji)
@ -123,7 +125,7 @@ async def react_message_edit(before: discord.Message, after: discord.Message) ->
@bot.listen("on_message")
async def rando_shuffle(message):
async def rando_shuffle(message: discord.Message) -> None:
if not message.flags.ephemeral and random.random() < 5 / 100 and message.guild:
logger.info(f"Message shuffle after message from {message.author}")
await try_shuffle(message.guild)