1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
defmodule Thulani.Command.Util do
alias Nostrum.Struct.Message
alias Nostrum.Struct.User
alias Nostrum.Struct.Emoji
alias Nostrum.Struct.Channel
alias Nostrum.Api
@spec reply(Message.t(), Api.options() | String.t()) ::
Api.create_message(Channel.id(), Message.t())
def reply(
%Message{
channel_id: channel_id
},
msg
)
when is_bitstring(msg) do
Api.create_message(channel_id, content: msg)
end
def reply(
%Message{
channel_id: channel_id
},
opts
) do
Api.create_message(channel_id, opts)
end
@spec reply!(Message.t(), Api.options() | String.t()) :: nil
def reply!(msg, opts), do: {:ok} = reply(msg, opts)
@spec react(Message.t(), Api.emoji()) ::
Api.create_reaction(Channel.id(), Message.id(), Emoji.t())
def react(
%Message{
id: id,
channel_id: channel_id
},
reaction
) do
Api.create_reaction(channel_id, id, reaction)
end
@spec react!(Message.t(), Api.emoji()) ::
Api.create_reaction(Channel.id(), Message.id(), Emoji.t())
def react!(msg, opts), do: {:ok} = react(msg, opts)
@spec metadata(Message.t()) :: Map.t()
def metadata(%Message{
author: %User{
id: user_id
},
timestamp: timestamp
}) do
%{
created_by: user_id,
created: timestamp
}
end
end
|