// FIXME: Remove this in a foreseeable future.
// Currently exists for backwards compatibility to previous Rust versions.
extern crate proc_macro;
use TokenStream;
use Span;
use quote;
use ;
pub
pub
pub
pub
use *;
use *;
use *;
use *;
/// The heart of the attribute-based framework.
///
/// This is a function attribute macro. Using this on other Rust constructs won't work.
///
/// ## Options
///
/// To alter how the framework will interpret the command,
/// you can provide options as attributes following this `#[command]` macro.
///
/// Each option has its own kind of data to stock and manipulate with.
/// They're given to the option either with the `#[option(...)]` or `#[option = ...]` syntaxes.
/// If an option doesn't require for any data to be supplied, then it's simply an empty `#[option]`.
///
/// If the input to the option is malformed, the macro will give you can error, describing
/// the correct method for passing data, and what it should be.
///
/// The list of available options, is, as follows:
///
/// | Syntax | Description | Argument explanation |
/// | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
/// | `#[checks(identifiers)]` | Preconditions that must met before the command's execution. | `identifiers` is a comma separated list of identifiers referencing functions marked by the `#[check]` macro |
/// | `#[aliases(names)]` | Alternative names to refer to this command. | `names` is a comma separated list of desired aliases. |
/// | `#[description(desc)]` </br> `#[description = desc]` | The command's description or summary. | `desc` is a string describing the command. |
/// | `#[usage(use)]` </br> `#[usage = use]` | The command's intended usage. | `use` is a string stating the schema for the command's usage. |
/// | `#[example(ex)]` </br> `#[example = ex]` | An example of the command's usage. May be called multiple times to add many examples at once. | `ex` is a string |
/// | `#[delimiters(delims)]` | Argument delimiters specific to this command. Overrides the global list of delimiters in the framework. | `delims` is a comma separated list of strings |
/// | `#[min_args(min)]` </br> `#[max_args(max)]` </br> `#[num_args(min_and_max)]` | The expected length of arguments that the command must receive in order to function correctly. | `min`, `max` and `min_and_max` are 16-bit, unsigned integers. |
/// | `#[required_permissions(perms)]` | Set of permissions the user must possess. | `perms` is a comma separated list of permission names.</br> These can be found at [Discord's official documentation](https://discord.com/developers/docs/topics/permissions). |
/// | `#[allowed_roles(roles)]` | Set of roles the user must possess. | `roles` is a comma separated list of role names. |
/// | `#[help_available]` </br> `#[help_available(b)]` | If the command should be displayed in the help message. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[only_in(ctx)]` | Which environment the command can be executed in. | `ctx` is a string with the accepted values `guild`/`guilds` and `dm`/`dms` (Direct Message). |
/// | `#[bucket(name)]` </br> `#[bucket = name]` | What bucket will impact this command. | `name` is a string containing the bucket's name.</br> Refer to [the bucket example in the standard framework](https://docs.rs/serenity/*/serenity/framework/standard/struct.StandardFramework.html#method.bucket) for its usage. |
/// | `#[owners_only]` </br> `#[owners_only(b)]` | If this command is exclusive to owners. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[owner_privilege]` </br> `#[owner_privilege(b)]` | If owners can bypass certain options. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[sub_commands(commands)]` | The sub or children commands of this command. They are executed in the form: `this-command sub-command`. | `commands` is a comma separated list of identifiers referencing functions marked by the `#[command]` macro. |
///
/// Documentation comments (`///`) applied onto the function are interpreted as sugar for the
/// `#[description]` option. When more than one application of the option is performed,
/// the text is delimited by newlines. This mimics the behaviour of regular doc-comments,
/// which are sugar for the `#[doc = "..."]` attribute.
///
/// # Notes
/// The name of the command is parsed from the applied function,
/// or may be specified inside the `#[command]` attribute, a lá `#[command("foobar")]`.
///
/// This macro attribute generates static instances of `Command` and `CommandOptions`,
/// conserving the provided options.
///
/// The names of the instances are all uppercased names of the command name.
/// For example, with a name of "foo":
/// ```rust,ignore
/// pub static FOO_COMMAND_OPTIONS: CommandOptions = CommandOptions { ... };
/// pub static FOO_COMMAND: Command = Command { options: FOO_COMMAND_OPTIONS, ... };
/// ```
/// A brother macro to [`command`], but for the help command.
/// An interface for simple browsing of all the available commands the bot provides,
/// and reading through specific information regarding a command.
///
/// As such, the options here will pertain in the help command's **layout** than its functionality.
///
/// ## Options
///
/// | Syntax | Description | Argument explanation |
/// |-----------------------------------------------------------------------------------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
/// | `#[suggestion_text(s)]` </br> `#[suggestion_text = s]` | When suggesting a command's name | `s` is a string |
/// | `#[no_help_available_text(s)]` </br> `#[no_help_available_text = s]` | When help is unavailable for a command. | `s` is a string |
/// | `#[usage_label(s)]` </br> `#[usage_label = s]` | How should the command be used. | `s` is a string |
/// | `#[usage_sample_label(s)]` </br> `#[usage_sample_label = s]` | Actual sample label. | `s` is a string |
/// | `#[ungrouped_label(s)]` </br> `#[ungrouped_label = s]` | Ungrouped commands label. | `s` is a string |
/// | `#[grouped_label(s)]` </br> `#[grouped_label = s]` | Grouped commands label. | `s` is a string |
/// | `#[sub_commands_label(s)]` </br> `#[sub_commands_label = s]` | Sub commands label. | `s` is a string
/// | `#[description_label(s)]` </br> `#[description_label = s]` | Label at the start of the description. | `s` is a string |
/// | `#[aliases_label(s)]` </br> `#[aliases_label= s]` | Label for a command's aliases. | `s` is a string |
/// | `#[guild_only_text(s)]` </br> `#[guild_only_text = s]` | When a command is specific to guilds only. | `s` is a string |
/// | `#[checks_label(s)]` </br> `#[checks_label = s]` | The header text when showing checks in the help command. | `s` is a string |
/// | `#[dm_only_text(s)]` </br> `#[dm_only_text = s]` | When a command is specific to dms only. | `s` is a string |
/// | `#[dm_and_guild_text(s)]` </br> `#[dm_and_guild_text = s]` | When a command is usable in both guilds and dms. | `s` is a string |
/// | `#[available_text(s)]` </br> `#[available_text = s]` | When a command is available. | `s` is a string |
/// | `#[command_not_found_text(s)]` </br> `#[command_not_found_text = s]` | When a command wasn't found. | `s` is a string |
/// | `#[individual_command_tip(s)]` </br> `#[individual_command_tip = s]` | How the user should access a command's details. | `s` is a string |
/// | `#[strikethrough_commands_tip_in_dm(s)]` </br> `#[strikethrough_commands_tip_in_dm = s]` | Reasoning behind strikethrough-commands.</br> *Only used in dms.* | `s` is a string. If not provided, default text will be used instead. |
/// | `#[strikethrough_commands_tip_in_guild(s)]` </br> `#[strikethrough_commands_tip_in_guild = s]` | Reasoning behind strikethrough-commands.</br> *Only used in guilds.* | `s` is a string. If not provided, default text will be used instead. |
/// | `#[group_prefix(s)]` </br> `#[group_prefix = s]` | For introducing a group's prefix | `s` is a string |
/// | `#[lacking_role(s)]` </br> `#[lacking_role = s]` | If a user lacks required roles, this will treat how commands will be displayed. | `s` is a string. Accepts `strike` (strikethroughs), `hide` (will not be listed) or `nothing`(leave be). |
/// | `#[lacking_ownership(s)]` </br> `#[lacking_ownership = s]` | If a user lacks ownership, this will treat how these commands will be displayed. | `s` is a string. Accepts `strike` (strikethroughs), `hide` (will not be listed) or `nothing`(leave be). |
/// | `#[lacking_permissions(s)]` </br> `#[lacking_permissions = s]` | If a user lacks permissions, this will treat how commands will be displayed. | `s` is a string. Accepts `strike` (strikethroughs), `hide` (will not be listed) or `nothing`(leave be). |
/// | `#[embed_error_colour(n)]` | Colour that the help-embed will use upon an error. | `n` is a name to one of the provided constants of the `Colour` struct. |
/// | `#[embed_success_colour(n)]` | Colour that the help-embed will use normally. | `n` is a name to one of the provided constants of the `Colour` struct. |
/// | `#[max_levenshtein_distance(n)]` | How much should the help command search for a similiar name.</br> Indicator for a nested guild. The prefix will be repeated based on what kind of level the item sits. A sub-group would be level two, a sub-sub-group would be level three. | `n` is a 64-bit, unsigned integer. |
/// | `#[indention_prefix(s)]` </br> `#[indention_prefix = s]` | The prefix used to express how deeply nested a command or group is. | `s` is a string |
///
/// [`command`]: attr.command.html
/// 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 be `!foo bar`.
///
/// It might have some options apply to *all* of its commands. E.g. guild or dm only.
///
/// It may even couple other groups as well.
///
/// This group macro purports all of the said purposes above, applied onto a `struct`:
///
/// ```rust,no_run
/// use command_attr::{command, group};
///
/// # type CommandResult = ();
///
/// #[command]
/// fn bar() -> CommandResult {
/// println!("baz");
///
/// Ok(())
/// }
///
/// #[command]
/// fn answer_to_life() -> CommandResult {
/// println!("42");
///
/// Ok(())
/// }
///
/// #[group]
/// // All sub-groups must own at least one prefix.
/// #[prefix = "baz"]
/// #[commands(answer_to_life)]
/// struct Baz;
///
/// #[group]
/// #[commands(bar)]
/// // Case does not matter; the names will be all uppercased.
/// #[sub_groups(baz)]
/// struct Foo;
/// ```
///
/// ## Options
///
/// These appear after `#[group]` as a series of attributes:
///
/// | Syntax | Description | Argument explanation |
/// |------------------------------------------------------|------------------------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
/// | `#[commands(commands)]` | Set of commands belonging to this group. | `commands` is a comma separated list of identifiers referencing functions marked by the `#[command]` macro |
/// | `#[sub_groups(subs)]` | Set of sub groups belonging to this group. | `subs` is a comma separated list of identifiers referencing structs marked by the `#[group]` macro |
/// | `#[prefixes(prefs)]` | Text that must appear before an invocation of a command of this group may occur. | `prefs` is a comma separated list of strings |
/// | `#[prefix(pref)]` | Assign just a single prefix. | `pref` is a string |
/// | `#[allowed_roles(roles)]` | Set of roles the user must possess | `roles` is a comma separated list of strings containing role names |
/// | `#[only_in(ctx)]` | Which environment the command can be executed in. | `ctx` is a string with the accepted values `guild`/`guilds` and `dm`/ `dms` (Direct Message). |
/// | `#[owners_only]` </br> `#[owners_only(b)]` | If this command is exclusive to owners. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[owner_privilege]` </br> `#[owner_privilege(b)]` | If owners can bypass certain options. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[help_available]` </br> `#[help_available(b)]` | If the group should be displayed in the help message. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[checks(identifiers)]` | Preconditions that must met before the command's execution. | `identifiers` is a comma separated list of identifiers referencing functions marked by the `#[check]` macro |
/// | `#[required_permissions(perms)]` | Set of permissions the user must possess. | `perms` is a comma separated list of permission names.</br> These can be found at [Discord's official documentation](https://discord.com/developers/docs/topics/permissions). |
/// | `#[default_command(cmd)]` | A command to execute if none of the group's prefixes are given. | `cmd` is an identifier referencing a function marked by the `#[command]` macro |
/// | `#[description(desc)]` </br> `#[description = desc]` | The group's description or summary. | `desc` is a string describing the group. |
///
/// Similarly to [`command`], this macro generates static instances of the group
/// and its options. The identifiers of these instances are based off the name of the struct to differentiate
/// this group from others. This name is given as the default value of the group's `name` field,
/// used in the help command for display and browsing of the group.
/// It may also be passed as an argument to the macro. For example: `#[group("Banana Phone")]`.
///
/// [`command`]: #fn.command.html
/// A macro for marking a function as a condition checker to groups and commands.
///
/// ## Options
///
/// | Syntax | Description | Argument explanation |
/// |----------------------------------------------------|--------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
/// | `#[name(s)]` </br> `#[name = s]` | How the check should be listed in help. | `s` is a string. If this option isn't provided, the value is assumed to be `"<fn>"`. |
/// | `#[display_in_help]` </br> `#[display_in_help(b)]` | If the check should be listed in help. Has no effect on `check_in_help`. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |
/// | `#[check_in_help]` </br> `#[check_in_help(b)]` | If the check should be evaluated in help. | `b` is a boolean. If no boolean is provided, the value is assumed to be `true`. |