-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Turn embed into a behaviour * Adjust type specs * defmacro * consistency * Fix wording * Add type check for callbacks * handle nil * add example in documentation and tests Co-authored-by: Awlex <no thank you>
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule MyApp.MyStruct do | ||
use Nostrum.Struct.Embed | ||
|
||
defstruct [] | ||
|
||
def title(_), do: "craig" | ||
def description(_), do: "nostrum" | ||
def url(_), do: "https://google.com/" | ||
def timestamp(_), do: "2016-05-05T21:04:13.203Z" | ||
def color(_), do: 431_948 | ||
|
||
def fields(_) do | ||
[ | ||
%Nostrum.Struct.Embed.Field{name: "Field 1", value: "Test"}, | ||
%Nostrum.Struct.Embed.Field{name: "Field 2", value: "More test", inline: true} | ||
] | ||
end | ||
end |