-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from danmason/add-slash-commands
Add slash commands
- Loading branch information
Showing
11 changed files
with
203 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
(ns cljukebox.handlers.play | ||
(:require [clojure.string :as string] | ||
[cljukebox.player :as player] | ||
(:require [cljukebox.player :as player] | ||
[cljukebox.util :as util])) | ||
|
||
(defn play-audio [{:keys [voice-channel message-channel guild-id content] :as data}] | ||
(let [[_ url] (string/split content #" ")] | ||
(cond | ||
(nil? voice-channel) | ||
(util/send-message message-channel "You're not in a voice channel - join one to queue songs on the bot.") | ||
|
||
(nil? url) | ||
(util/send-message message-channel "No media URL has been provided.") | ||
|
||
:else | ||
(let [{:keys [scheduler] :as guild-manager} (player/get-guild-audio-manager guild-id)] | ||
(player/connect-to-voice guild-manager voice-channel) | ||
(.loadItemOrdered player/player-manager | ||
guild-manager | ||
url | ||
(player/mk-audio-handler scheduler message-channel)))))) | ||
(defn play-audio | ||
([{:keys [voice-channel message-channel content] :as data}] | ||
(if-let [url (util/get-arguments content)] | ||
(play-audio data {:url url}) | ||
(util/send-message message-channel "No media URL has been provided."))) | ||
([{:keys [voice-channel message-channel guild-id] :as data} {:keys [url] :as opts}] | ||
(if-not voice-channel | ||
(util/send-message message-channel "You're not in a voice channel - join one to queue songs on the bot.") | ||
(let [{:keys [scheduler] :as guild-manager} (player/get-guild-audio-manager guild-id)] | ||
(player/connect-to-voice guild-manager voice-channel) | ||
(.loadItemOrdered player/player-manager | ||
guild-manager | ||
url | ||
(player/mk-audio-handler scheduler message-channel)))))) | ||
|
||
(def handler-data | ||
{:doc "Will add audio to the bot's playlist - if not currently playing anything, will join the bot to the calling user's voice channel. For a list of supported sources/file formats, see here: https://github.com/sedmelluq/lavaplayer#supported-formats" | ||
{:doc "Add a track to the bot's playlist" | ||
:long-doc "Add a track to the bot's playlist - if not currently playing anything, will join the bot to the calling user's voice channel. For a list of supported sources/file formats, see here: https://github.com/sedmelluq/lavaplayer#supported-formats" | ||
:usage-str "play <media-url>" | ||
:args [{:name "url" | ||
:doc "URL of the track you want to play" | ||
:required? true}] | ||
:handler-fn play-audio}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
(ns cljukebox.handlers.prefix | ||
(:require [cljukebox.util :as util] | ||
[clojure.string :as string])) | ||
(:require [cljukebox.util :as util])) | ||
|
||
(defn set-prefix [{:keys [message-channel guild-id content] :as data}] | ||
(let [split-data (string/split content #" ")] | ||
(if (= 2 (count split-data)) | ||
(let [[_ new-prefix] split-data] | ||
(util/merge-to-config {guild-id {:prefix new-prefix}}) | ||
(util/send-message message-channel (format "Command prefix set to `%s`" new-prefix))) | ||
(util/send-message message-channel (format "Command prefix is currently set to `%s`" (util/get-prefix guild-id)))))) | ||
(defn set-prefix | ||
([{:keys [content message-channel guild-id] :as data}] | ||
(if-let [new-prefix (util/get-arguments content)] | ||
(set-prefix data {:new-prefix new-prefix}) | ||
(util/send-message message-channel (format "Need to supply new bot prefix (currently set to `%s`)" (util/get-prefix guild-id))))) | ||
([{:keys [message-channel guild-id] :as data} {:keys [new-prefix] :as opts}] | ||
(util/merge-to-config {guild-id {:prefix new-prefix}}) | ||
(util/send-message message-channel (format "Command prefix set to `%s`" new-prefix)))) | ||
|
||
(def handler-data | ||
{:doc "Sets the server wide command prefix (default is `^`)" | ||
:usage-str "prefix <new-prefix>" | ||
:args [{:name "new-prefix" | ||
:doc "New prefix string for the bot to use for commands" | ||
:required? true}] | ||
:handler-fn set-prefix}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.