Skip to content

Commit

Permalink
per server
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCos17 committed Oct 25, 2024
1 parent 8103b91 commit ea010c5
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions bell/bell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ class BellCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.config = Config.get_conf(self, identifier=492089091320446976)
default_user = {
"bell_count": 0
default_guild = {
"user_bell_counts": {} # Changed to store user counts per guild
}
self.config.register_user(**default_user)
self.config.register_guild(**default_guild) # Register guild-level configuration

@commands.command()
async def ringbell(self, ctx):
"""Rings a bell and increases the user's bell count."""
user = ctx.author
bell_count = await self.config.user(user).bell_count()
"""Rings a bell and increases the user's bell count in this server.""" # Updated docstring
user = ctx.author # Get the user who invoked the command
guild = ctx.guild # Get the guild (server) context
user_bell_counts = await self.config.guild(guild).user_bell_counts() # Get the user bell counts for the guild

# Increment the bell count
bell_count += 1
await self.config.user(user).bell_count.set(bell_count)
# Initialize the user's bell count
if user.id not in user_bell_counts:
user_bell_counts[user.id] = 0

# Increment the user's bell count
user_bell_counts[user.id] += 1
await self.config.guild(guild).user_bell_counts.set(user_bell_counts) # Update the counts in the config

# Send the message with the updated bell count for the user
await ctx.send(f"{user.mention} rang the bell! 🔔 You have rung the bell {user_bell_counts[user.id]} times in this server.")

# Send the message with the updated bell count
await ctx.send(f"{user.mention} rang the bell! 🔔 You have rung the bell {bell_count} times.")

# Send a bell ringing gif
gif_url = "https://github.com/BenCos17/ben-cogs/blob/main/bell/bell.gif?raw=true"
await ctx.send(gif_url) # Improved structure for sending the GIF
await ctx.send(gif_url)

0 comments on commit ea010c5

Please sign in to comment.