Skip to content

Commit

Permalink
Merge pull request #326 from practical-python-org/fix/on-message-poin…
Browse files Browse the repository at this point in the history
…ts-update

fix: on message points update
  • Loading branch information
Xarlos89 authored Dec 5, 2023
2 parents b79e533 + c422edc commit 042a6bd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/zorak/cogs/utility/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ async def on_message(self, message: discord.Message):
"""When a member sends a message, give them 1 point."""
if message.author.bot:
return
self.bot.db_client.add_points_to_user(message.author.id, 1)
message_value = len(message.content.split(" "))
self.bot.db_client.add_points_to_user(message.author.id, abs(message_value))

@commands.Cog.listener()
async def on_message_delete(self, message: discord.Message):
"""When a member deletes a message, remove a point."""
message_value = len(message.content.split(" "))
mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
await mod_log.send(f"1 Point removed from {message.author} for deleting a message.")
self.bot.db_client.remove_points_from_user(message.author.id, 1)
await mod_log.send(f"{message_value} Point/s removed from {message.author} for deleting a message.")
self.bot.db_client.remove_points_from_user(message.author.id, abs(message_value))
#
# # TODO: Fix the backup command.
# # @commands.slash_command()
Expand Down

0 comments on commit 042a6bd

Please sign in to comment.