Replace Logger with Lombok's @Slf4j annotation in ContactEndpoint and update log method calls.
This commit is contained in:
parent
81b53cd1f8
commit
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");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user