Merge branch 'feat/updates' into 'master'
bump versions, make loader use non deprecated method See merge request jdejeu/ottobotv2!20
This commit is contained in:
commit
ad792c8ba7
12
build.gradle
12
build.gradle
|
@ -1,11 +1,11 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
|
||||
id 'org.springframework.boot' version '2.2.5.RELEASE'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
|
||||
id 'org.springframework.boot' version '2.3.1.RELEASE'
|
||||
id "io.spring.dependency-management" version "1.0.9.RELEASE"
|
||||
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.70'
|
||||
id 'org.jetbrains.kotlin.plugin.jpa' version '1.3.70'
|
||||
id "org.jetbrains.kotlin.kapt" version "1.3.70"
|
||||
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.72'
|
||||
id 'org.jetbrains.kotlin.plugin.jpa' version '1.3.72'
|
||||
id "org.jetbrains.kotlin.kapt" version "1.3.72"
|
||||
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ dependencies {
|
|||
|
||||
testImplementation "org.junit.jupiter:junit-jupiter:5.4.2"
|
||||
|
||||
implementation 'net.dv8tion:JDA:4.1.1_101'
|
||||
implementation 'net.dv8tion:JDA:4.2.0_179'
|
||||
|
||||
runtimeOnly "com.h2database:h2"
|
||||
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.stereotype.Service
|
|||
class Loader(listeners: List<ListenerAdapter>, store: ConfigStore) {
|
||||
init {
|
||||
val token = System.getenv("DISCORD_TOKEN") ?: throw RuntimeException("'DISCORD_TOKEN' not set!")
|
||||
val builder = DefaultShardManagerBuilder(token)
|
||||
val builder = DefaultShardManagerBuilder.createDefault(token)
|
||||
|
||||
|
||||
builder.addEventListeners(listeners)
|
||||
|
|
|
@ -10,14 +10,12 @@ import nl.voidcorp.discord.command.CommandResult
|
|||
import nl.voidcorp.discord.command.CommandSettings
|
||||
import nl.voidcorp.discord.creator
|
||||
import nl.voidcorp.discord.logger
|
||||
import nl.voidcorp.discord.storage.GuildRepo
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class CommandListener(
|
||||
@Autowired val guildRepo: GuildRepo,
|
||||
@Autowired final val commands: Set<Command>,
|
||||
@Autowired val commands: Set<Command>,
|
||||
@Autowired val commandSettings: CommandSettings
|
||||
) : ListenerAdapter() {
|
||||
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package nl.voidcorp.discord.events
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageUpdateEvent
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||
import nl.voidcorp.discord.jda
|
||||
import nl.voidcorp.discord.storage.GuildRepo
|
||||
import nl.voidcorp.discord.storage.GuildStore
|
||||
import nl.voidcorp.discord.storage.MessageRepo
|
||||
import nl.voidcorp.discord.storage.MessageStore
|
||||
import java.awt.Color
|
||||
import java.time.Clock
|
||||
import java.time.LocalDateTime
|
||||
|
||||
class LogListener(val repo: GuildRepo, val msg: MessageRepo) : ListenerAdapter() {
|
||||
|
||||
private enum class EventType {
|
||||
EDIT,
|
||||
DELET
|
||||
}
|
||||
|
||||
override fun onGuildMessageReceived(event: GuildMessageReceivedEvent) {
|
||||
msg.save(MessageStore(event.messageIdLong, event.message.contentRaw, event.guild.idLong, event.author.idLong))
|
||||
}
|
||||
|
||||
override fun onGuildMessageUpdate(event: GuildMessageUpdateEvent) {
|
||||
val past = msg.findByMsgId(event.messageIdLong) ?: MessageStore(
|
||||
event.messageIdLong,
|
||||
event.message.contentRaw,
|
||||
event.guild.idLong,
|
||||
event.author.idLong
|
||||
)
|
||||
if (event.message.contentRaw != past.text) {
|
||||
past.past.add(past.text)
|
||||
past.text = event.message.contentRaw
|
||||
}
|
||||
msg.save(past)
|
||||
sendMessageModification(past, EventType.EDIT)
|
||||
}
|
||||
|
||||
override fun onGuildMessageDelete(event: GuildMessageDeleteEvent) {
|
||||
val past =
|
||||
msg.findByMsgId(event.messageIdLong) ?: MessageStore(
|
||||
event.messageIdLong,
|
||||
"~~deleted~~",
|
||||
event.guild.idLong,
|
||||
-1
|
||||
)
|
||||
past.deleted = true
|
||||
msg.save(past)
|
||||
sendMessageModification(past, EventType.DELET)
|
||||
}
|
||||
|
||||
private fun sendMessageModification(st: MessageStore, type: EventType) {
|
||||
val store = repo.findByGuildId(st.guildId) ?: GuildStore(st.guildId)
|
||||
if (store.loggingChannel != null) {
|
||||
val embedBuilder = EmbedBuilder().addField("Message", st.text, false)
|
||||
.addField("Past", st.past.joinToString("\n"), true)
|
||||
.addField("Sender", jda.getUserById(st.authorId)?.asTag ?: "someone#-1", true)
|
||||
.setTitle(type.toString()).setTimestamp(LocalDateTime.now(Clock.systemUTC()))
|
||||
.setColor(if (type == EventType.EDIT) Color.GREEN.brighter() else Color.RED.darker())
|
||||
jda.getTextChannelById(store.loggingChannel ?: -1)?.sendMessage(embedBuilder.build())?.queue()
|
||||
}
|
||||
msg.deleteInBatch(msg.findByNowBefore(LocalDateTime.now().minusDays(2)))
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ class OttoListener(val configStore: ConfigStore) : ListenerAdapter() {
|
|||
}
|
||||
|
||||
override fun onReconnect(event: ReconnectedEvent) {
|
||||
val id = event.jda.shardInfo!!.shardId
|
||||
val id = event.jda.shardInfo.shardId
|
||||
val reconn = event.responseNumber
|
||||
val version = configStore.version
|
||||
if(reconn >=10) exitProcess(0)
|
||||
|
|
Loading…
Reference in a new issue