nostrum

Elixir Discord Library
授权协议 MIT License
开发语言 Python
所属分类 应用工具、 IM/聊天/语音工具
软件类型 开源软件
地区 不详
投 递 者 宗冠宇
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Nostrum

Build Status

An Elixir library for the Discord API.

It is highly recommended to check out thedocumentation first. It includes all of theinformation listed here and more.

Installation

It is recommended to use a stable release by specifying a publishedversion from Hex:

def deps do
  [{:nostrum, "~> 0.4"}]
end

For stable installations, documentation can be found athttps://hexdocs.pm/nostrum. However, if you want the latest changes and helptest the library, you can also install directly from GitHub:

def deps do
  [{:nostrum, github: "Kraigie/nostrum"}]
end

Documentation for master can be found at https://kraigie.github.io/nostrum/.

Edit or create your config file at /config/config.exs. To run Nostrum youneed the following two fields:

config :nostrum,
  token: "666" # The token of your bot as a string

For more information about the differences between dev and stable as well asadditional config parameters, please see thedocumentation.

Example Usage

The below module needs to be started in some fashion to capture events. Seeherefor a full example.

defmodule ExampleConsumer do
  use Nostrum.Consumer

  alias Nostrum.Api

  def start_link do
    Consumer.start_link(__MODULE__)
  end

  def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do
    case msg.content do
      "ping!" ->
        Api.create_message(msg.channel_id, "I copy and pasted this code")
      _ ->
        :ignore
    end
  end

  # Default event handler, if you don't include this, your consumer WILL crash if
  # you don't have a method definition for each event type.
  def handle_event(_event) do
    :noop
  end
end

Although it's recommended to run under a supervisor, you could start it from iex.

iex()> ExampleConsumer.start
  {:ok, #PID<0.208.0>}

Getting Help

If you need help, visit #elixir_nostrum on the unofficial Discord API guild!

Discord API

License

MIT