CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-py-cord

A modern, async-ready Python API wrapper for Discord with comprehensive bot development features

Overall
score

93%

Overview
Eval results
Files

task.mdevals/scenario-1/

Guild Action Logger

Build a Discord bot that logs administrative actions in a server to help server moderators track changes.

Requirements

Create a Discord bot with a /recent_actions slash command that:

  1. Fetches the 5 most recent administrative actions from the guild's audit log
  2. Displays each action in a readable format that includes:
    • The action type (e.g., "role created", "member kicked")
    • The user who performed the action
    • When the action occurred
  3. If a reason was provided for an action, displays it as well
  4. Handles the case where no actions are found gracefully

Implementation

@generates

API

import discord
from discord.ext import commands

class AuditLogger(commands.Cog):
    """Cog for logging guild administrative actions."""

    def __init__(self, bot: commands.Bot):
        """Initialize the audit logger."""
        pass

    @commands.slash_command(name="recent_actions", description="Display recent administrative actions")
    async def recent_actions(self, ctx: discord.ApplicationContext):
        """Fetch and display the 5 most recent administrative actions."""
        pass

Test Cases

  • When /recent_actions is invoked in a guild with no recent actions, the bot responds with a message indicating no actions found @test
  • When /recent_actions is invoked in a guild with 3 role creation actions, the bot displays those 3 actions with their timestamps and responsible users @test
  • When /recent_actions is invoked in a guild with 5 member kick actions that include reasons, the bot displays all 5 actions with their reasons @test

Dependencies { .dependencies }

py-cord { .dependency }

Provides Discord bot functionality and audit log access.

Install with Tessl CLI

npx tessl i tessl/pypi-py-cord

tile.json