Commit a3ef2d99 authored by Jose V. Trigueros's avatar Jose V. Trigueros

Update Guild Activity and Name...sometimes

parent 9fd4ceca
Pipeline #142851874 passed with stages
in 13 minutes and 29 seconds
......@@ -10,7 +10,7 @@
</scm>
<properties>
<jda.version>4.1.1_136</jda.version>
<jda.version>4.1.1_143</jda.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
<kotlin.version>1.3.72</kotlin.version>
......@@ -23,12 +23,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.0.rc1</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.rollbar</groupId>
<artifactId>rollbar-log4j2</artifactId>
<version>1.7.0</version>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
......@@ -80,17 +80,17 @@
<dependency>
<groupId>net.jodah</groupId>
<artifactId>failsafe</artifactId>
<version>2.3.4</version>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>org.jetbrains.exposed</groupId>
......@@ -125,7 +125,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.30.1</version>
<version>3.31.1</version>
</dependency>
<dependency>
......
This diff is collapsed.
......@@ -23,6 +23,7 @@ import tech.gdragon.commands.handleCommand
import tech.gdragon.db.asyncTransaction
import tech.gdragon.db.dao.Guild
import tech.gdragon.db.nowUTC
import tech.gdragon.discord.Bot
import tech.gdragon.metrics.Rollbar
class EventListener : ListenerAdapter(), KoinComponent {
......@@ -38,9 +39,9 @@ class EventListener : ListenerAdapter(), KoinComponent {
.findOrCreate(guild.idLong, guild.name, guild.region.name)
.also {
it.active = true
it.lastActiveOn = nowUTC()
}
}
BotUtils.updateActivity(event.guild)
logger.info { "Joined new server '${guild.name}', connected to ${event.jda.guilds.size} guilds." }
}
......@@ -60,22 +61,6 @@ class EventListener : ListenerAdapter(), KoinComponent {
}
}
override fun onGuildUpdateName(event: GuildUpdateNameEvent) {
withLoggingContext("guild" to event.guild.name) {
event.run {
asyncTransaction {
Guild.findById(guild.idLong)
.also {
it?.name = newName
}
}
logger.info {
"Changed name $oldName -> $newName"
}
}
}
}
override fun onGuildUpdateRegion(event: GuildUpdateRegionEvent) {
withLoggingContext("guild" to event.guild.name) {
event.run {
......@@ -103,15 +88,7 @@ class EventListener : ListenerAdapter(), KoinComponent {
}
// Update activity
asyncTransaction {
event.guild.run {
Guild
.findOrCreate(idLong, name, region.name)
.also {
it.lastActiveOn = nowUTC()
}
}
}
BotUtils.updateActivity(event.guild)
BotUtils.autoRecord(event.guild, event.channelJoined)
}
......@@ -133,15 +110,7 @@ class EventListener : ListenerAdapter(), KoinComponent {
logger.debug { "${event.guild.name}#${event.channelJoined.name} - ${user.name} joined voice channel" }
// Update activity
asyncTransaction {
event.guild.run {
Guild
.findOrCreate(idLong, name, region.name)
.also {
it.lastActiveOn = nowUTC()
}
}
}
BotUtils.updateActivity(event.guild)
if (BotUtils.isSelfBot(user).not()) {
BotUtils.autoStop(event.guild, event.channelLeft)
......@@ -181,7 +150,7 @@ class EventListener : ListenerAdapter(), KoinComponent {
try {
handleCommand(event, prefix, rawContent)
// Update activity
asyncTransaction { guild.lastActiveOn = nowUTC() }
BotUtils.updateActivity(event.guild)
} catch (e: InvalidCommand) {
BotUtils.sendMessage(defaultChannel, ":no_entry_sign: _Usage: `${e.usage(prefix)}`_")
logger.warn { "[$rawContent] ${e.reason}" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment