Alchemy.Cache.search
You're seeing just the function
search
, go back to Alchemy.Cache module for more information.
Link to this function
search(section, filter)
Specs
Searches across all guild for information.
The section is the type of object to search for. The possibilities are:
:guilds
, :members
, :roles
, :presences
, :voice_states
, :emojis
,
:channels
The filter is a function returning a boolean, that allows you to filter out elements from this list.
The return type will be a struct of the same type of the section searched for.
Examples
Cache.search(:members, fn x -> String.length(x.nick) < 10 end)
This will return a list of all members whose nickname is less than 10 characters long.
Cache.search(:roles, &match?(%{name: "Cool Kids"}, &1))
This is a good example of using the match?/2
function to filter against a pattern.
Cache.search(:guilds, &match?(%{name: "Test"}, &1))
Will match any guilds named "Test" in the cache.