nostrum

Elixir Discord Library

Github星跟蹤圖

Nostrum

Build Status
Join Discord

An Elixir library for the Discord API.

It is highly recommended to check out the
documentation first. It includes all of the
information listed here and more.

Installation

Add Nostrum as a dependency:

Stable

Stable documentation can be found here

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

Dev

def deps do
  [{:nostrum, git: "https://github.com/Kraigie/nostrum.git"}]
end

Edit or create your config file:

The file should be located at /config/config.exs. To run Nostrum you need the
following two fields:

config :nostrum,
  token: "666", # The token of your bot as a string
  num_shards: 2 # The number of shards you want to run your bot under, or :auto.

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

Example Usage

The below module needs to be started in some fashion to capture events. See
here
for 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

主要指標

概覽
名稱與所有者Kraigie/nostrum
主編程語言Elixir
編程語言Elixir (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2016-08-26 21:18:34
推送於2025-09-18 18:12:35
最后一次提交2025-09-18 20:08:37
發布數31
最新版本名稱v0.10.4 (發布於 2025-03-02 21:40:50)
第一版名稱0.2.0 (發布於 )
用户参与
星數698
關注者數13
派生數137
提交數1.8k
已啟用問題?
問題數184
打開的問題數23
拉請求數438
打開的拉請求數5
關閉的拉請求數68
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?