API Reference

class discord.ext.levenshtein.Levenshtein(bot, max_length=3)[source]

The root of the module.

Creates a list of commands when on_ready is called, and dispatches the on_command_suggest coroutine when command_not_found is invoked.

Parameters
  • bot (Bot) – discord.py bot instance

  • max_length (int) –

    The Levenshtein distance threshold for considering a similar command. the Levenshtein distance is a string metric for measuring the difference between two sequences.

    Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other.

Note

When CommandNotFound exception is raised in discord.py, command_suggest event will be dispatched. The command_suggest event is given two arguments, the former is the Context(Context) and the latter is a list of similar commands (List(str)).