Compare commits

..

No commits in common. "7863b3f62da87e072e3b671c5d7b9d3a0a62ea79" and "81b53cd1f865ab66db4f22a736b77aa50d58593a" have entirely different histories.

3 changed files with 7 additions and 31 deletions

View File

@ -3,7 +3,6 @@ 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;
@ -15,25 +14,26 @@ 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) {
log.debug("Sending form to Discord: {}", formData);
logger.debug("Sending form to Discord: " + formData);
MessageEmbed messageEmbed = formData.toMessageEmbed();
Guild guild = AltitudeBot.getInstance().getJDA().getGuildById(514920774923059209L);
if (guild == null) {
log.error("Unable to retrieve staff guild");
logger.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) {
log.error("Unable to retrieve contact form channel");
logger.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) {
log.error("Failed to send message to Discord", exception);
logger.error("Failed to send message to Discord", exception);
}
return ResponseEntity.internalServerError().body("Failed to submit form to Discord");
});

View File

@ -1,22 +0,0 @@
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());
}
}

View File

@ -42,15 +42,13 @@ 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, autoThread);
jda.addEventListener(buttonManager, tagAdded, modalManager, commandManager, contextMenuManager, lockedChannel, appealRepost, selectMenuManager);
PollQueries.loadPolls(buttonManager);
new Timer().scheduleAtFixedRate(new PollTimerTask(jda, Logger.altitudeLogs), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(5));
new QueriesEvent().loadActiveEvents();