Skip to content

Commit

Permalink
Added XP multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
sarzz2 committed Oct 17, 2023
1 parent 4bb9a38 commit e70b64b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bot/extensions/levelling/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, bot):
self.bot = bot
self.ignored_channel = {}
self.required_xp = [0]
self.xp_boost = 1

async def cog_load(self):
for guild in self.bot.guilds:
Expand Down Expand Up @@ -45,7 +46,7 @@ async def on_message(self, message):
pass

# Generate random XP to be added
xp = random.randint(5, 25)
xp = random.randint(5, 25) * self.xp_boost
# Add the XP and update the DB
data = await Levels.insert_by_guild(guild_id=message.guild.id, user_id=message.author.id, total_xp=xp)
self.bot.dispatch("xp_updated", data=data, member=message.author, required_xp=self.required_xp)
Expand Down Expand Up @@ -140,6 +141,16 @@ async def levelling_rewards_list(self, interaction: core.InteractionType):

await interaction.response.send_message(f"{res}")

@app_commands.command()
@app_commands.checks.has_permissions(administrator=True)
async def xp_multiplier(self, interaction: core.InteractionType, multiplier: int):
"""Increase XP gain per message"""
if multiplier <= 0 or multiplier > 5:
return await interaction.response.send_message("Invalid multiplier value.(Max. 5)")

self.xp_boost = multiplier
return await interaction.response.send_message(f"XP multiplied by {multiplier}x.")


async def setup(bot: commands.Bot):
await bot.add_cog(Levelling(bot=bot))

0 comments on commit e70b64b

Please sign in to comment.