Skip to content

Commit bbab2d9

Browse files
authored
Merge pull request #34 from the-programmers-hangout/develop
release: merge develop into master for v1.2.0
2 parents 97e8a79 + 177af6b commit bbab2d9

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<a href="https://kotlinlang.org/"><img src="https://img.shields.io/badge/Kotlin-1.4.0-blue.svg?logo=Kotlin" alt="Kotlin 1.4.0"></a>
2+
<a href="https://github.com/JakeJMattson/DiscordKt">
3+
<img alt="DiscordKt 0.21.3" src="https://img.shields.io/badge/DiscordKt-0.21.3-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAEvElEQVRYw+2Yy2seVRiHn3Ob756kiWlrq7ZqDSJUsSqoK4srQXHjRnShf4ILl/4FrkVcKLgS1FW3FRR05b1IMVXbNG2SJvny5ct3nZkz5+IitpW2giYOFskLA7M4Z+Y57/m9P857YC92F+Lqy/T0M/F2Atvc/EIAyNs9g3uAuw3974lZMFc9jsJwLj+Dj+72ATxSO8KrB1/nHjOHd5q1rM3Hm+/zc/b9f1vFTV3npbuf49k7ThJ9gisM3ulrz5nBj3zSfY+u39hxFe8IUCA4efgRXjv2PA05iXeaiGHyiRa2L+l87SnsNmRaBE53T3F68CnuH2z7jgHvm5rljRPPMTdxz7VMVeemOPTyYSp3JgCMzlt+fWdA71zEO41zmqV0hY823mPBzpcHeKg1wYcvvEJCDe8V1GpMv3iM5qMzN42NEdpfjFn4YETakXinyQt4e/ktLtvz5Rj1s/cfpVWPmEpO88Emh988cUs4ACFg/8k6j707w+wT23NqVc+Tk0+X54ONisBUcnRiqT9/P157vPd/OT7GiFM5B16SJJWcpJJTM6o8m6lVBCaxSBmIaU5sVXGFxXuB1gYpr/48YnNLlmYgInISTDVDFoZ6mYB3tAw6sUjlQVyXbAyRwlqUUiAEaZoSQ7imcCEiSSXHK89krVoeoNEek1i8V3hxc01577F5QSTcIMhtDUrlSYwrD3CyLrcz6BUBzy3LPsuham7gu57BZjUpr0jqFYE2BdoUmIX5bS+5ack3fDKC+2ENnVhMJadqYnkZbA9ztCkIMiCWziJ7bewjTxFmD17nUX8CXB/gv7pAuDTCJBrvFZ1sUB5gp+9Z35LMTjm0CsjxKuarUxQH7iV/+ElivQFCIEYp6odzhF9WiU5jEo2QnvZajc1RiRo0JtIbw3CkmZkKTLX+yGb7POqzRYqDx1AuIi5dIRSCkGikDPQtLK9VGI8jifHlAQ5zi1YFISjWupLeSLN/2lE1AekDanWe4BVBK7xQZCGy1jV0uooQLcoERn5YogZHGd3UMtXQaKmwXnLpimKiEZmddmgp8TIQRaDT1bTbGlsEjLE4qehmlp4dlQfoY6CfFgxTz76mpllVSKkYZprhkqHViOAl3X5CnguEdhgiQ+9pDwNpIfEyLw/w4sYYj0NIxcYwMBgrZiY0iY5EL+mPFdFHoijQJuKjY3Mo2RpFolBECYuD1fJ8sJ85Pp/f4EpvjFKBAsdyz9IeWKJyaO1QxiGVo59nLG9ljIscpR1bdsB36xdJfVZmkXhSF/lmsc++dsrxuxrsq1VIi8jlTqBZUcQg6I8FtpAorcl9wfzGgKWtETEKBkVa4hZ3Uu6cSjg6U6U7Lvjy1x5376vw0KEGiTQMck8MEoREKMFCZ8C59SHOgZSSy70Ri71u+U3T/omEx4+2mKprQJBIwYOHGhyZrkFULG9Zzi6NGeWeGCVjG/hppcul7t+3mF01TVcnHp2t8tiRFonePuNJISAIfIQYBD4IfmuP+Gmlh/NhR13djvviCCy0M1a6OcfvavLAgfr2IUtEBLDSt3y32GeY766B33XjnrvItxcH/LaeMXewipaCC+2M1Z69va4+tsYFX18o9m639gD/d4B7sdv4Hc8YdmfiizvVAAAAAElFTkSuQmCC">
4+
</a>
5+
<a href="https://hub.docker.com/repository/docker/theprogrammershangout/judgebot/tags?page=1">
6+
<img src="https://img.shields.io/docker/cloud/build/theprogrammershangout/judgebot.svg?label=Docker&logo=docker" alt="Docker">
7+
</a>
8+
19
# judgebot
210

311
> A Discord bot to manage guild rules, infractions and punishments for guild members that don't play nicely.
@@ -10,5 +18,5 @@ $ cp .env.example .env
1018
Edit the .env file with your favourite editor, filling out the token, default prefix and mongo configuration.
1119

1220
```
13-
$ docker-compose up --build --detach
21+
$ docker-compose up --detach
1422
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ suspend fun main(args: Array<String>) {
5656
field {
5757
name = "Build Info"
5858
value = "```" +
59-
"Version: 1.1.2\n" +
59+
"Version: 1.2.0\n" +
6060
"DiscordKt: ${versions.library}\n" +
6161
"Kotlin: $kotlinVersion" +
6262
"```"

src/main/kotlin/me/ddivad/judgebot/embeds/InfractionEmbeds.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ fun EmbedBuilder.createModeratorInfractionEmbed(guild: Guild, user: Member, infr
156156
}
157157
}
158158

159-
fun EmbedBuilder.createMessageDeleteEmbed(guild: Guild, user: User, message: Message) {
159+
fun EmbedBuilder.createMessageDeleteEmbed(guild: Guild, message: Message) {
160+
var messageContent = message.content.take(1010)
161+
if (message.content.length > 1024) messageContent += " ..."
162+
160163
title = "Message Deleted"
161164
thumbnail {
162165
url = guild.getIconUrl(Image.Format.PNG) ?: ""
@@ -166,7 +169,7 @@ fun EmbedBuilder.createMessageDeleteEmbed(guild: Guild, user: User, message: Mes
166169
Your ${if (message.attachments.isNotEmpty()) "image" else "message"} was deleted from ${message.channel.mention}
167170
as it is against our server rules.
168171
""".trimIndent()
169-
addField("Message", "```${message.content}```")
172+
addField("Message", "```${messageContent}```")
170173
if (message.attachments.isNotEmpty()) {
171174
addField("Filename", "```${message.attachments.first().filename}```")
172175
}

src/main/kotlin/me/ddivad/judgebot/listeners/StaffReactionListeners.kt

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

3+
import com.gitlab.kordlib.common.exception.RequestException
34
import com.gitlab.kordlib.core.event.message.ReactionAddEvent
45
import me.ddivad.judgebot.dataclasses.Configuration
56
import me.ddivad.judgebot.embeds.createMessageDeleteEmbed
67
import me.ddivad.judgebot.embeds.createSelfHistoryEmbed
8+
import me.ddivad.judgebot.extensions.testDmStatus
79
import me.ddivad.judgebot.services.DatabaseService
810
import me.ddivad.judgebot.services.PermissionLevel
911
import me.ddivad.judgebot.services.PermissionsService
@@ -32,15 +34,22 @@ fun onStaffReactionAdd(muteService: MuteService,
3234
}
3335
guildConfiguration.reactions.historyReaction -> {
3436
message.deleteReaction(this.emoji)
35-
val target = databaseService.users.getOrCreateUser(messageAuthor, guild!!.asGuild())
36-
it.sendPrivateMessage { createSelfHistoryEmbed(messageAuthor, target, guild!!.asGuild(), configuration) }
37+
val target = databaseService.users.getOrCreateUser(messageAuthor, guild.asGuild())
38+
it.sendPrivateMessage { createSelfHistoryEmbed(messageAuthor, target, guild.asGuild(), configuration) }
3739
}
3840
guildConfiguration.reactions.deleteMessageReaction -> {
41+
val content = message.asMessage()
3942
message.deleteReaction(this.emoji)
40-
messageAuthor.sendPrivateMessage {
41-
createMessageDeleteEmbed(guild, messageAuthor, message.asMessage())
42-
}
4343
message.delete()
44+
try {
45+
messageAuthor.sendPrivateMessage {
46+
createMessageDeleteEmbed(guild, content)
47+
}
48+
} catch (ex: RequestException) {
49+
this.user.sendPrivateMessage("User ${messageAuthor.mention} has DM's disabled." +
50+
" Message deleted without notification.")
51+
}
52+
4453
}
4554
}
4655
}

0 commit comments

Comments
 (0)