Nosedrum.Converters (nosedrum v0.5.0) View Source
Conversion from command arguments to various types.
This module provides an interface to the individual converter modules.
Most converter functions related to Discord itself take a guild_id
which is used for loading the guild from the cache. If the guild could
not be load from the cache, implementations will usually attempt to
fetch the relevant data from the API.
Link to this section Summary
Functions
Convert the given text
to a Nostrum.Struct.Channel.t/0
.
Convert the given text
to a Nostrum.Struct.Guild.Member.t/0
.
Convert the given text
to a Nostrum.Struct.Guild.Role.t/0
.
Link to this section Functions
Specs
to_channel(String.t(), Nostrum.Struct.Guild.id()) :: {:ok, Nostrum.Struct.Channel.t()} | {:error, String.t()}
Convert the given text
to a Nostrum.Struct.Channel.t/0
.
Lookup is attempted in the following order:
- by direct ID, such as
9999
- by mention, such as
<#9999>
- by name, such as
mod-log
Specs
to_member(String.t(), Nostrum.Struct.Guild.id()) :: {:ok, Nostrum.Struct.Guild.Member.t()} | {:error, String.t()}
Convert the given text
to a Nostrum.Struct.Guild.Member.t/0
.
Lookup is attempted in the following order:
- by direct ID, such as
1231321
- by mention, such as
<@1231321>
,<@!1231321>
- by name#discrim combination, such as
Jimmy#9999
- by name, such as
Jimmy
Note that name lookups may not be 100% accurate: if there are multiple users with the same name on the server, the first one found will be used.
Specs
to_role(String.t(), Nostrum.Struct.Guild.id(), boolean()) :: {:ok, Nostrum.Struct.Guild.Role.t()} | {:error, String.t()}
Convert the given text
to a Nostrum.Struct.Guild.Role.t/0
.
Lookup is attempted in the following order:
- by direct ID, such as
5555
- by mention, such as
<@&5555>
- by name, such as
Bots
The optional ilike
argument determines whether the role name
search should be case-insensitive. This is useful if your users
are lazy and you want to save them from holding down an extra
button on their keyboard.