Skip to content

Commit

Permalink
Initial help post message now deletes on post close
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen committed Oct 30, 2023
1 parent 9a6bba9 commit a403551
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/com/learnspigot/bot/help/CloseListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class CloseListener : ListenerAdapter() {
profileRegistry.messagesToRemove[channel.id]?.delete()?.queue()
CloseCommand.knowledgebasePostsUsed.remove(channel.id)

event.channel.asThreadChannel().getHistoryFromBeginning(2).complete().retrievedHistory[0].delete().complete()

event.channel.sendMessageEmbeds(embed()
.setTitle(event.member!!.effectiveName + " has closed the thread")
.setDescription("Listing ${if (contributors.isEmpty()) "no contributors." else contributors.joinToString(", ") {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/learnspigot/bot/help/PingCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class PingCommand {
}

val closeId = event.guild!!.retrieveCommands().complete()
.first { it.name == "close" }
.id
.firstOrNull { it.name == "close" }
?.id

event.replyEmbeds(
embed()
Expand All @@ -39,7 +39,7 @@ class PingCommand {
"Paste it @ https://paste.learnspigot.com and send it so we can help.",
false
)
.addField("I figured it out", "Great job! Run </close:$closeId> and select contributors.", false)
.addField("I figured it out", "Great job! Run ${if (closeId == null) "/close" else "</close$closeId>"} and select contributors.", false)
.build())
.setContent(channel.owner!!.asMention + " - You haven't responded in a while!")
.queue()
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/com/learnspigot/bot/help/ThreadListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class ThreadListener : ListenerAdapter() {
if (event.channelType != ChannelType.GUILD_PUBLIC_THREAD) return
if (event.channel.asThreadChannel().parentChannel.id != Server.helpChannel.id) return

val closeId = event.guild.retrieveCommands().complete()
.first { it.name == "close" }
.id
val closeId = event.guild!!.retrieveCommands().complete()
.firstOrNull { it.name == "close" }
?.id

event.channel.asThreadChannel().sendMessageEmbeds(
embed()
.setTitle("Thank you for creating a post!")
.setDescription("""
Please allow someone to read through your post and answer it! Hi Akkih!
Please allow someone to read through your post and answer it!
If you have managed to fix your problem, please run `</close:$closeId>`.
If you fixed your problem, please run ${if (closeId == null) "/close" else "</close$closeId>"}.
""".trimIndent())
.build()
).queue()
Expand Down

0 comments on commit a403551

Please sign in to comment.