diff --git a/src/main/kotlin/nl/voidcorp/dbot/UnityBot.kt b/src/main/kotlin/nl/voidcorp/dbot/UnityBot.kt index 74efed1..d6d9a77 100644 --- a/src/main/kotlin/nl/voidcorp/dbot/UnityBot.kt +++ b/src/main/kotlin/nl/voidcorp/dbot/UnityBot.kt @@ -15,6 +15,7 @@ import net.dv8tion.jda.core.JDA import net.dv8tion.jda.core.JDABuilder import net.dv8tion.jda.core.MessageBuilder import net.dv8tion.jda.core.entities.Game +import net.dv8tion.jda.core.entities.MessageEmbed import net.dv8tion.jda.webhook.WebhookClient import net.dv8tion.jda.webhook.WebhookClientBuilder import nl.voidcorp.dbot.commands.helloCommand @@ -24,6 +25,7 @@ import nl.voidcorp.dbot.storage.GitlabWebhook import org.slf4j.LoggerFactory import java.io.File import java.io.FileReader +import java.time.LocalDateTime val playerManager = DefaultAudioPlayerManager() @@ -99,6 +101,16 @@ fun main(args: Array) { val replies = listOf("Hello %%", "Why hello there %%!", "Hello there %%", "General %%. You are a bold one", "A wild %% appeared!") cb.setHelpConsumer { event -> val greeting = replies.random().replace("%%", event.member.effectiveName) + val eb = EmbedBuilder().setTitle(greeting) + .appendDescription("My name is ${event.selfMember.effectiveName}, and I am definitely the best Discord bot around!\n\nUse `!help command` for a chance that I have more info about a command!") + .setColor(event.selfMember.color).setFooter("Requested by ${event.member.effectiveName}", event.author.effectiveAvatarUrl).setTimestamp(LocalDateTime.now()) + val m = commands.catMap() + for (e in m.entries){ + + val f = MessageEmbed.Field(e.key, e.value.joinToString(separator = "\n") { "!${it.name}" }, true) + eb.addField(f) + } + eb.setThumbnail(event.selfUser.effectiveAvatarUrl) val mb = MessageBuilder("$greeting\n").append { var st = "" for (c in commands) { @@ -108,7 +120,7 @@ fun main(args: Array) { } - event.reply(mb.build()) + event.reply(eb.build()) } initMusic() diff --git a/src/main/kotlin/nl/voidcorp/dbot/Util.kt b/src/main/kotlin/nl/voidcorp/dbot/Util.kt index e1ad9cb..ce06af0 100644 --- a/src/main/kotlin/nl/voidcorp/dbot/Util.kt +++ b/src/main/kotlin/nl/voidcorp/dbot/Util.kt @@ -2,6 +2,7 @@ package nl.voidcorp.dbot import com.google.gson.Gson import com.google.gson.GsonBuilder +import com.jagrosh.jdautilities.command.Command import java.util.* val gson: Gson = GsonBuilder().setPrettyPrinting().create() @@ -10,4 +11,17 @@ val random = Random() fun MutableList.addAll(vararg e: E) = this.addAll(listOf(*e)) -fun List.random(): E = this[random.nextInt(this.size)] \ No newline at end of file +fun List.random(): E = this[random.nextInt(this.size)] + +fun List.catMap(): Map> { + val m = mutableMapOf>() + for (c in this) { + val cname = if (c.category==null) "Unknown" else c.category.name + if (!m.containsKey(cname)) { + m[cname] = mutableListOf() + } + + m[cname]!!+=c + } + return m +} \ No newline at end of file