### Start Messaging Process Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Initiate the process for sending messages to Discord using `start-connection!`. This function requires your bot's token and returns a channel for managing outgoing messages. ```clojure (discljord.messaging/start-connection! token) ``` -------------------------------- ### Default Event Pump with Multimethod Handler Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Use this event pump when you want to define event handling logic using Clojure's multimethods. It requires setting up connections and messaging channels, and then starting the message pump. ```clojure (require '[discljord.connections :as c]) (require '[discljord.messaging :as m]) (require '[discljord.events :as e]) (require '[clojure.core.async :as a]) (def token "TOKEN") (def state (atom nil)) (defmulti handle-event (fn [event-type event-data] event-type)) (defmethod handle-event :default [event-type event-data]) (defmethod handle-event :message-create [event-type {{bot :bot} :author :keys [channel-id content]}] (if (= content "!disconnect") (c/disconnect-bot! (:connection @state)) (when-not bot (m/create-message! (:messaging @state) channel-id :content "Hello, World!")))) (let [event-ch (a/chan 100) connection-ch (c/connect-bot! token event-ch) messaging-ch (m/start-connection! token) init-state {:connection connection-ch :event event-ch :messaging messaging-ch}] (reset! state init-state) (try (e/message-pump! event-ch handle-event) (finally (m/stop-connection! messaging-ch) (a/close! event-ch)))) ``` -------------------------------- ### Download Dependencies with Leiningen Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Run this command after adding Discljord to your project.clj to download dependencies. ```bash lein deps ``` -------------------------------- ### Download Dependencies with tools.deps Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Run this command after adding Discljord to your deps.edn to download dependencies. ```bash clj -e "(println \"Dependencies downloaded\")" ``` -------------------------------- ### Connect Bot to Discord API Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Use `connect-bot!` to establish a connection process. It takes a channel for communication and returns a channel for receiving events. ```clojure (discljord.connections/connect-bot! channel) ``` -------------------------------- ### Add Discljord to tools.deps Project Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Add this to your deps.edn file's :dependencies key to use Discljord with tools.deps. ```clojure {org.suskalo/discljord {:mvn/version "1.2.3"}} ``` -------------------------------- ### Respond to Messages with 'Hello, World' Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Responds with 'Hello, World!' to messages in a specific channel. Bot disconnects when a message is pinned or unpinned. ```clojure (require '[clojure.core.async :as a]) (require '[discljord.connections :as c]) (require '[discljord.messaging :as m]) (def token "TOKEN") (def channel-id "12345") (let [event-ch (a/chan 100) connection-ch (c/connect-bot! token event-ch) message-ch (m/start-connection! token)] (try (loop [] (let [[event-type event-data] (a/") (:name emoji))))) (def handlers {:message-create [#'greet-or-disconnect] :message-reaction-add [#'send-emoji]}) (let [event-ch (a/chan 100) connection-ch (c/connect-bot! token event-ch) messaging-ch (m/start-connection! token) init-state {:connection connection-ch :event event-ch :messaging messaging-ch}] (reset! state init-state) (try (e/message-pump! event-ch (partial e/dispatch-handlers #'handlers)) (finally (m/stop-connection! messaging-ch) (c/disconnect-bot! connection-ch)))) ``` -------------------------------- ### Echo Bot with Exit Command Source: https://cljdoc.org/d/com.github.discljord/discljord/CURRENT Echoes user messages in a channel, except for '!exit' which terminates the bot with a 'Goodbye!' message. Bot also disconnects on channel pin updates. ```clojure (require '[clojure.string :as s]) (require '[clojure.core.async :as a]) (require '[discljord.connections :as c]) (require '[discljord.messaging :as m]) (def token "TOKEN") (def channel-id "12345") (let [event-ch (a/chan 100) connection-ch (c/connect-bot! token event-ch) message-ch (m/start-connection! token)] (try (loop [] (let [[event-type event-data] (a/