├── examples ├── test ├── test_helper.exs ├── discord_elixir_test.exs └── discord_elixir │ ├── voice │ ├── controller_test.exs │ └── buffer_test.exs │ └── permissions_test.exs ├── .tool-versions ├── doc ├── fonts │ ├── icomoon.eot │ ├── icomoon.ttf │ ├── icomoon.woff │ └── icomoon.svg ├── index.html ├── search.html ├── 404.html ├── DiscordEx.EchoBot.html ├── DiscordEx.Voice.Encoder.html ├── DiscordEx.Voice.UDP.html ├── DiscordEx.html ├── api-reference.html ├── DiscordEx.Permissions.html ├── dist │ └── sidebar_items-506f2099ca.js ├── DiscordEx.RestClient.Resources.Image.html ├── DiscordEx.Heartbeat.html ├── DiscordEx.RestClient.html ├── DiscordEx.Voice.Controller.html ├── DiscordEx.RestClient.Resources.Invite.html ├── DiscordEx.Client.Helpers.MessageHelper.html └── DiscordEx.Client.Utility.html ├── .gitignore ├── .travis.yml ├── lib ├── discord_ex.ex ├── discord_ex │ ├── voice │ │ ├── encoder.ex │ │ ├── udp.ex │ │ ├── buffer.ex │ │ ├── controller.ex │ │ └── client.ex │ ├── rest_client │ │ ├── rest.ex │ │ ├── resources │ │ │ ├── image.ex │ │ │ ├── invite.ex │ │ │ ├── user.ex │ │ │ └── channel.ex │ │ └── rest_client.ex │ ├── permissions.ex │ └── client │ │ ├── heartbeat.ex │ │ ├── utility.ex │ │ └── helpers │ │ └── message_helper.ex └── examples │ └── echo_bot.ex ├── LICENSE ├── config └── config.exs ├── mix.exs ├── mix.lock └── README.md /examples: -------------------------------------------------------------------------------- 1 | lib/examples/ -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | erlang 20.1 2 | elixir 1.5.2 3 | -------------------------------------------------------------------------------- /doc/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmcafee/discord_ex/HEAD/doc/fonts/icomoon.eot -------------------------------------------------------------------------------- /doc/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmcafee/discord_ex/HEAD/doc/fonts/icomoon.ttf -------------------------------------------------------------------------------- /doc/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmcafee/discord_ex/HEAD/doc/fonts/icomoon.woff -------------------------------------------------------------------------------- /test/discord_elixir_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DiscordExTest do 2 | use ExUnit.Case 3 | doctest DiscordEx 4 | end 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | doc/.build 2 | /_build 3 | /cover 4 | /deps 5 | erl_crash.dump 6 | *.ez 7 | .DS_Store 8 | *.tar 9 | .notes 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: elixir 2 | 3 | sudo: false # use faster, container-based Travis 4 | 5 | elixir: 6 | - 1.5.2 7 | 8 | # test last two OTP releases 9 | otp_release: 10 | - 18.3 11 | - 19.0 12 | - 20.1 13 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |Sorry, but the page you were trying to get to, does not exist. You 72 | may want to try searching this site using the sidebar or using our 73 | API Reference page to find what 74 | you were looking for.
75 | 76 | 89 |An all so original echo and ping bot!
83 |Type “!example:echo hello!” or “!example:ping” to get a reply back.
84 | 85 |Voice Encoder
83 | 84 |Encode audio file to proper format
109 |encode_file(String.t(), map()) :: binary()152 | 153 |
Encode audio file to proper format
158 | 159 |Voice UDP Setup functions
83 | 84 |self_discovery(String.t(), number(), number()) :: {tuple(), number()}155 | 156 |
send_audio(binary(), pid(), number(), number()) :: atom()183 | 184 |
Base Discord Ex Module
83 | 84 |Discord Bot Authorization URL
109 |Discord API URL
118 |bot_auth_url(number(), number()) :: String.t()161 | 162 |
Discord Bot Authorization URL
167 | 168 |discord_url() :: String.t()190 | 191 |
Discord API URL
196 | 197 |Base Discord Ex Module
86 |Connect to Discord to recieve and send data in realtime
93 |Bot Message Helpers
100 |Utilty methods to be used for discord clients
107 |Discord uses a REST interface to send data to the API
114 |An all so original echo and ping bot!
121 |Heartbeat service for Discord websocket connection. 128 | Sends heartbeat on interval and detects stale connection if heartbeat ack 129 | is not received
130 |Easily assign permissions with this helper module
137 |Discord RestClient. Used a GenServer so that you can have multiple 144 | clients in one application
145 |Convience helper for channel
152 |Convience helper for guild resource
159 |Convience helper for images
166 |Convience helper for invites
173 |Convience helper for user resource
180 |Buffer Module for holding and reading audio
187 |This client is for specifically working with voice. You can pass this process 194 | to your regular client if you wish to use it with your bot
195 |Voice control to make voice interaction a lot easier
202 |Voice Encoder
209 |Voice UDP Setup functions
216 |Easily assign permissions with this helper module.
83 | 84 |Add any permission to an existing set of permissions and return the complete permission value
109 |Remove any permission from an existing set of permissions and return updated value
118 |Take current permission value and convert it to a map of permissions
127 |add(integer(), atom()) :: integer()172 | 173 |
Add any permission to an existing set of permissions and return the complete permission value.
178 | 179 |remove(integer(), atom()) :: integer()201 | 202 |
Remove any permission from an existing set of permissions and return updated value.
207 | 208 |to_map(integer()) :: map()230 | 231 |
Take current permission value and convert it to a map of permissions.
236 | 237 |Convience helper for images
83 | 84 |Get the user avatar URL
109 |Get the guild icon URL
118 |Get the user avatar URL
167 |Image.avatar_url("99999999993832","f3e8329c329020329")
184 |
185 | Get the guild icon URL
213 |Image.icon_url("99999999993832","f3e8329c329020329")
230 |
231 | Heartbeat service for Discord websocket connection. 83 | Sends heartbeat on interval and detects stale connection if heartbeat ack 84 | is not received.
85 | 86 |Reset heartbeat
117 |Heartbeat ACK not received, connection is stale. Stop heartbeat
126 |Reset heartbeat
203 | 204 |Heartbeat ACK not received, connection is stale. Stop heartbeat.
226 | 227 |Discord RestClient. Used a GenServer so that you can have multiple 83 | clients in one application.
84 | 85 |Response body with related options
108 |Start process and HTTP Client. 138 | {:ok, conn} = DiscordEx.RestClient.start_link(%{token: token})
139 |request_reply() :: {atom(), map(), map()}
181 |
182 | Response body with related options
187 | 188 |resource(pid(), atom(), String.t(), map()) :: request_reply()248 | 249 |
Start process and HTTP Client. 278 | {:ok, conn} = DiscordEx.RestClient.start_link(%{token: token})
279 | 280 |Voice control to make voice interaction a lot easier.
83 | 84 |Play some audio to a channel
115 |Stop audio from playing in channel and clear buffer
130 |Play some audio to a channel
197 |DiscordEx.Controller.play(voice_client, "/my/awesome/audio.wav", %{volume: 128})
216 |
217 | Stop audio from playing in channel and clear buffer
261 |DiscordEx.Controller.stop(voice_client)
276 |
277 | Convience helper for invites
83 | 84 |Accept invite
109 |Delete invite object
118 |Get invite object
127 |accept(pid(), String.t()) :: map()170 | 171 |
Accept invite
176 |Accept an invite. This is not available to bot accounts, and requires the guilds.join OAuth2 scope to accept on behalf of normal users.
177 |Invite.accept(conn, "99999999993832")
194 |
195 | delete(pid(), String.t()) :: map()217 | 218 |
Delete invite object
223 |Requires the MANAGE_CHANNELS permission. Returns an invite object on success.
224 |Invite.delete(conn, "99999999993832")
241 |
242 | get(pid(), String.t()) :: map()264 | 265 |
Get invite object
270 |Invite.get(conn, "99999999993832")
287 |
288 | Bot Message Helpers
83 | 84 |Actionable Mention and DM Message
109 |Actionable Mention and DM Message 118 | This checks that an incoming message is private or is a mention to the current user.
119 |MessageHelper.actionable_message_for_me?(payload, state)
128 | #=> true
129 | Parses a message payload which is content leading with ‘!’. 138 | Returns a tuple with the command and the message
139 |Parses a message payload which is content leading with provided prefix. 148 | Returns a tuple with the command and the message
149 |actionable_message_for?(String.t(), map(), map()) :: boolean()192 | 193 |
Actionable Mention and DM Message
198 |This checks that an incoming message is private or is a mention to the defined user.
199 |MessageHelper.actionable_message_for?("Mr.Botman", payload, state)
218 | #=> true
219 |
220 | actionable_message_for_me?(map(), map()) :: boolean()242 | 243 |
Actionable Mention and DM Message 248 | This checks that an incoming message is private or is a mention to the current user.
249 |MessageHelper.actionable_message_for_me?(payload, state)
266 | #=> true
267 |
268 | Parses a message payload which is content leading with ‘!’. 296 | Returns a tuple with the command and the message.
297 |MessageHelper.msg_command_parse(payload)
312 | #=> {"ping", "me please!"}
313 |
314 | Parses a message payload which is content leading with provided prefix. 342 | Returns a tuple with the command and the message.
343 |MessageHelper.msg_command_parse(payload, "!")
360 | #=> {"ping", "me please!"}
361 |
362 | Utilty methods to be used for discord clients.
83 |Normalizers, Encoders, and Decoders
84 | 85 |Generic function for updating the value of an agent process
110 |Generic function for getting the value from an agent process
119 |Convert atom to string
128 |Get the atom value of and opcode using an integer value
137 |Build a binary payload for discord communication
146 |Build a json payload for discord communication
155 |Decode json payload received from discord into a map
164 |agent_update(pid(), any()) :: nil207 | 208 |
Generic function for updating the value of an agent process
213 | 214 |agent_value(pid()) :: any()236 | 237 |
Generic function for getting the value from an agent process
242 | 243 |normalize_atom(atom()) :: String.t()265 | 266 |
Convert atom to string
271 | 272 |opcode(map(), integer()) :: atom()294 | 295 |
opcode(map(), atom()) :: integer()296 | 297 |
Get the atom value of and opcode using an integer value
302 | 303 |payload_build(number(), map(), number(), String.t()) :: binary()329 | 330 |
Build a binary payload for discord communication
335 | 336 |payload_build_json(number(), map(), number(), String.t()) :: binary()362 | 363 |
Build a json payload for discord communication
368 | 369 |payload_decode(list(), {atom(), binary()}) :: map()
391 |
392 | payload_decode(list(), {atom(), binary()}) :: map()
393 |
394 | Decode json payload received from discord into a map
399 | 400 |