yeet
This commit is contained in:
parent
b0e2255767
commit
7cad13248a
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.idea/
|
.idea/
|
||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
|
out/
|
||||||
|
|
|
@ -1,18 +1,49 @@
|
||||||
package nl.voidcorp.ottologs
|
package nl.voidcorp.ottologs
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder
|
||||||
import net.dv8tion.jda.api.JDABuilder
|
import net.dv8tion.jda.api.JDABuilder
|
||||||
import net.dv8tion.jda.api.entities.Activity
|
import net.dv8tion.jda.api.entities.Activity
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent
|
||||||
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
|
import java.awt.Color
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val token: String = System.getenv("DISCORD_TOKEN") ?: throw RuntimeException("Missing DISCORD_TOKEN in env!")
|
val token: String = System.getenv("DISCORD_TOKEN") ?: throw RuntimeException("Missing DISCORD_TOKEN in env!")
|
||||||
val jda = JDABuilder().setToken(token).setActivity(Activity.watching("you")).addEventListeners(LogListener).build()
|
val jda = JDABuilder().setToken(token).setActivity(Activity.watching("you")).addEventListeners(LogListener).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class Message(val user: Long, val content: String, val channel: Long, val guild: Long, val message: Long)
|
||||||
|
|
||||||
|
val messages = mutableListOf<Message>()
|
||||||
|
|
||||||
object LogListener : ListenerAdapter() {
|
object LogListener : ListenerAdapter() {
|
||||||
override fun onGuildMessageDelete(event: GuildMessageDeleteEvent) {
|
override fun onGuildMessageReceived(event: GuildMessageReceivedEvent) {
|
||||||
|
if (!event.isWebhookMessage && !event.author.isBot) {
|
||||||
|
val m = Message(
|
||||||
|
event.author.idLong,
|
||||||
|
event.message.contentRaw,
|
||||||
|
event.message.channel.idLong,
|
||||||
|
event.guild.idLong,
|
||||||
|
event.message.idLong
|
||||||
|
)
|
||||||
|
messages += m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onGuildMessageDelete(event: GuildMessageDeleteEvent) {
|
||||||
|
val m = messages.firstOrNull { it.message == event.messageIdLong } ?: return
|
||||||
|
val logs = event.guild.textChannels.find { it.name == "logs" }
|
||||||
|
logs?.sendMessage(
|
||||||
|
EmbedBuilder().setDescription(m.content).setTitle("Message Deleted!")
|
||||||
|
.addField("Channel", event.channel.asMention, true).addField(
|
||||||
|
"User",
|
||||||
|
event.jda.getUserById(m.user)?.asTag ?: "No Idea...",
|
||||||
|
true
|
||||||
|
).setColor(Color.RED)
|
||||||
|
.build()
|
||||||
|
)?.queue {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue