Skip to main content
Admin commands require special permissions and are used for server moderation and spam system management.

Permission Requirements

Admin commands use Discord.py permission decorators:
@commands.has_permissions(administrator=True)
# Full admin access required
Zorcuz (user ID: 708005339282276392) is treated as an administrator for command execution purposes, even if lacking formal Discord permissions.

Delete Messages Command

Bulk delete messages from the current channel.
$borrar <cantidad>
cantidad
integer
required
Number of messages to delete (1-100)

Permission Required

manage_messages - Source: main.py:528

Behavior

1

Validate Quantity

Checks if quantity is between 1 and 100
2

Delete Command Message

Removes the command message itself
3

Purge Messages

Deletes the specified number of messages
4

Confirm Action

Sends confirmation message that auto-deletes after 3 seconds

Examples

$borrar 10
# Response: "Se borraron **10** mensajes."

Error Handling

Missing Permissions:
No tengo permisos para borrar mensajes.
The bot needs manage_messages permission in the channel.
HTTP Error:
Error al borrar mensajes: {error_details}
Discord API errors are caught and displayed.

Logging

All deletions are logged to console:
print(f"[MODERACIÓN] {ctx.author} borró {len(mensajes_borrados)} mensajes en #{ctx.channel.name}")
Source: main.py:527-555

Activate Spam Command

Enable the automated spam system to send periodic messages.
$activarspam

Permission Required

administrator=True - Source: main.py:486

Behavior

  1. Checks if spam messages are configured
  2. Verifies if spam is already active
  3. Starts the periodic spam task (runs every 12 hours)
  4. Confirms activation

Response Messages

Spam automático **ACTIVADO**. Se enviará un mensaje cada 12 horas.
El spam automático ya está activo.
**ERROR:** No hay mensajes configurados. Agrega mensajes primero.

Technical Details

The command starts a Discord.py task loop:
if spam_periodico.is_running():
    await ctx.send("El spam automático ya está activo.")
else:
    spam_periodico.start()
    await ctx.send("Spam automático **ACTIVADO**...")

Spam System Configuration

  • Frequency: Every 12 hours
  • Target Channel: ID 1004171793101230151
  • Message Source: mensajes_random list
  • Anti-Repeat: Uses obtener_mensaje_sin_repetir() to cycle through all messages before repeating
Source: main.py:485-498, Task: main.py:408-418

Deactivate Spam Command

Disable the automated spam system.
$desactivarspam

Permission Required

administrator=True - Source: main.py:501

Behavior

  1. Checks if spam task is running
  2. Cancels the periodic task
  3. Confirms deactivation

Response Messages

Spam automático **DESACTIVADO**.
El spam automático ya está desactivado.

Implementation

if spam_periodico.is_running():
    spam_periodico.cancel()
    await ctx.send("Spam automático **DESACTIVADO**.")
else:
    await ctx.send("El spam automático ya está desactivado.")

Logging

Logs deactivation events:
print(f"[ADMIN] Spam automático desactivado por {ctx.author}")
Source: main.py:500-509

Admin Help Display

When admins run $help admin, they see additional AI command options:
**COMANDOS DE ADMINISTRADOR:**

`$borrar <cantidad>` - Borra mensajes del canal (1-100)
`$activarspam` - Activa el spam automático
`$desactivarspam` - Desactiva el spam automático
`$permisos` - Ver permisos del bot en el servidor y canal

**COMANDOS POR IA (etiqueta @chimbot):**
`@chimbot borra X mensajes` - Borra X mensajes (requiere admin)
`@chimbot activa/activa el spam` - Activa spam automático
`@chimbot desactiva/detén el spam` - Desactiva spam automático
`@chimbot status del spam` - Ver estado del spam
`@chimbot envía un mensaje de prueba` - Test del spam
Source: main.py:450-455

Permission Validation

The bot validates permissions before executing admin commands:

Traditional Commands

Uses decorators that automatically check permissions:
@bot.command(name='borrar')
@commands.has_permissions(manage_messages=True)
async def borrar_mensajes(ctx, cantidad: int):
    # Command implementation

AI-Interpreted Commands

Manual permission checking in the execution handler:
es_admin = message.author.guild_permissions.administrator
es_zorcuz = user_id == ZORCUZ_ID

# Zorcuz is considered admin
puede_ejecutar_admin = es_admin or es_zorcuz

if not puede_ejecutar_admin:
    await message.channel.send("No tienes permisos para usar comandos de administrador.")
    return True
Source: main.py:304-319 (AI commands), main.py:528 (traditional commands)

Error Messages

When non-admins attempt to use admin commands:
No tienes permisos para usar este comando.
This error is handled by the global error handler:
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("No tienes permisos para usar este comando.")
Source: main.py:819-826

Best Practices

Test Before Activating: Always use $testspam before running $activarspam to ensure messages are configured correctly.
Check Permissions: Run $permisos to verify the bot has necessary permissions before using admin commands.
Message Deletion is Permanent: The $borrar command permanently deletes messages. Use with caution.

Next Steps

AI Commands

Learn about natural language admin commands

Spam System

Understand the automated spam system

Build docs developers (and LLMs) love