File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
src/main/kotlin/net/azisaba/guildchatdiscord Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ plugins {
55}
66
77group = " net.azisaba"
8- version = " 2.1.2 "
8+ version = " 2.1.3 "
99
1010repositories {
1111 mavenCentral()
Original file line number Diff line number Diff line change @@ -41,18 +41,18 @@ object LinkCommand : CommandHandler {
4141 defer.respond { content = " コードが無効です。" }
4242 return
4343 }
44- val discordId = DatabaseManager .query(" SELECT `discord_id` FROM `users` WHERE `link_code` = ?" ) { stmt ->
44+ val discordIdAndExpiresAt = DatabaseManager .query(" SELECT `discord_id`, `expires_at ` FROM `users` WHERE `link_code` = ?" ) { stmt ->
4545 stmt.setString(1 , code)
4646 stmt.executeQuery().use { rs ->
4747 if (rs.next()) {
48- rs.getLong(" discord_id" )
48+ Pair ( rs.getLong(" discord_id" ), rs.getLong( " expires_at " ) )
4949 } else {
50- - 1L
50+ Pair ( - 1L , 0L )
5151 }
5252 }
5353 }
54- if (discordId != - 1L ) {
55- // already linked
54+ if (discordIdAndExpiresAt.first != - 1L || discordIdAndExpiresAt.second < System .currentTimeMillis() ) {
55+ // already linked or expired
5656 defer.respond { content = " コードが無効です。" }
5757 return
5858 }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ object DatabaseManager {
2020 `minecraft_uuid` VARCHAR(36) NOT NULL UNIQUE,
2121 `minecraft_name` VARCHAR(16) NOT NULL,
2222 `link_code` VARCHAR(8) NOT NULL UNIQUE,
23+ `expires_at` BIGINT NOT NULL DEFAULT 0,
2324 PRIMARY KEY (`id`)
2425 )
2526 """ .trimIndent()) { it.executeUpdate() }
You can’t perform that action at this time.
0 commit comments