Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 

README.md

coxir

License Build Status Join Discord Donate

An Elixir wrapper for Discord. Based on nostrum and alchemy.

Please refer to the documentation for more information on the library.

Installation

One should simply include coxir as a dependency as follows.

defp deps do
  [{:coxir, git: "https://github.com/satom99/coxir.git"}]
end

Getting started

Before setting up a consumer, coxir must be configured as follows.

config :coxir,
  token: "",
  shards: 1, # optional
  ffmpeg: "" # optional

In order to process incoming events, a consumer should be set up as follows.

defmodule Consumer do
  use Coxir

  def handle_event({:MESSAGE_CREATE, message}, state) do
    case message.content do
      "ping!" ->
        Message.reply(message, "pong!")
      _ ->
        :ignore
    end

    {:ok, state}
  end

  def handle_event(_event, state) do
    {:ok, state}
  end
end

Once all the above is done, the application may be configured in any desired fashion so that a consumer process is started.

defmodule Example do
  use Application
  use Supervisor

  def start(_type, _args) do
    children = [
      worker(Consumer, [])
    ]
    options = [
      strategy: :one_for_one,
      name: __MODULE__
    ]
    Supervisor.start_link(children, options)
  end
end

A common approach to which would be the above, of course after configuring the module as a callback.

About

An Elixir wrapper for Discord.

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.