Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
feat: num tag command
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtakagi committed Jul 13, 2020
1 parent a92003e commit 146f62c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/kotlin/me/notsmatch/teambot/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package me.notsmatch.teambot

import com.jagrosh.jdautilities.command.CommandClientBuilder
import com.jagrosh.jdautilities.commons.waiter.EventWaiter
import me.notsmatch.teambot.command.ChooseCommand
import me.notsmatch.teambot.command.GuildlistCommand
import me.notsmatch.teambot.command.TagCommand
import me.notsmatch.teambot.command.TeamCommand
import me.notsmatch.teambot.command.*
import me.notsmatch.tracktablebot.command.AboutCommand
import net.dv8tion.jda.api.*
import net.dv8tion.jda.api.entities.Activity
Expand Down Expand Up @@ -37,6 +34,8 @@ class Bot (private val token: String) {
builder.addCommands(
TeamCommand(),
TagCommand(),
KanaTagCommand(),
NumTagCommand(),
AboutCommand(Color.GREEN, "https://github.com/riptakagi/mk8dx-teambot", Permission.VIEW_CHANNEL, Permission.MESSAGE_WRITE, Permission.MESSAGE_READ),
GuildlistCommand(eventWaiter),
ChooseCommand()
Expand Down
57 changes: 57 additions & 0 deletions src/main/kotlin/me/notsmatch/teambot/command/NumTagCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package me.notsmatch.teambot.command

import com.jagrosh.jdautilities.command.Command
import com.jagrosh.jdautilities.command.CommandEvent
import me.notsmatch.teambot.util.TagUtils
import me.notsmatch.teambot.util.NumberUtils
import net.dv8tion.jda.api.EmbedBuilder
import org.apache.commons.lang3.StringUtils
import java.awt.Color

class NumTagCommand : Command() {

init {
this.name = "numtag"
this.help = "ランダムな数字でタグを決めます"
this.arguments = "<文字数>"
}

override fun execute(event: CommandEvent?) {
event?.apply {
val args = StringUtils.split(args)

var tagLength: Int = 0
if (args.isNotEmpty()) {

if (!NumberUtils.isInteger(args[0])) {
return reply(EmbedBuilder().apply {
setColor(Color.RED)
setAuthor(
"Error",
null,
null
)
setDescription("文字数は1~10で指定してください\n``_tag <文字数>``")
}.build())
}

tagLength = args[0].toInt()

if (tagLength > 10 || tagLength < 1) {
return reply(EmbedBuilder().apply {
setColor(Color.RED)
setAuthor(
"Error",
null,
null
)
setDescription("文字数は1~10で指定してください\n``_tag <文字数>``")
}.build())
}

//結果出力
reply("タグ: " + TagUtils.randomNum(tagLength))
}
}
}
}

0 comments on commit 146f62c

Please sign in to comment.