dimscmd/common

  Source   Edit

Types

ChatCommandProc = proc (s: Shard; m: Message): Future[void]
  Source   Edit
Command = ref object
  names*: seq[string]        ## The name includes the command groups
  description*: string
  parameters*: seq[ProcParameter]
  guildID*: string
  case kind*: CommandType
  of ctSlashCommand:
      slashHandler*: SlashCommandProc

  of ctChatCommand:
      chatHandler*: ChatCommandProc
      nil

  
  Source   Edit
CommandGroup = ref object
  name*: string
  case isleaf*: bool
  of true:
      command*: Command

  of false:
      children*: seq[CommandGroup]
      description*: string

  
  Source   Edit
CommandHandler = ref object
  discord*: DiscordClient
  applicationID*: string
  msgVariable*: string
  chatCommands*: CommandGroup
  slashCommands*: CommandGroup
  Source   Edit
CommandType = enum
  ctChatCommand, ctSlashCommand
A chat command is a command that is sent to the bot over chat A slash command is a command that is sent using the slash commands functionality in discord   Source   Edit
EnumOption = object
  name*: string
  value*: string
  Source   Edit
ProcParameter = object
  name*: string
  kind*: string
  optional*: bool
  future*: bool
  sequence*: bool
  isEnum*: bool
  array*: bool
  options*: seq[EnumOption]
  help*: string
  Source   Edit
ProcParameterSetting = enum
  Optional, Future, Sequence, Array, Enum
  Source   Edit
SlashCommandProc = proc (s: Shard; i: Interaction): Future[void]
  Source   Edit

Procs

func aliases(command: Command): seq[string] {....raises: [], tags: [].}
  Source   Edit
proc chatCommandsAll(cmd: CommandHandler): seq[Command] {....raises: [], tags: [].}
  Source   Edit
func flatten(group: CommandGroup; name = ""): seq[Command] {....raises: [],
    tags: [].}
Flattens a group into a sequence of tuples containing the path to the command and the command   Source   Edit
func get(root: CommandGroup; key: openArray[string]): Command {.
    ...raises: [KeyError, ValueError], tags: [].}
Returns the command that belongs to key   Source   Edit
func getGroup(root: CommandGroup; key: openArray[string]): CommandGroup {.
    ...raises: [KeyError, ValueError], tags: [].}
Like get except it returns the group that the command belongs to   Source   Edit
func getGuildID(root: CommandGroup): string {....raises: [], tags: [].}
Returns the first guildID for the first command   Source   Edit
func has(root: CommandGroup; key: openArray[string]): bool {....raises: [],
    tags: [].}
Returns true if the key points to a command or a command group   Source   Edit
func map(root: CommandGroup; cmd: Command) {....raises: [], tags: [].}
Maps the command to the tree. Gets the key from the command name   Source   Edit
func map(root: CommandGroup; key: openArray[string]; cmd: Command) {....raises: [],
    tags: [].}
Maps the command to the tree using key   Source   Edit
func mapAltPath(root: CommandGroup; a, b: openArray[string]) {.
    ...raises: [ValueError, KeyError], tags: [].}
Makes b also point to a Checks for ambiguity before adding   Source   Edit
func name(command: Command): string {....raises: [], tags: [].}
  Source   Edit
func newGroup(cmd: Command): CommandGroup {....raises: [], tags: [].}
Creates a leaf node from a command   Source   Edit
func newGroup(name: string; description: string;
              children: seq[CommandGroup] = @[]): CommandGroup {....raises: [],
    tags: [].}
Creates a group object which is used by the command handler for routing groups   Source   Edit
proc print(group: CommandGroup; depth = 1) {....raises: [], tags: [].}
Used for debugging, prints out the tree structure of the group. If the node is a handler then it is suffixed with -   Source   Edit
proc slashCommandsAll(cmd: CommandHandler): seq[Command] {....raises: [], tags: [].}
  Source   Edit