Skip to content

Add !uptime prefix command to display bot runtime #9

@TrivCodez

Description

@TrivCodez

Description

Create a prefix command !uptime that shows how long the bot has been running since its last restart.

Task

  • Create prefixcommands/uptime.py
  • Track bot start time using time.time() or datetime
  • Calculate elapsed time (days, hours, minutes, seconds)
  • Format output as: Uptime: X days, Y hours, Z minutes
  • Follow existing pattern from prefixcommands/ping.py

Why this is good for beginners

  • Teaches time calculation and formatting
  • Introduces global state management
  • Simple math operations
  • Builds on existing command patterns
  • Immediate visual feedback

Example output

Bot Uptime: 2 days, 14 hours, 35 minutes

Files to modify

  • Create: prefixcommands/uptime.py
  • Modify: bot.py (add start_time variable and extension)

Acceptance Criteria

  • Command responds to !uptime
  • Shows accurate elapsed time
  • Works in both guilds and DMs
  • Format is human-readable
  • Code follows existing style with type hints
  • Bot start time persists across commands
  • Tested by running bot for several minutes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions