Skip to content

Commit e1bb224

Browse files
authored
Merge pull request #130 from the-programmers-hangout/develop
release: merge develop with master for v2.7.0
2 parents af278e0 + b6ad47a commit e1bb224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+303
-272
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ version = Versions.BOT
33
description = "judgebot"
44

55
plugins {
6-
kotlin("jvm") version "1.5.10"
6+
kotlin("jvm") version "1.6.0"
7+
kotlin("plugin.serialization") version "1.6.0"
78
id("com.github.johnrengelman.shadow") version "7.0.0"
89
}
910

src/main/kotlin/me/ddivad/judgebot/Main.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.ddivad.judgebot
22

33
import dev.kord.common.annotation.KordPreview
4-
import dev.kord.common.kColor
54
import dev.kord.core.supplier.EntitySupplyStrategy
65
import dev.kord.gateway.Intent
76
import dev.kord.gateway.Intents
@@ -11,8 +10,9 @@ import me.ddivad.judgebot.dataclasses.Permissions
1110
import me.ddivad.judgebot.services.*
1211
import me.ddivad.judgebot.services.infractions.BanService
1312
import me.ddivad.judgebot.services.infractions.MuteService
14-
import me.jakejmattson.discordkt.api.dsl.bot
15-
import me.jakejmattson.discordkt.api.extensions.addInlineField
13+
import me.jakejmattson.discordkt.dsl.bot
14+
import me.jakejmattson.discordkt.extensions.addInlineField
15+
import me.jakejmattson.discordkt.extensions.pfpUrl
1616
import java.awt.Color
1717

1818
@KordPreview
@@ -24,8 +24,9 @@ suspend fun main() {
2424
require(token != null) { "Expected the bot token as an environment variable" }
2525

2626
bot(token) {
27+
val configuration = data("config/config.json") { Configuration() }
28+
2729
prefix {
28-
val configuration = discord.getInjectionObjects(Configuration::class)
2930
guild?.let { configuration[guild!!.id.value]?.prefix } ?: defaultPrefix
3031
}
3132

@@ -49,11 +50,9 @@ suspend fun main() {
4950
val botStats = it.discord.getInjectionObjects(BotStatsService::class)
5051
val channel = it.channel
5152
val self = channel.kord.getSelf()
52-
53-
color = it.discord.configuration.theme?.kColor
54-
53+
color = it.discord.configuration.theme
5554
thumbnail {
56-
url = self.avatar.url
55+
url = self.pfpUrl
5756
}
5857

5958
field {
@@ -70,7 +69,7 @@ suspend fun main() {
7069
field {
7170
name = "Build Info"
7271
value = "```" +
73-
"Version: 2.6.0\n" +
72+
"Version: 2.7.0\n" +
7473
"DiscordKt: ${versions.library}\n" +
7574
"Kord: ${versions.kord}\n" +
7675
"Kotlin: $kotlinVersion" +

src/main/kotlin/me/ddivad/judgebot/arguments/GuildConfigArg.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.ddivad.judgebot.arguments
22

3-
import me.jakejmattson.discordkt.api.arguments.*
4-
import me.jakejmattson.discordkt.api.commands.CommandEvent
3+
import me.jakejmattson.discordkt.arguments.*
4+
import me.jakejmattson.discordkt.commands.CommandEvent
55

66
val validConfigParameters = mutableListOf(
77
"setPrefix",

src/main/kotlin/me/ddivad/judgebot/arguments/LowerMemberArg.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package me.ddivad.judgebot.arguments
22

33
import dev.kord.core.entity.Member
4-
import me.jakejmattson.discordkt.api.arguments.*
5-
import me.jakejmattson.discordkt.api.commands.CommandEvent
6-
import me.jakejmattson.discordkt.api.extensions.isSelf
7-
import me.jakejmattson.discordkt.api.extensions.toSnowflakeOrNull
4+
import me.jakejmattson.discordkt.arguments.*
5+
import me.jakejmattson.discordkt.commands.CommandEvent
6+
import me.jakejmattson.discordkt.extensions.isSelf
7+
import me.jakejmattson.discordkt.extensions.toSnowflakeOrNull
88

99
open class LowerMemberArg(override val name: String = "LowerMemberArg") : Argument<Member> {
1010
companion object : LowerMemberArg()

src/main/kotlin/me/ddivad/judgebot/arguments/LowerUserArg.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package me.ddivad.judgebot.arguments
22

33
import dev.kord.core.entity.User
4-
import me.jakejmattson.discordkt.api.arguments.*
5-
import me.jakejmattson.discordkt.api.commands.CommandEvent
6-
import me.jakejmattson.discordkt.api.extensions.isSelf
7-
import me.jakejmattson.discordkt.api.extensions.toSnowflakeOrNull
4+
import me.jakejmattson.discordkt.arguments.*
5+
import me.jakejmattson.discordkt.commands.CommandEvent
6+
import me.jakejmattson.discordkt.extensions.isSelf
7+
import me.jakejmattson.discordkt.extensions.toSnowflakeOrNull
88

99
open class LowerUserArg(override val name: String = "LowerUserArg") : Argument<User> {
1010
companion object : LowerUserArg()

src/main/kotlin/me/ddivad/judgebot/arguments/RuleArg.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package me.ddivad.judgebot.arguments
33
import dev.kord.core.entity.Guild
44
import me.ddivad.judgebot.dataclasses.Rule
55
import me.ddivad.judgebot.services.DatabaseService
6-
import me.jakejmattson.discordkt.api.arguments.*
7-
import me.jakejmattson.discordkt.api.commands.CommandEvent
6+
import me.jakejmattson.discordkt.arguments.*
7+
import me.jakejmattson.discordkt.commands.CommandEvent
88

99
open class RuleArg(override val name: String = "Rule") : Argument<Rule> {
1010
override val description = "A rule number"

src/main/kotlin/me/ddivad/judgebot/commands/GuildCommands.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import me.ddivad.judgebot.dataclasses.Permissions
88
import me.ddivad.judgebot.embeds.createActivePunishmentsEmbed
99
import me.ddivad.judgebot.services.DatabaseService
1010
import me.ddivad.judgebot.services.infractions.MuteService
11-
import me.jakejmattson.discordkt.api.commands.commands
11+
import me.jakejmattson.discordkt.commands.commands
1212

1313
@Suppress("unused")
1414
fun guildConfigCommands(configuration: Configuration,
1515
databaseService: DatabaseService,
1616
muteService: MuteService) = commands("Guild") {
17-
guildCommand("setup") {
17+
command("setup") {
1818
description = "Configure a guild to use Judgebot."
1919
requiredPermission = Permissions.ADMINISTRATOR
2020
execute {
@@ -30,7 +30,7 @@ fun guildConfigCommands(configuration: Configuration,
3030
}
3131
}
3232

33-
guildCommand("configuration") {
33+
command("configuration") {
3434
description = "Update configuration parameters for this guild (conversation)."
3535
requiredPermission = Permissions.STAFF
3636
execute(GuildConfigArg.optional("options")) {
@@ -44,7 +44,7 @@ fun guildConfigCommands(configuration: Configuration,
4444
}
4545
}
4646

47-
guildCommand("activePunishments") {
47+
command("activePunishments") {
4848
description = "View active punishments for a guild."
4949
requiredPermission = Permissions.STAFF
5050
execute {

src/main/kotlin/me/ddivad/judgebot/commands/InfoCommands.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import me.ddivad.judgebot.dataclasses.Permissions
99
import me.ddivad.judgebot.embeds.createInformationEmbed
1010
import me.ddivad.judgebot.extensions.testDmStatus
1111
import me.ddivad.judgebot.services.DatabaseService
12-
import me.jakejmattson.discordkt.api.arguments.EveryArg
13-
import me.jakejmattson.discordkt.api.arguments.IntegerArg
14-
import me.jakejmattson.discordkt.api.commands.commands
15-
import me.jakejmattson.discordkt.api.extensions.sendPrivateMessage
12+
import me.jakejmattson.discordkt.arguments.EveryArg
13+
import me.jakejmattson.discordkt.arguments.IntegerArg
14+
import me.jakejmattson.discordkt.commands.commands
15+
import me.jakejmattson.discordkt.extensions.sendPrivateMessage
1616

1717
@Suppress("unused")
1818
fun createInformationCommands(databaseService: DatabaseService) = commands("Information") {
19-
guildCommand("info") {
19+
command("info") {
2020
description = "Send an information message to a guild member"
2121
requiredPermission = Permissions.MODERATOR
2222
execute(LowerMemberArg, EveryArg("Info Content")) {
@@ -30,7 +30,7 @@ fun createInformationCommands(databaseService: DatabaseService) = commands("Info
3030
return@execute
3131
}
3232
val user = databaseService.users.getOrCreateUser(target, guild)
33-
val information = Info(content, author.id.asString)
33+
val information = Info(content, author.id.toString())
3434
databaseService.users.addInfo(guild, user, information)
3535
target.sendPrivateMessage {
3636
createInformationEmbed(guild, target, information)
@@ -39,13 +39,13 @@ fun createInformationCommands(databaseService: DatabaseService) = commands("Info
3939
}
4040
}
4141

42-
guildCommand("removeInfo") {
42+
command("removeInfo") {
4343
description = "Remove an information message from a member record."
4444
requiredPermission = Permissions.STAFF
4545
execute(LowerMemberArg, IntegerArg("Info ID")) {
4646
val (target, id) = args
4747
val user = databaseService.users.getOrCreateUser(target, guild)
48-
if (user.getGuildInfo(guild.id.asString).info.isEmpty()) {
48+
if (user.getGuildInfo(guild.id.toString()).info.isEmpty()) {
4949
respond("${target.mention} has no information records.")
5050
return@execute
5151
}

src/main/kotlin/me/ddivad/judgebot/commands/InfractionCommands.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import me.ddivad.judgebot.services.*
1717
import me.ddivad.judgebot.services.infractions.BadPfpService
1818
import me.ddivad.judgebot.services.infractions.BadnameService
1919
import me.ddivad.judgebot.services.infractions.InfractionService
20-
import me.jakejmattson.discordkt.api.arguments.BooleanArg
21-
import me.jakejmattson.discordkt.api.arguments.EveryArg
22-
import me.jakejmattson.discordkt.api.arguments.IntegerArg
23-
import me.jakejmattson.discordkt.api.commands.commands
24-
import me.jakejmattson.discordkt.api.conversations.ConversationResult
20+
import me.jakejmattson.discordkt.arguments.BooleanArg
21+
import me.jakejmattson.discordkt.arguments.EveryArg
22+
import me.jakejmattson.discordkt.arguments.IntegerArg
23+
import me.jakejmattson.discordkt.commands.commands
24+
import me.jakejmattson.discordkt.conversations.ConversationResult
2525

2626
@KordPreview
2727
@Suppress("unused")
@@ -30,7 +30,7 @@ fun createInfractionCommands(databaseService: DatabaseService,
3030
infractionService: InfractionService,
3131
badPfpService: BadPfpService,
3232
badnameService: BadnameService) = commands("Infraction") {
33-
guildCommand("strike", "s", "S") {
33+
command("strike", "s", "S") {
3434
description = "Strike a user."
3535
requiredPermission = Permissions.STAFF
3636
execute(LowerMemberArg, IntegerArg("Weight").optional(1), EveryArg("Reason")) {
@@ -59,7 +59,7 @@ fun createInfractionCommands(databaseService: DatabaseService,
5959
}
6060
}
6161

62-
guildCommand("warn", "w", "W") {
62+
command("warn", "w", "W") {
6363
description = "Warn a user."
6464
requiredPermission = Permissions.MODERATOR
6565
execute(LowerMemberArg, EveryArg("Reason")) {
@@ -77,7 +77,7 @@ fun createInfractionCommands(databaseService: DatabaseService,
7777
}
7878
}
7979

80-
guildCommand("badpfp") {
80+
command("badpfp") {
8181
description = "Notifies the user that they should change their profile pic and applies a 30 minute mute. Bans the user if they don't change picture."
8282
requiredPermission = Permissions.STAFF
8383
execute(BooleanArg("cancel", "apply", "cancel").optional(true), LowerMemberArg) {
@@ -102,13 +102,13 @@ fun createInfractionCommands(databaseService: DatabaseService,
102102
return@execute
103103
}
104104

105-
val badPfp = Infraction(author.id.asString, "BadPfp", InfractionType.BadPfp)
105+
val badPfp = Infraction(author.id.toString(), "BadPfp", InfractionType.BadPfp)
106106
badPfpService.applyBadPfp(targetMember, guild, timeLimit)
107107
respond("${targetMember.mention} has been muted and a badpfp has been triggered with a time limit of $minutesUntilBan minutes.")
108108
}
109109
}
110110

111-
guildCommand("badname") {
111+
command("badname") {
112112
description = "Rename a guild member that has a bad name."
113113
requiredPermission = Permissions.MODERATOR
114114
execute(LowerMemberArg) {
@@ -117,12 +117,12 @@ fun createInfractionCommands(databaseService: DatabaseService,
117117
}
118118
}
119119

120-
guildCommand("cleanseInfractions") {
120+
command("cleanseInfractions") {
121121
description = "Use this to delete (permanently) as user's infractions."
122122
requiredPermission = Permissions.ADMINISTRATOR
123123
execute(LowerUserArg) {
124124
val user = databaseService.users.getOrCreateUser(args.first, guild)
125-
if (user.getGuildInfo(guild.id.asString).infractions.isEmpty()) {
125+
if (user.getGuildInfo(guild.id.toString()).infractions.isEmpty()) {
126126
respond("User has no infractions.")
127127
return@execute
128128
}
@@ -131,12 +131,12 @@ fun createInfractionCommands(databaseService: DatabaseService,
131131
}
132132
}
133133

134-
guildCommand("removeInfraction") {
134+
command("removeInfraction") {
135135
description = "Use this to delete (permanently) an infraction from a user."
136136
requiredPermission = Permissions.ADMINISTRATOR
137137
execute(LowerUserArg, IntegerArg("Infraction ID")) {
138138
val user = databaseService.users.getOrCreateUser(args.first, guild)
139-
if (user.getGuildInfo(guild.id.asString).infractions.isEmpty()) {
139+
if (user.getGuildInfo(guild.id.toString()).infractions.isEmpty()) {
140140
respond("User has no infractions.")
141141
return@execute
142142
}

src/main/kotlin/me/ddivad/judgebot/commands/MuteCommands.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import me.ddivad.judgebot.extensions.testDmStatus
99
import me.ddivad.judgebot.services.infractions.MuteService
1010
import me.ddivad.judgebot.services.infractions.RoleState
1111
import me.ddivad.judgebot.util.timeToString
12-
import me.jakejmattson.discordkt.api.arguments.EveryArg
13-
import me.jakejmattson.discordkt.api.arguments.TimeArg
14-
import me.jakejmattson.discordkt.api.arguments.UserArg
15-
import me.jakejmattson.discordkt.api.commands.commands
12+
import me.jakejmattson.discordkt.arguments.EveryArg
13+
import me.jakejmattson.discordkt.arguments.TimeArg
14+
import me.jakejmattson.discordkt.arguments.UserArg
15+
import me.jakejmattson.discordkt.commands.commands
1616
import kotlin.math.roundToLong
1717

1818
@Suppress("unused")
1919
fun createMuteCommands(muteService: MuteService) = commands("Mute") {
20-
guildCommand("mute") {
20+
command("mute") {
2121
description = "Mute a user for a specified time."
2222
requiredPermission = Permissions.MODERATOR
2323
execute(LowerMemberArg, TimeArg("Time"), EveryArg("Reason")) {
@@ -34,7 +34,7 @@ fun createMuteCommands(muteService: MuteService) = commands("Mute") {
3434
}
3535
}
3636

37-
guildCommand("unmute") {
37+
command("unmute") {
3838
description = "Unmute a user."
3939
requiredPermission = Permissions.MODERATOR
4040
execute(LowerMemberArg) {
@@ -49,7 +49,7 @@ fun createMuteCommands(muteService: MuteService) = commands("Mute") {
4949
}
5050
}
5151

52-
guildCommand("gag") {
52+
command("gag") {
5353
description = "Mute a user for 5 minutes while you deal with something"
5454
requiredPermission = Permissions.MODERATOR
5555
execute(LowerMemberArg) {

0 commit comments

Comments
 (0)