-
Notifications
You must be signed in to change notification settings - Fork 4
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
ITesserakt
committed
Mar 25, 2019
1 parent
8acc376
commit 84e4e7f
Showing
53 changed files
with
698 additions
and
645 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package handler | ||
|
||
import discord4j.core.event.domain.Event | ||
import kotlinx.coroutines.Job | ||
|
||
abstract class Handler <T : Event> { | ||
abstract fun handle(event : T) | ||
abstract fun handle(event: T): Job | ||
} |
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
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package types | ||
|
||
import context.ICommandContext | ||
import reactor.core.publisher.toMono | ||
|
||
class BooleanResolver : ITypeResolver<Boolean> { | ||
override fun read(context: ICommandContext, input: String) = input.toBoolean().toMono() | ||
override suspend fun read(context: ICommandContext, input: String) = input.toBoolean() | ||
} |
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package types | ||
|
||
import context.ICommandContext | ||
import reactor.core.publisher.Mono | ||
import reactor.core.publisher.toMono | ||
|
||
class CharResolver : ITypeResolver<Char> { | ||
override fun read(context: ICommandContext, input: String): Mono<Char> = input[0].toMono() | ||
override suspend fun read(context: ICommandContext, input: String): Char = input[0] | ||
} |
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
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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package types | ||
|
||
import context.ICommandContext | ||
import reactor.core.publisher.Mono | ||
import reactor.core.publisher.switchIfEmpty | ||
import kotlinx.coroutines.Deferred | ||
import util.toOptional | ||
|
||
abstract class MentionableResolver<T> : ITypeResolver<T> { | ||
abstract fun mentionMatch(context: ICommandContext, input: String): Mono<T> | ||
abstract fun idMatch(context: ICommandContext, input: String): Mono<T> | ||
abstract fun elseMatch(context: ICommandContext, input: String): Mono<T> | ||
abstract fun mentionMatchAsync(context: ICommandContext, input: String): Deferred<T?> | ||
abstract fun idMatchAsync(context: ICommandContext, input: String): Deferred<T?> | ||
abstract fun elseMatchAsync(context: ICommandContext, input: String): Deferred<T?> | ||
abstract val exceptionMessage : String | ||
|
||
override fun read(context: ICommandContext, input: String): Mono<T> { | ||
override suspend fun read(context: ICommandContext, input: String): T { | ||
return when { | ||
Regex("""^<.\d{18}>$""").matches(input) -> mentionMatch(context, input) | ||
Regex("""^\d{18}$""").matches(input) -> idMatch(context, input) | ||
else -> elseMatch(context, input) | ||
}.switchIfEmpty { throw NoSuchElementException(exceptionMessage) } | ||
Regex("""^<.\d{18}>$""").matches(input) -> mentionMatchAsync(context, input) | ||
Regex("""^\d{18}$""").matches(input) -> idMatchAsync(context, input) | ||
else -> elseMatchAsync(context, input) | ||
}.await() | ||
.toOptional() | ||
.orElseThrow { NoSuchElementException(exceptionMessage) } | ||
} | ||
} |
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
Oops, something went wrong.