Skip to content

Commit 88fb0e8

Browse files
committed
fix errors
1 parent d525e60 commit 88fb0e8

14 files changed

+232
-209
lines changed

Diff for: src/main/kotlin/moe/nikky/BotInfoExtension.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import dev.kordex.core.extensions.ephemeralSlashCommand
1010
import dev.kord.common.entity.Permission
1111
import dev.kord.common.entity.Permissions
1212
import dev.kord.rest.builder.message.embed
13+
import dev.kordex.core.i18n.toKey
1314
import io.klogging.Klogging
1415
import io.ktor.http.*
1516
import kotlinx.coroutines.flow.count
@@ -50,21 +51,21 @@ class BotInfoExtension : Extension(), Klogging {
5051

5152
inner class SetAdminRoleArgs : Arguments() {
5253
val role by role {
53-
name = "role"
54-
description = "admin role"
54+
name = "role".toKey()
55+
description = "admin role".toKey()
5556
}
5657
}
5758

5859
override suspend fun setup() {
5960
val self = kord.getSelf()
6061

6162
ephemeralSlashCommand {
62-
name = "bot"
63-
description = "${self.username} related commands"
63+
name = "bot".toKey()
64+
description = "${self.username} related commands".toKey()
6465

6566
ephemeralSubCommand() {
66-
name = "show-config"
67-
description = "shows the current configuration of (${self.username} ${self.mention})"
67+
name = "show-config".toKey()
68+
description = "shows the current configuration of (${self.username} ${self.mention})".toKey()
6869
allowInDms = false
6970

7071
check {
@@ -110,8 +111,8 @@ class BotInfoExtension : Extension(), Klogging {
110111
}
111112

112113
ephemeralSubCommand {
113-
name = "invite"
114-
description = "get invite url"
114+
name = "invite".toKey()
115+
description = "get invite url".toKey()
115116

116117
action {
117118
withLogContextOptionalGuild(event, guild) { guild ->
@@ -124,8 +125,8 @@ class BotInfoExtension : Extension(), Klogging {
124125
}
125126

126127
ephemeralSubCommand {
127-
name = "stats"
128-
description = "shows some numbers about (${self.username} ${self.mention})"
128+
name = "stats".toKey()
129+
description = "shows some numbers about (${self.username} ${self.mention})".toKey()
129130
action {
130131
val roleManagement: RoleManagementExtension? = getKoin().getOrNull()
131132
val twitch: TwitchExtension? = getKoin().getOrNull()

Diff for: src/main/kotlin/moe/nikky/ConfigurationExtension.kt

+10-9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import dev.kord.core.behavior.GuildBehavior
1919
import dev.kord.core.entity.Role
2020
import dev.kord.core.event.Event
2121
import dev.kord.core.event.interaction.InteractionCreateEvent
22+
import dev.kordex.core.i18n.toKey
2223
import io.github.xn32.json5k.SerialComment
2324
import io.klogging.Klogging
2425
import kotlinx.serialization.Serializable
@@ -54,22 +55,22 @@ class ConfigurationExtension : Extension(), Klogging {
5455

5556
inner class SetAdminRoleArgs : Arguments() {
5657
val role by role {
57-
name = "role"
58-
description = "admin role"
58+
name = "role".toKey()
59+
description = "admin role".toKey()
5960
}
6061
}
6162

6263
override suspend fun setup() {
6364
val self = kord.getSelf()
6465
ephemeralSlashCommand {
65-
name = "config"
66+
name = "config".toKey()
6667
// description = "${self.username} related commands"
67-
description = "self.username related commands"
68+
description = "self.username related commands".toKey()
6869
allowInDms = false
6970

7071
ephemeralSubCommand(::SetAdminRoleArgs) {
71-
name = "adminset"
72-
description = "sets the admin role"
72+
name = "adminset".toKey()
73+
description = "sets the admin role".toKey()
7374

7475
check {
7576
hasPermission(Permission.Administrator)
@@ -90,8 +91,8 @@ class ConfigurationExtension : Extension(), Klogging {
9091
}
9192

9293
ephemeralSubCommand {
93-
name = "adminunset"
94-
description = "clears admin role"
94+
name = "adminunset".toKey()
95+
description = "clears admin role".toKey()
9596
check {
9697
hasPermission(Permission.Administrator)
9798
}
@@ -115,7 +116,7 @@ class ConfigurationExtension : Extension(), Klogging {
115116
}
116117

117118
suspend fun CheckContext<Event>.requiresBotControl(locale: Locale) {
118-
val guild = guildFor(event)?.asGuildOrNull() ?: relayError("cannot load guild")
119+
val guild = guildFor(event)?.asGuildOrNull() ?: relayError("cannot load guild".toKey())
119120
val configUnit = guild.config()
120121
val guildConfig = configUnit.get()
121122
val adminRole = guildConfig?.adminRole(guild)

Diff for: src/main/kotlin/moe/nikky/DiceExtension.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import dev.kordex.core.commands.Arguments
99
import dev.kordex.core.commands.converters.impl.string
1010
import dev.kordex.core.extensions.Extension
1111
import dev.kordex.core.extensions.publicSlashCommand
12+
import dev.kordex.core.i18n.toKey
1213
import io.klogging.Klogging
1314

1415
class DiceExtension() : Extension(), Klogging {
1516
override val name: String = "dice"
1617
override suspend fun setup() {
1718
publicSlashCommand(::DiceArgs) {
18-
name = "dice"
19-
description = "rolls dice"
19+
name = "dice".toKey()
20+
description = "rolls dice".toKey()
2021
allowInDms = true
2122

2223
action {
@@ -45,8 +46,8 @@ class DiceExtension() : Extension(), Klogging {
4546

4647
inner class DiceArgs : Arguments() {
4748
val notation by string {
48-
name = "notation"
49-
description = "dices to roll"
49+
name = "notation".toKey()
50+
description = "dices to roll".toKey()
5051
}
5152
}
5253
}

Diff for: src/main/kotlin/moe/nikky/KloggingExt.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dev.kord.core.entity.Guild
66
import dev.kord.core.entity.channel.GuildChannel
77
import dev.kord.core.event.Event
88
import dev.kord.core.event.interaction.InteractionCreateEvent
9+
import dev.kordex.core.i18n.toKey
910
import io.klogging.context.logContext
1011
import io.klogging.events.LogEvent
1112
import io.klogging.logger
@@ -141,7 +142,7 @@ suspend fun <E : Event, T> Extension.withLogContext(
141142
guildBehavior: GuildBehavior?,
142143
block: suspend CoroutineScope.(Guild) -> T,
143144
): T {
144-
val guild = guildBehavior?.asGuild() ?: relayError("cannot load guild")
145+
val guild = guildBehavior?.asGuild() ?: relayError("cannot load guild".toKey())
145146
val items = mutableListOf<Pair<String, String?>>()
146147
if (event is InteractionCreateEvent) {
147148
items += "channel" to (event.interaction.channel.asChannel() as? GuildChannel)?.name

Diff for: src/main/kotlin/moe/nikky/LocalTimeExtension.kt

+14-13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import dev.kord.common.entity.Snowflake
1515
import dev.kord.core.behavior.GuildBehavior
1616
import dev.kord.core.entity.User
1717
import dev.kord.rest.builder.message.embed
18+
import dev.kordex.core.i18n.toKey
1819
import io.klogging.Klogging
1920
import io.ktor.client.request.forms.*
2021
import io.ktor.utils.io.*
@@ -60,12 +61,12 @@ class LocalTimeExtension : Extension(), Klogging {
6061
override suspend fun setup() {
6162

6263
ephemeralSlashCommand(::TimezoneArgs) {
63-
name = "timezone"
64-
description = "list or set timezones"
64+
name = "timezone".toKey()
65+
description = "list or set timezones".toKey()
6566

6667
ephemeralSubCommand(::TimezoneArgs) {
67-
name = "set"
68-
description = "update your timezone"
68+
name = "set".toKey()
69+
description = "update your timezone".toKey()
6970

7071
action {
7172
withLogContext(event, guild) { guild ->
@@ -118,8 +119,8 @@ class LocalTimeExtension : Extension(), Klogging {
118119
}
119120

120121
ephemeralSubCommand() {
121-
name = "list"
122-
description = "sends a list of valid timezones"
122+
name = "list".toKey()
123+
description = "sends a list of valid timezones".toKey()
123124

124125
action {
125126
withLogContext(event, guild) { guild ->
@@ -144,7 +145,7 @@ class LocalTimeExtension : Extension(), Klogging {
144145
}
145146

146147
ephemeralUserCommand {
147-
name = "Local Time"
148+
name = "Local Time".toKey()
148149

149150
action {
150151
withLogContext(event, guild) { guild ->
@@ -162,8 +163,8 @@ class LocalTimeExtension : Extension(), Klogging {
162163
}
163164
}
164165
ephemeralSlashCommand(::TimezoneTargetArgs) {
165-
name = "LocalTime"
166-
description = "get the local time for a user"
166+
name = "LocalTime".toKey()
167+
description = "get the local time for a user".toKey()
167168

168169
action {
169170
withLogContext(event, guild) { guild ->
@@ -224,8 +225,8 @@ class LocalTimeExtension : Extension(), Klogging {
224225

225226
inner class TimezoneArgs : Arguments() {
226227
val timezoneId by string {
227-
name = "timezone"
228-
description = "time zone id"
228+
name = "timezone".toKey()
229+
description = "time zone id".toKey()
229230

230231
autoComplete { event ->
231232
val now = Clock.System.now()
@@ -248,8 +249,8 @@ class LocalTimeExtension : Extension(), Klogging {
248249

249250
inner class TimezoneTargetArgs : Arguments() {
250251
val user by user {
251-
name = "user"
252-
description = "user to get local time for"
252+
name = "user".toKey()
253+
description = "user to get local time for".toKey()
253254
}
254255
}
255256
}

Diff for: src/main/kotlin/moe/nikky/RoleChooserConfig.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import dev.kord.core.entity.ReactionEmoji
1010
import dev.kord.core.entity.Role
1111
import dev.kord.core.entity.channel.TextChannel
1212
import dev.kord.rest.request.KtorRequestException
13+
import dev.kordex.core.i18n.toKey
1314
import io.github.xn32.json5k.SerialComment
1415
import io.klogging.context.logContext
1516
import io.klogging.logger
@@ -44,7 +45,7 @@ data class RoleChooserConfig(
4445
logContext("guild" to guildBehavior.name)
4546
) {
4647
guildBehavior.getChannelOfOrNull<TextChannel>(channelId)
47-
?: relayError("channel $channelId in '${guildBehavior.name}' could not be loaded as TextChannel")
48+
?: relayError("channel $channelId in '${guildBehavior.name}' could not be loaded as TextChannel".toKey())
4849
}
4950
}
5051

@@ -56,7 +57,7 @@ data class RoleChooserConfig(
5657
channel(guildBehavior).getMessageOrNull(messageId)
5758
} catch (e: KtorRequestException) {
5859
logger.errorF { e.message }
59-
relayError("cannot access message $messageId")
60+
relayError("cannot access message $messageId".toKey())
6061
}
6162
}
6263
}

0 commit comments

Comments
 (0)