Changed Modules command to fetch data directly from the addons.

This commit is contained in:
Erik C. Thauvin 2022-01-16 18:32:28 -08:00
parent c99d2ce805
commit a70f22d402
2 changed files with 5 additions and 4 deletions

View file

@ -401,6 +401,7 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
addons.add(Ignore())
addons.add(LinksMgr())
addons.add(Me())
addons.add(Modules(addons))
addons.add(Msg())
addons.add(Nick())
addons.add(Posting())
@ -426,7 +427,6 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
addons.add(Info(tell))
addons.add(Joke())
addons.add(Lookup())
addons.add(Modules(addons.modulesNames))
addons.add(Ping())
addons.add(RockPaperScissors())
addons.add(StockQuote())

View file

@ -32,12 +32,13 @@
package net.thauvin.erik.mobibot.commands
import net.thauvin.erik.mobibot.Addons
import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.isChannelOp
import net.thauvin.erik.mobibot.Utils.sendList
import org.pircbotx.hooks.types.GenericMessageEvent
class Modules(private val modulesNames: List<String>) : AbstractCommand() {
class Modules(private val addons: Addons) : AbstractCommand() {
override val name = "modules"
override val help = listOf("To view a list of enabled modules:", helpFormat("%c $name"))
override val isOpOnly = true
@ -46,11 +47,11 @@ class Modules(private val modulesNames: List<String>) : AbstractCommand() {
override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) {
if (isChannelOp(channel, event)) {
if (modulesNames.isEmpty()) {
if (addons.modulesNames.isEmpty()) {
event.respondPrivateMessage("There are no enabled modules.")
} else {
event.respondPrivateMessage("The enabled modules are: ")
event.sendList(modulesNames, 7, isIndent = true)
event.sendList(addons.modulesNames, 7, isIndent = true)
}
} else {
helpResponse(channel, args, event)