Skip to content

Commit a857eda

Browse files
committed
Merge branch 'main' into help-ack-timestamps
2 parents 6f0acaa + c0e3a44 commit a857eda

File tree

64 files changed

+608
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+608
-293
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ At startup, the bot will initially start by loading just the global settings, an
2828

2929
We're using [DIH4JDA](https://github.com/DynxstyGIT/DIH4JDA) as our Command/Interaction framework, which makes it quite easy to add new commands.
3030

31-
[PingCommand.java](https://github.com/Java-Discord/JavaBot/blob/main/src/main/java/net/javadiscord/javabot/systems/commands/PingCommand.java)
31+
[PingCommand.java](https://github.com/Java-Discord/JavaBot/blob/main/src/main/java/net/javadiscord/javabot/systems/user_commands/PingCommand.java)
3232
```java
3333
/**
3434
* <h3>This class represents the /ping command.</h3>

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ dependencies {
3030
compileOnly("org.jetbrains:annotations:23.0.0")
3131

3232
// DIH4JDA (Command Framework) & JDA
33-
implementation("xyz.dynxsty:dih4jda:1.6.2")
34-
implementation("net.dv8tion:JDA:5.0.0-beta.2") {
33+
implementation("com.github.DynxstyGIT:DIH4JDA:120a15ad2e")
34+
implementation("net.dv8tion:JDA:5.0.0-beta.12") {
3535
exclude(module = "opus-java")
3636
}
3737

src/main/java/net/javadiscord/javabot/Bot.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import java.util.Map;
88
import java.util.TimeZone;
99

10-
import javax.annotation.PostConstruct;
11-
1210
import org.jetbrains.annotations.NotNull;
1311
import org.springframework.boot.SpringApplication;
1412
import org.springframework.boot.autoconfigure.SpringBootApplication;
13+
import org.springframework.boot.context.event.ApplicationReadyEvent;
1514
import org.springframework.context.ApplicationContext;
15+
import org.springframework.context.ApplicationListener;
1616
import org.springframework.context.annotation.ComponentScan;
1717
import org.springframework.context.annotation.FilterType;
1818
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -46,7 +46,7 @@
4646
)
4747
@EnableScheduling
4848
@RequiredArgsConstructor
49-
public class Bot {
49+
public class Bot implements ApplicationListener<ApplicationReadyEvent> {
5050

5151
private final DIH4JDA dih4jda;
5252
private final BotConfig config;
@@ -64,12 +64,12 @@ private void addEventListeners(final List<ListenerAdapter> listeners) {
6464
}
6565
dih4jda.getJDA().addEventListener(dih4jda);
6666
}
67-
67+
6868
/**
6969
* Initializes Sentry, interactions and listeners.
7070
*/
71-
@PostConstruct
72-
public void init() {
71+
@Override
72+
public void onApplicationEvent(ApplicationReadyEvent event) {
7373
Sentry.init(options -> {
7474
options.setDsn(config.getSystems().getSentryDsn());
7575
options.setTracesSampleRate(1.0);

src/main/java/net/javadiscord/javabot/SpringConfig.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import xyz.dynxsty.dih4jda.DIH4JDA;
1616
import xyz.dynxsty.dih4jda.DIH4JDABuilder;
17-
import xyz.dynxsty.dih4jda.DIH4JDALogger;
1817
import xyz.dynxsty.dih4jda.exceptions.DIH4JDAException;
1918
import xyz.dynxsty.dih4jda.interactions.commands.application.RegistrationType;
2019

@@ -39,27 +38,27 @@
3938
@RequiredArgsConstructor
4039
public class SpringConfig {
4140
@Bean
42-
public PresenceUpdater standardActivityPresenceUpdater() {
41+
PresenceUpdater standardActivityPresenceUpdater() {
4342
return PresenceUpdater.standardActivities();
4443
}
4544

4645
@Bean
47-
public DataSource getDataSource(BotConfig config) {
46+
DataSource getDataSource(BotConfig config) {
4847
return DbHelper.initDataSource(config);
4948
}
5049

5150
@Bean
52-
public ScheduledExecutorService asyncPool(BotConfig config) {
51+
ScheduledExecutorService asyncPool(BotConfig config) {
5352
return Executors.newScheduledThreadPool(config.getSystems().getAsyncPoolSize());
5453
}
5554

5655
@Bean
57-
public BotConfig config() {
56+
BotConfig config() {
5857
return new BotConfig(Path.of("config"));
5958
}
6059

6160
@Bean
62-
public SystemsConfig systemsConfig(BotConfig botConfig) {
61+
SystemsConfig systemsConfig(BotConfig botConfig) {
6362
return botConfig.getSystems();
6463
}
6564

@@ -71,7 +70,7 @@ public SystemsConfig systemsConfig(BotConfig botConfig) {
7170
* @throws LoginException if the token is invalid
7271
*/
7372
@Bean
74-
public JDA jda(BotConfig botConfig, ApplicationContext ctx) throws LoginException {
73+
JDA jda(BotConfig botConfig, ApplicationContext ctx) throws LoginException {
7574
Collection<Object> listeners = ctx.getBeansWithAnnotation(PreRegisteredListener.class).values();
7675
return JDABuilder.createDefault(botConfig.getSystems().getJdaBotToken())
7776
.setStatus(OnlineStatus.DO_NOT_DISTURB)
@@ -90,16 +89,17 @@ public JDA jda(BotConfig botConfig, ApplicationContext ctx) throws LoginExceptio
9089
* @throws DIH4JDAException if an error occurs while initializing {@link DIH4JDA}
9190
*/
9291
@Bean
93-
public DIH4JDA initializeDIH4JDA(JDA jda) throws DIH4JDAException {
92+
DIH4JDA initializeDIH4JDA(JDA jda) throws DIH4JDAException {
9493
DIH4JDA.setDefaultRegistrationType(RegistrationType.GLOBAL);
9594
return DIH4JDABuilder.setJDA(jda)
96-
.disableLogging(DIH4JDALogger.Type.SMART_QUEUE_IGNORED)
95+
.setGlobalSmartQueue(false)
96+
.setGuildSmartQueue(false)
9797
.disableAutomaticCommandRegistration()
9898
.build();
9999
}
100100

101101
@Bean
102-
public BotConfig botConfig() {
102+
BotConfig botConfig() {
103103
return new BotConfig(Path.of("config"));
104104
}
105105
}

src/main/java/net/javadiscord/javabot/api/TomcatConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public TomcatConfig(@Value("${tomcat.ajp.port}") int ajpPort, @Value("${tomcat.a
4040
* @return The {@link TomcatServletWebServerFactory}.
4141
*/
4242
@Bean
43-
public TomcatServletWebServerFactory servletContainer() {
43+
TomcatServletWebServerFactory servletContainer() {
4444
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
4545
if (tomcatAjpEnabled) {
4646
Connector ajpConnector = new Connector("org.apache.coyote.ajp.AjpNioProtocol");

src/main/java/net/javadiscord/javabot/api/routes/metrics/MetricsController.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package net.javadiscord.javabot.api.routes.metrics;
22

33
import com.github.benmanes.caffeine.cache.Caffeine;
4-
import lombok.extern.slf4j.Slf4j;
54
import net.dv8tion.jda.api.JDA;
65
import net.dv8tion.jda.api.entities.Guild;
76
import net.javadiscord.javabot.api.exception.InvalidEntityIdException;
87
import net.javadiscord.javabot.api.routes.CaffeineCache;
98
import net.javadiscord.javabot.api.routes.metrics.model.MetricsData;
109
import net.javadiscord.javabot.data.config.BotConfig;
1110
import net.javadiscord.javabot.data.config.guild.MetricsConfig;
12-
import org.springframework.beans.factory.annotation.Autowired;
1311
import org.springframework.http.HttpStatus;
1412
import org.springframework.http.ResponseEntity;
1513
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,7 +19,6 @@
2119
/**
2220
* Handles all GET-Requests on the guilds/{guild_id}/metrics/ route.
2321
*/
24-
@Slf4j
2522
@RestController
2623
public class MetricsController extends CaffeineCache<Long, MetricsData> {
2724
private final JDA jda;
@@ -33,7 +30,6 @@ public class MetricsController extends CaffeineCache<Long, MetricsData> {
3330
* @param jda The {@link Autowired} {@link JDA} instance to use.
3431
* @param botConfig The main configuration of the bot
3532
*/
36-
@Autowired
3733
public MetricsController(final JDA jda, BotConfig botConfig) {
3834
super(Caffeine.newBuilder()
3935
.expireAfterWrite(15, TimeUnit.MINUTES)

src/main/java/net/javadiscord/javabot/data/config/guild/HelpConfig.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ public class HelpConfig extends GuildConfigItem {
4949
You can disable notifications like this using the `/preferences` command.
5050
[Post link](%s)
5151
""";
52-
53-
52+
53+
/**
54+
* The message that is sent in a post to tell users that they
55+
* should use discord's code-formatting, provided the bot detects unformatted code.
56+
* Issued by {@link net.javadiscord.javabot.systems.help.AutoCodeFormatter}
57+
*/
58+
private String formatHintMessage = "> Please format your code to make it more readable. \n> For java, it should look like this: \n```\u200B`\u200B`\u200B`\u200Bjava\npublic void foo() {\n \n}\n\u200B`\u200B`\u200B`\u200B```";
59+
5460
/**
5561
* The message that's sent when a user unreserved a channel where other users
5662
* participated in.
@@ -93,6 +99,12 @@ public class HelpConfig extends GuildConfigItem {
9399
*/
94100
private int minimumMessageLength = 10;
95101

102+
/**
103+
* The message-embed's footnote of an unformatted-code-replacement.
104+
* Issued by {@link net.javadiscord.javabot.systems.help.AutoCodeFormatter}
105+
*/
106+
private String autoFormatInfoMessage = "This message has been formatted automatically. You can disable this using ``/preferences``.";
107+
96108
/**
97109
* The amount of experience points one gets for being thanked by the help channel owner.
98110
*/

src/main/java/net/javadiscord/javabot/data/h2db/DbHelper.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.sql.Statement;
2323
import java.util.Arrays;
2424
import java.util.List;
25-
import java.util.concurrent.ExecutorService;
2625
import java.util.regex.Matcher;
2726
import java.util.regex.Pattern;
2827
import java.util.stream.Collectors;
@@ -38,8 +37,6 @@
3837
public class DbHelper {
3938
@Getter
4039
private final DataSource dataSource;
41-
private final ExecutorService asyncPool;
42-
private final BotConfig botConfig;
4340

4441
/**
4542
* Initializes the data source that'll be used throughout the bot to access

src/main/java/net/javadiscord/javabot/data/h2db/commands/MessageCacheInfoSubcommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.javadiscord.javabot.data.h2db.commands;
22

3+
import net.javadiscord.javabot.util.UserUtils;
34
import xyz.dynxsty.dih4jda.interactions.commands.application.SlashCommand;
45
import net.dv8tion.jda.api.EmbedBuilder;
56
import net.dv8tion.jda.api.Permission;
@@ -45,7 +46,7 @@ private MessageEmbed buildInfoEmbed(GuildConfig config, User author) {
4546
long messages = dbActions.count("SELECT count(*) FROM message_cache");
4647
int maxMessages = config.getMessageCacheConfig().getMaxCachedMessages();
4748
return new EmbedBuilder()
48-
.setAuthor(author.getAsTag(), null, author.getEffectiveAvatarUrl())
49+
.setAuthor(UserUtils.getUserTag(author), null, author.getEffectiveAvatarUrl())
4950
.setTitle("Message Cache Info")
5051
.setColor(Responses.Type.DEFAULT.getColor())
5152
.addField("Table Size", dbActions.getLogicalSize("message_cache") + " bytes", false)

src/main/java/net/javadiscord/javabot/data/h2db/commands/QuickMigrateSubcommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ CREATE TABLE my_table (
118118
.setRequired(true)
119119
.build();
120120
return Modal.create("quick-migrate", "Quick Migrate")
121-
.addActionRows(ActionRow.of(sqlInput), ActionRow.of(confirmInput))
121+
.addComponents(ActionRow.of(sqlInput), ActionRow.of(confirmInput))
122122
.build();
123123
}
124124
}

0 commit comments

Comments
 (0)