mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-24 13:44:33 +00:00
added configurable warning and success reactions
changed that channels dont actually get deleted, but rather with a deleted flag, so the foreign keys are valid added more optionals to server/channel/message/member retrieval added throwing exceptions instead of just returning null fixed filtering of deleted channels while the bot was offline fixed channel listener added message deleted listener structure moved quartz properties to general application properties, because they were not found in the separate one added try catch to reminderJob, so that the job is not in an invalid state we now completely remove the starboard post, in case it falls under the threshold added code to 'ignore' a staroard post form further stars, in case the post in the starboard gets deleted now actually setting the reminded flag on a reminder added handnling in case the channel to remind in does not exist anymore
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
public class NotFoundException extends RuntimeException {
|
||||
public NotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.CachedMessage;
|
||||
|
||||
public interface MessageDeletedListener {
|
||||
void execute(CachedMessage messageBefore);
|
||||
}
|
||||
@@ -6,4 +6,6 @@ import dev.sheldan.abstracto.core.models.AChannelType;
|
||||
public interface ChannelManagementService {
|
||||
AChannel loadChannel(Long id);
|
||||
AChannel createChannel(Long id, AChannelType type);
|
||||
void markAsDeleted(Long id);
|
||||
void removeChannel(Long id);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
public interface ServerManagementService {
|
||||
AServer createServer(Long id);
|
||||
AServer loadServer(Long id);
|
||||
AServer loadOrCreate(Long id);
|
||||
void addChannelToServer(AServer server, AChannel channel);
|
||||
AUserInAServer addUserToServer(AServer server, AUser user);
|
||||
AUserInAServer addUserToServer(Long serverId, Long userId);
|
||||
|
||||
@@ -34,6 +34,11 @@ public class AChannel implements SnowFlake {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AChannelType type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private Boolean deleted;
|
||||
|
||||
public static AChannelType getAChannelType(ChannelType type) {
|
||||
switch (type) {
|
||||
case TEXT: return AChannelType.TEXT;
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public interface Bot {
|
||||
@@ -18,8 +19,9 @@ public interface Bot {
|
||||
ServerChannelUser getServerChannelUser(Long serverId, Long channelId, Long userId);
|
||||
Member getMemberInServer(Long serverId, Long memberId);
|
||||
void deleteMessage(Long serverId, Long channelId, Long messageId);
|
||||
Emote getEmote(Long serverId, AEmote emote);
|
||||
TextChannel getTextChannelFromServer(Long serverId, Long textChannelId);
|
||||
Guild getGuildById(Long serverId);
|
||||
Optional<Emote> getEmote(Long serverId, AEmote emote);
|
||||
Optional<TextChannel> getTextChannelFromServer(Guild serverId, Long textChannelId);
|
||||
Optional<TextChannel> getTextChannelFromServer(Long serverId, Long textChannelId);
|
||||
Optional<Guild> getGuildById(Long serverId);
|
||||
void shutdown();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ContextUtils {
|
||||
.guild(serverChannelUser.getGuild())
|
||||
.textChannel(serverChannelUser.getTextChannel())
|
||||
.channel(channelManagementService.loadChannel(message.getChannelId()))
|
||||
.server(serverManagementService.loadServer(message.getServerId()))
|
||||
.server(serverManagementService.loadOrCreate(message.getServerId()))
|
||||
.aUserInAServer(aUserInAServer)
|
||||
.user(aUserInAServer.getUserReference())
|
||||
.build();
|
||||
|
||||
@@ -10,10 +10,9 @@ import java.util.Optional;
|
||||
|
||||
public class EmoteUtils {
|
||||
|
||||
public static boolean isReactionEmoteAEmote(MessageReaction.ReactionEmote reaction, AEmote emote, Optional<Emote> emoteInGuildOptional) {
|
||||
public static boolean isReactionEmoteAEmote(MessageReaction.ReactionEmote reaction, AEmote emote, Emote emoteInGuild) {
|
||||
if(reaction.isEmote() && emote.getCustom()) {
|
||||
if(emoteInGuildOptional.isPresent()) {
|
||||
Emote emoteInGuild = emoteInGuildOptional.get();
|
||||
if(emoteInGuild != null) {
|
||||
return emoteInGuild.equals(reaction.getEmote());
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user