Compare commits
2 Commits
81b53cd1f8
...
7863b3f62d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7863b3f62d | ||
|
|
003c75c391 |
|
|
@ -3,6 +3,7 @@ package com.alttd.communication.contact;
|
|||
import com.alttd.AltitudeBot;
|
||||
import com.alttd.communication.formData.ContactFormData;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
|
|
@ -14,26 +15,25 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@RequestMapping("/api/contact")
|
||||
public class ContactEndpoint {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContactEndpoint.class);
|
||||
|
||||
|
||||
@PostMapping("/submitContactForm")
|
||||
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();
|
||||
Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L);
|
||||
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"));
|
||||
}
|
||||
TextChannel channel = guild.getChannelById(TextChannel.class, 514922567883292673L);
|
||||
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"));
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ public class ContactEndpoint {
|
|||
if (complete != null)
|
||||
return ResponseEntity.ok("");
|
||||
} 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");
|
||||
});
|
||||
|
|
|
|||
22
src/main/java/com/alttd/listeners/AutoThread.java
Normal file
22
src/main/java/com/alttd/listeners/AutoThread.java
Normal file
|
|
@ -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.");
|
||||
LockedChannel lockedChannel = new LockedChannel();
|
||||
ButtonManager buttonManager = new ButtonManager();
|
||||
AutoThread autoThread = new AutoThread();
|
||||
TagAdded tagAdded = new TagAdded();
|
||||
AppealRepost appealRepost = new AppealRepost(buttonManager);
|
||||
ModalManager modalManager = new ModalManager(buttonManager);
|
||||
ContextMenuManager contextMenuManager = new ContextMenuManager(modalManager);
|
||||
SelectMenuManager selectMenuManager = new SelectMenuManager();
|
||||
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);
|
||||
new Timer().scheduleAtFixedRate(new PollTimerTask(jda, Logger.altitudeLogs), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(5));
|
||||
new QueriesEvent().loadActiveEvents();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user