Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
サーバーを起動してから一度しかDMに対して認証失敗のメッセージを送信しないようにした #12
Browse files Browse the repository at this point in the history
close #12
  • Loading branch information
sya-ri committed Feb 23, 2021
1 parent efa4c47 commit 9c08589
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter

object DiscordEventListener : ListenerAdapter() {
private val alreadyFailureMessage = mutableSetOf<Long>()

override fun onPrivateMessageReceived(event: PrivateMessageReceivedEvent) {
if (event.author.isBot) return
val authPlayer = DiscordMember.auth(event.message.contentRaw, event.author.idLong)
val authorId = event.author.idLong
val authPlayer = DiscordMember.auth(event.message.contentRaw, authorId)
if (authPlayer != null) {
authPlayer.player?.sendMessage(templateMessage("&6${event.author.asTag} &fと連携しました"))
event.channel.sendMessage("認証に成功しました")
} else {
event.channel.sendMessage("認証に失敗しました")
if (alreadyFailureMessage.contains(authorId)) return
alreadyFailureMessage.add(authorId)
event.channel.sendMessage("`/twnp connect` というコマンドをサーバー内で実行して認証コードを取得してください")
}.complete()
}
}

0 comments on commit 9c08589

Please sign in to comment.