27 lines
1.2 KiB
Kotlin
27 lines
1.2 KiB
Kotlin
package nl.voidcorp.discord.commands.general
|
|
|
|
import nl.voidcorp.discord.command.Command
|
|
import nl.voidcorp.discord.command.CommandMessage
|
|
import nl.voidcorp.discord.command.CommandResult
|
|
import org.gitlab.api.GitlabAPI
|
|
import org.gitlab.api.TokenType
|
|
import org.springframework.stereotype.Service
|
|
|
|
class ReportCommand : Command(
|
|
"report",
|
|
helpMesage = "Report a bug or request a feature for the bot!",
|
|
usage = "report bug/feature \"name\" \"description\""
|
|
) {
|
|
val api = GitlabAPI.connect("https://gitlab.voidcorp.nl/", "KUqA3G9DnPVtCgitmfgU", TokenType.PRIVATE_TOKEN)
|
|
override fun handle(event: CommandMessage): CommandResult {
|
|
if (event.params.size != 4) return CommandResult.PARAMETERS
|
|
val theProject = api.projects.first { it.name.contains("ottobotv2") }
|
|
val (type, title, descr) = event.params.drop(1)
|
|
if (type.toLowerCase() !in listOf("bug", "feature")) return CommandResult.PARAMETERS
|
|
|
|
|
|
val issue = api.createIssue(theProject.id, 0, null, type.toLowerCase().capitalize(), descr, title)
|
|
event.reply("Thanks for reporting, a new issue was created: ${theProject.webUrl}/issues/${issue.iid}")
|
|
return CommandResult.SUCCESS
|
|
}
|
|
} |