gizmo385/discord.clj

stateful macros from discord.bot do not work

Closed this issue · 1 comments

Once again, I'm new to clojure, so bear with me. I tried looking for logic errors, but there's so much that I don't understand, I'd have to come back with a better understanding of the language.

Here's my core file:

(ns devbot.core
	(:require [discord.bot :as bot]
		  [discord.http :as http]
		  [discord.config :as config])
	(:gen-class))

(defn say 
	"Repeats the message back to the user"
	[client message]
	(bot/say (:content message)))

(bot/defcommand ping [_ _] 
	"Ping!"
	(bot/say "Pong!"))

(defn -main
	"Creates a new discord bot and supplies a series of extensions to it."
	[& args]
	(let [bot-name (config/get-bot-name)
		prefix (config/get-prefix)]
	  (bot/with-extensions bot-name prefix
		:say say)))

Sorry about the formatting, IntelliJ was sorta mangling the tabbing and spacing.
I've been trying to test the use of inline command definitions and macros. In my testing, the bot worked perfectly with the say command, but not with the ping command. On top of that, standard builtins like the help command doesn't work correctly with say, nor with any functions. The commands simply pass the bot by, with no exceptions or anything printed out onto the screen.

@MyriaCore I think the issue is something that needs to be corrected in the docs. When you're starting a bot using bot/with-extensions it does not load the extensions that have been defined using bot/defcommand. It will only load the extensions that have been defined inside the macro body.

I think this is why the help command doesn't work either when you're using bot/with-extensions. If you migrate your extensions into separate files and use bot/from-files, that should address the problem. I'll update the docs to remove the confusion.