mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-28 19:35:23 +00:00
[AB-213] fixing not properly creating a channel in case the event is sent
This commit is contained in:
@@ -10,10 +10,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.events.channel.text.TextChannelCreateEvent;
|
import net.dv8tion.jda.api.events.channel.text.TextChannelCreateEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.core.task.TaskExecutor;
|
import org.springframework.core.task.TaskExecutor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.event.TransactionalEventListener;
|
import org.springframework.transaction.event.TransactionalEventListener;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -39,8 +41,16 @@ public class AsyncAChannelCreatedListenerBean extends ListenerAdapter {
|
|||||||
@Qualifier("aChannelCreatedExecutor")
|
@Qualifier("aChannelCreatedExecutor")
|
||||||
private TaskExecutor channelCreatedExecutor;
|
private TaskExecutor channelCreatedExecutor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsyncAChannelCreatedListenerBean self;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChannelCreate(@Nonnull TextChannelCreateEvent event) {
|
public void onTextChannelCreate(@Nonnull TextChannelCreateEvent event) {
|
||||||
|
self.createChannelInDatabase(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void createChannelInDatabase(@NotNull TextChannelCreateEvent event) {
|
||||||
log.info("Creating text channel with ID {}.", event.getChannel().getIdLong());
|
log.info("Creating text channel with ID {}.", event.getChannel().getIdLong());
|
||||||
AServer serverObject = serverManagementService.loadOrCreate(event.getChannel().getGuild().getIdLong());
|
AServer serverObject = serverManagementService.loadOrCreate(event.getChannel().getGuild().getIdLong());
|
||||||
TextChannel createdChannel = event.getChannel();
|
TextChannel createdChannel = event.getChannel();
|
||||||
|
|||||||
Reference in New Issue
Block a user