Giter VIP home page Giter VIP logo

coxir's Introduction

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.

coxir's People

Contributors

awlexus avatar epicorange avatar geopjr avatar jb3 avatar perryprog avatar satom99 avatar tiltmesenpai avatar xh4h avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.