UNIVERSAL DEVELOPMENT
Join Discord [Click Here]
  • 🗨️UniversalChat
    • Installation
    • Commands
    • Permissions
    • Designing Your Chat
    • Customising Translation
    • Quick Chat (Shortcuts)
    • Server Guide
    • Profanity Filter
    • Message Of The Day (MOTD)
    • Polls
    • Autocorrect
    • Command Auto Complete
    • Developer Guide
      • Getting Started
      • Translation
      • Check For Profanity & Hate Speech
      • Create Summary Of Text
      • Server Guide
      • Autocorrect
      • Parsing Colors
    • Credits
  • 👜Modular Backpacks
    • Installation
    • Commands
    • Permissions
    • Changing backpack prices
Powered by GitBook
On this page
  • Create Answer To Question Based On Information
  • Example
  1. UniversalChat
  2. Developer Guide

Server Guide

import org.universaldevelopment.universalChat.API.UniversalChatAPI.makeAnswerRequest

Create Answer To Question Based On Information

UniversalChatAPI.makeAnswerRequest(Message)
Message: String

Returns String

Example

   Bukkit.getScheduler().runTaskAsynchronously(this, Runnable {
                                try {

                                    val serverGuideText = loadServerGuide(player)
                                    val strippedGuideText = ChatColor.stripColor(serverGuideText)
                                    val combinedQuery = "$strippedGuideText\n\nQuestion: $question"
                                    val rawAnswer = makeAnswerRequest(combinedQuery)

                                    val translatedAnswer = if (translationEnabled && playerLanguage.isNotEmpty()) {
                                        rawAnswer?.let { makeTranslation(it, playerLanguage) } ?: rawAnswer
                                    } else {
                                        rawAnswer
                                    }

                                    val finalAnswer = PlaceholderAPI.setPlaceholders(player, translatedAnswer ?: "")

                                    Bukkit.getScheduler().runTask(this, Runnable {
                                        player.sendMessage(finalAnswer)
                                    })
                                } catch (e: Exception) {

                                    Bukkit.getScheduler().runTask(this, Runnable {
                                        player.sendMessage("${ChatColor.RED}Error processing your question: ${e.message}")
                                    })
                                }
                            })

This example would read from the serverGuide file, make an answer and send it the player.

PreviousCreate Summary Of TextNextAutocorrect

Last updated 1 month ago

🗨️