disagreement/docs/converters.md
Slipstreamm 9237d12a24 docs(imports): Update import paths in documentation examples
Adjust examples to reflect the new top-level exposure of classes and enums, such as `Client`, `Permissions`, `Embed`, and `Button`, making imports simpler.
2025-06-14 18:44:04 -06:00

1.0 KiB
Raw Permalink Blame History

Command Argument Converters

disagreement.ext.commands provides a number of built in converters that will parse string arguments into richer objects. These converters are automatically used when a command callback annotates its parameters with one of the supported types.

Supported Types

  • int, float, bool, and str
  • Member resolves a user mention or ID to a Member object for the current guild
  • Role resolves a role mention or ID to a Role object
  • Guild resolves a guild ID to a Guild object

Example

from disagreement.ext.commands import command
from disagreement import Member
from disagreement.ext.commands.core import CommandContext

@command()
async def kick(ctx: CommandContext, target: Member):
    await target.kick()
    await ctx.send(f"Kicked {target.display_name}")

Member.display_name returns the member's nickname if one is set, otherwise it falls back to the username.

The framework will automatically convert the first argument to a Member using the mention or ID provided by the user.