[−][src]Macro command_attr::group
group!() { /* proc-macro */ }
Create a grouping of commands.
It is a prerequisite for all commands to be assigned under a common group, before they may be executed by a user.
A group might have one or more prefixes set. This will necessitate for
one of the prefixes to appear before the group's command.
For example, for a general prefix !
, a group prefix foo
and a command bar
,
the invocation would look like this: !foo bar
.
It might have some options apply to all of its commands. E.g. guild or dm only.
Its options may be inherited from another group.
It may even couple other groups as well.
This group macro purports all of the said purposes above, in a json-like syntax:
use command_attr::{command, group}; #[command] fn bar() { println!("baz"); } group!({ name: "baz", options: { prefixes: ["baz"] // Any sub-group **must** have a prefix. }, commands: [], }); group!({ name: "foo", options: { prefixes: ["foo"], }, commands: [bar], sub_groups: [baz], });
Options
These appear inside the object of the options
field:
-
prefixes
: ArrayThe group's prefixes. -
allowed_roles
: ArrayOnly which roles may execute this group's commands. -
only
: String Whether this group's commands are restricted toguilds
ordms
. -
owner_only
: Bool If only the owners of the bot may execute this group's commands. -
owner_privilege
: Bool Whether the owners should be treated as normal users.
Default value is true
help_available
: bool Whether the group is visible to the help command.
Default value is true
-
checks
: ArrayA set of preconditions that must be met before a group command's execution. Refer to command
'schecks
documentation. -
required_permissions
: ArrayA set of permissions needed by the user before a group command's execution. -
default_command
: Ident Command to be executed if none of the group's prefixes are given. Identifier must refer to a#[command]
'd function. -
prefix
: String Assign a single prefix to this group. -
description
: String The description of the group. Used in the help command. -
inherit
: Access Derive options from anotherGroupOptions
instance.
On standalone GroupOptions
: $name_of_options$
GroupOptions
belonging to another Group
: $name_of_group$.options