asd
This commit is contained in:
parent
edf5e76c7f
commit
3e65bdef03
@ -69,6 +69,15 @@ class CountingCog(commands.Cog):
|
||||
parent=self.counting_group
|
||||
)
|
||||
self.counting_group.add_command(status_command)
|
||||
|
||||
# Set count command (admin only)
|
||||
set_count_command = app_commands.Command(
|
||||
name="setcount",
|
||||
description="Manually set the current count (Admin only)",
|
||||
callback=self.counting_set_count_callback,
|
||||
parent=self.counting_group
|
||||
)
|
||||
self.counting_group.add_command(set_count_command)
|
||||
|
||||
async def cog_load(self):
|
||||
"""Called when the cog is loaded."""
|
||||
@ -192,6 +201,40 @@ class CountingCog(commands.Cog):
|
||||
f"Channel: {channel.mention}\n"
|
||||
f"Current count: {current_count}\n"
|
||||
f"Next number: {current_count + 1}", ephemeral=False)
|
||||
|
||||
@app_commands.describe(number="The number to set the current count to.")
|
||||
async def counting_set_count_callback(self, interaction: discord.Interaction, number: int):
|
||||
"""Manually set the current count."""
|
||||
# Check if user has administrator permission
|
||||
if not interaction.user.guild_permissions.administrator:
|
||||
await interaction.response.send_message("❌ You need Administrator permissions to use this command.", ephemeral=True)
|
||||
return
|
||||
|
||||
guild_id = interaction.guild.id
|
||||
|
||||
# Check if counting is enabled
|
||||
if guild_id not in self.counting_channels:
|
||||
await self.load_counting_data(guild_id)
|
||||
if guild_id not in self.counting_channels:
|
||||
await interaction.response.send_message("❌ Counting is not enabled for this server. Use `/counting setchannel` first.", ephemeral=True)
|
||||
return
|
||||
|
||||
if number < 0:
|
||||
await interaction.response.send_message("❌ The count cannot be a negative number.", ephemeral=True)
|
||||
return
|
||||
|
||||
# Update count in database
|
||||
await settings_manager.set_setting(guild_id, 'counting_current_number', str(number))
|
||||
|
||||
# Update cache
|
||||
self.current_counts[guild_id] = number
|
||||
|
||||
# Reset last user as the count is manually set
|
||||
if guild_id in self.last_user:
|
||||
del self.last_user[guild_id]
|
||||
await settings_manager.set_setting(guild_id, 'counting_last_user', None) # Clear last user in DB
|
||||
|
||||
await interaction.response.send_message(f"✅ The count has been manually set to {number}. The next number is {number + 1}.", ephemeral=False)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message: discord.Message):
|
||||
|
Loading…
x
Reference in New Issue
Block a user