Compare commits
8
Commits
forms
...
7863b3f62d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7863b3f62d | ||
|
|
003c75c391 | ||
|
|
81b53cd1f8 | ||
|
|
34f9559d10 | ||
|
|
f2864ade8a | ||
|
|
cd356121b7 | ||
|
|
1f706b69b8 | ||
|
|
8f6d1137ae |
Vendored
+1
-1
@@ -3,7 +3,7 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Gradle') {
|
stage('Gradle') {
|
||||||
steps {
|
steps {
|
||||||
sh 'bash ./gradlew build'
|
sh 'bash ./gradlew shadowJar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Archive') {
|
stage('Archive') {
|
||||||
|
|||||||
+16
-12
@@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.0"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("org.springframework.boot") version("2.7.8")
|
id("org.springframework.boot") version("3.5.3")
|
||||||
|
id("com.github.ben-manes.versions") version "0.52.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.alttd"
|
group = "com.alttd"
|
||||||
@@ -12,7 +13,7 @@ description = "Altitude Discord Bot."
|
|||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(17))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,23 +60,26 @@ tasks {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// JDA
|
// JDA
|
||||||
implementation("net.dv8tion:JDA:5.0.2") {
|
implementation("net.dv8tion:JDA:5.6.1") {
|
||||||
exclude("opus-java") // exclude audio
|
exclude("opus-java") // exclude audio
|
||||||
}
|
}
|
||||||
// MySQL
|
// MySQL
|
||||||
implementation("mysql:mysql-connector-java:8.0.33")
|
implementation("mysql:mysql-connector-java:8.0.33")
|
||||||
|
|
||||||
// Configurate
|
// Configurate
|
||||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
implementation("org.spongepowered:configurate-yaml:4.2.0")
|
||||||
|
|
||||||
// Excel
|
// Excel
|
||||||
implementation("org.apache.poi:poi:5.2.0")
|
implementation("org.apache.poi:poi:5.4.1")
|
||||||
implementation("org.apache.poi:poi-ooxml:5.2.0")
|
implementation("org.apache.poi:poi-ooxml:5.4.1")
|
||||||
// Other stuff?
|
// Other stuff?
|
||||||
compileOnly("org.projectlombok:lombok:1.18.30")
|
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.24")
|
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||||
implementation("com.alttd:AltitudeLogs:1.0")
|
implementation("com.alttd:AltitudeLogs:1.0")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web:3.2.1")
|
implementation("org.springframework.boot:spring-boot-starter-web:3.5.3")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-validation:3.2.1")
|
implementation("org.springframework.boot:spring-boot-starter-validation:3.5.3")
|
||||||
implementation("com.google.code.gson:gson:2.8.9")
|
implementation("com.google.code.gson:gson:2.13.1")
|
||||||
|
|
||||||
|
testImplementation(platform("org.junit:junit-bom:5.13.1"))
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ import com.alttd.util.Util;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.IMentionable;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||||
@@ -27,10 +26,12 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class CommandStaffJoinDate extends DiscordCommand {
|
public class CommandStaffJoinDate extends DiscordCommand {
|
||||||
|
|
||||||
|
private final CommandData commandData;
|
||||||
|
|
||||||
public CommandStaffJoinDate(JDA jda, CommandManager commandManager) {
|
public CommandStaffJoinDate(JDA jda, CommandManager commandManager) {
|
||||||
CommandData commandData = Commands.slash(getName(), "View join date for staff members, or add them manually")
|
this.commandData = Commands.slash(getName(), "View join date for staff members, or add them manually")
|
||||||
.addOption(OptionType.MENTIONABLE, "staff", "Set the soft lock \"on\" or \"off\"", false, true)
|
.addOption(OptionType.MENTIONABLE, "staff", "The staff member to set/check the join date for", false, false)
|
||||||
.addOption(OptionType.NUMBER, "join-time", "Channel to change soft lock state for", false, true)
|
.addOption(OptionType.INTEGER, "join-time", "The join date to set", false, false)
|
||||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
|
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
|
||||||
.setGuildOnly(true);
|
.setGuildOnly(true);
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ public class CommandStaffJoinDate extends DiscordCommand {
|
|||||||
interactionHook.editOriginalEmbeds(getFullStaffEmbed()).queue();
|
interactionHook.editOriginalEmbeds(getFullStaffEmbed()).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Member member = staff.getAsMember();
|
Member member = staff.getAsMember();
|
||||||
if (member == null) {
|
if (member == null) {
|
||||||
interactionHook.editOriginalEmbeds(Util.genericErrorEmbed("Invalid member", String.format("%s is not a valid member", staff.getAsMentionable().getAsMention()))).queue();
|
interactionHook.editOriginalEmbeds(Util.genericErrorEmbed("Invalid member", String.format("%s is not a valid member", staff.getAsMentionable().getAsMention()))).queue();
|
||||||
@@ -104,7 +106,7 @@ public class CommandStaffJoinDate extends DiscordCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suggest(CommandAutoCompleteInteractionEvent event) {
|
public void suggest(CommandAutoCompleteInteractionEvent event) {
|
||||||
|
event.replyChoiceStrings(List.of()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,6 +116,6 @@ public class CommandStaffJoinDate extends DiscordCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getCommandData() {
|
public CommandData getCommandData() {
|
||||||
return null;
|
return commandData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.alttd.communication.contact;
|
|||||||
import com.alttd.AltitudeBot;
|
import com.alttd.AltitudeBot;
|
||||||
import com.alttd.communication.formData.ContactFormData;
|
import com.alttd.communication.formData.ContactFormData;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
@@ -14,26 +15,25 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/contact")
|
@RequestMapping("/api/contact")
|
||||||
public class ContactEndpoint {
|
public class ContactEndpoint {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContactEndpoint.class);
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/submitContactForm")
|
@PostMapping("/submitContactForm")
|
||||||
public CompletableFuture<ResponseEntity<String>> sendFormToDiscord(@Valid @RequestBody ContactFormData formData) {
|
public CompletableFuture<ResponseEntity<String>> sendFormToDiscord(@Valid @RequestBody ContactFormData formData) {
|
||||||
logger.debug("Sending form to Discord: " + formData);
|
log.debug("Sending form to Discord: {}", formData);
|
||||||
MessageEmbed messageEmbed = formData.toMessageEmbed();
|
MessageEmbed messageEmbed = formData.toMessageEmbed();
|
||||||
Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L);
|
Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L);
|
||||||
if (guild == null) {
|
if (guild == null) {
|
||||||
logger.error("Unable to retrieve staff guild");
|
log.error("Unable to retrieve staff guild");
|
||||||
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
|
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
|
||||||
}
|
}
|
||||||
TextChannel channel = guild.getChannelById(TextChannel.class, 514922567883292673L);
|
TextChannel channel = guild.getChannelById(TextChannel.class, 514922567883292673L);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
logger.error("Unable to retrieve contact form channel");
|
log.error("Unable to retrieve contact form channel");
|
||||||
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
|
return CompletableFuture.completedFuture(ResponseEntity.internalServerError().body("Failed to submit form to Discord"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class ContactEndpoint {
|
|||||||
if (complete != null)
|
if (complete != null)
|
||||||
return ResponseEntity.ok("");
|
return ResponseEntity.ok("");
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
logger.error("Failed to send message to Discord", exception);
|
log.error("Failed to send message to Discord", exception);
|
||||||
}
|
}
|
||||||
return ResponseEntity.internalServerError().body("Failed to submit form to Discord");
|
return ResponseEntity.internalServerError().body("Failed to submit form to Discord");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class QueriesStaffJoinDate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setJoinDate(long userId, Instant date) {
|
public static void setJoinDate(long userId, Instant date) {
|
||||||
String sql = "INSERT INTO staff_join_date (user_id, date) VALUES (?, ?)";
|
String sql = "INSERT INTO staff_join_date (user_id, date) VALUES (?, ?) ON DUPLICATE KEY UPDATE date = VALUES(date)";
|
||||||
|
|
||||||
try (PreparedStatement preparedStatement = Database.getDatabase().getConnection().prepareStatement(sql)) {
|
try (PreparedStatement preparedStatement = Database.getDatabase().getConnection().prepareStatement(sql)) {
|
||||||
preparedStatement.setLong(1, userId);
|
preparedStatement.setLong(1, userId);
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.alttd.listeners;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import org.jetbrains.annotations.NonNls;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AutoThread extends ListenerAdapter {
|
||||||
|
|
||||||
|
List<Long> channels = List.of(1172922338023591956L);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessageReceived(@NonNls MessageReceivedEvent event) {
|
||||||
|
if (!channels.contains(event.getChannel().getIdLong())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.getMessage().createThreadChannel("Auto Thread").queue(threadChannel ->
|
||||||
|
threadChannel.sendMessage("Thread for community post by: " + event.getAuthor().getAsMention())
|
||||||
|
.queue());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,13 +42,15 @@ public class JDAListener extends ListenerAdapter {
|
|||||||
Logger.altitudeLogs.info("JDA ready to register commands.");
|
Logger.altitudeLogs.info("JDA ready to register commands.");
|
||||||
LockedChannel lockedChannel = new LockedChannel();
|
LockedChannel lockedChannel = new LockedChannel();
|
||||||
ButtonManager buttonManager = new ButtonManager();
|
ButtonManager buttonManager = new ButtonManager();
|
||||||
|
AutoThread autoThread = new AutoThread();
|
||||||
TagAdded tagAdded = new TagAdded();
|
TagAdded tagAdded = new TagAdded();
|
||||||
AppealRepost appealRepost = new AppealRepost(buttonManager);
|
AppealRepost appealRepost = new AppealRepost(buttonManager);
|
||||||
ModalManager modalManager = new ModalManager(buttonManager);
|
ModalManager modalManager = new ModalManager(buttonManager);
|
||||||
ContextMenuManager contextMenuManager = new ContextMenuManager(modalManager);
|
ContextMenuManager contextMenuManager = new ContextMenuManager(modalManager);
|
||||||
SelectMenuManager selectMenuManager = new SelectMenuManager();
|
SelectMenuManager selectMenuManager = new SelectMenuManager();
|
||||||
CommandManager commandManager = new CommandManager(jda, modalManager, contextMenuManager, lockedChannel, selectMenuManager, buttonManager);
|
CommandManager commandManager = new CommandManager(jda, modalManager, contextMenuManager, lockedChannel, selectMenuManager, buttonManager);
|
||||||
jda.addEventListener(buttonManager, tagAdded, modalManager, commandManager, contextMenuManager, lockedChannel, appealRepost, selectMenuManager);
|
jda.addEventListener(buttonManager, tagAdded, modalManager, commandManager, contextMenuManager, lockedChannel,
|
||||||
|
appealRepost, selectMenuManager, autoThread);
|
||||||
PollQueries.loadPolls(buttonManager);
|
PollQueries.loadPolls(buttonManager);
|
||||||
new Timer().scheduleAtFixedRate(new PollTimerTask(jda, Logger.altitudeLogs), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(5));
|
new Timer().scheduleAtFixedRate(new PollTimerTask(jda, Logger.altitudeLogs), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(5));
|
||||||
new QueriesEvent().loadActiveEvents();
|
new QueriesEvent().loadActiveEvents();
|
||||||
|
|||||||
Reference in New Issue
Block a user