This repository has been archived by the owner on Aug 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/kotlin/me/notsmatch/teambot/command/NumTagCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} | ||
} | ||
} |