mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-13 19:41:38 +00:00
[AB-166] refactored conditions to not use exceptions for their regular case, split up feature mode exception into condition and exception, if the conditions need to be checked somewhere else, a separate exception is required, fixed command not being disabled properly in channels
This commit is contained in:
@@ -8,7 +8,6 @@ import dev.sheldan.abstracto.core.command.exception.IncorrectParameterException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.exception.IncorrectFeatureModeException;
|
||||
import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -52,12 +50,9 @@ public class TrackEmote extends AbstractConditionableCommand {
|
||||
} else if(emoteToTrack.getEmote() != null) {
|
||||
boolean external = !emoteService.emoteIsFromGuild(emoteToTrack.getEmote(), commandContext.getGuild());
|
||||
if(external) {
|
||||
boolean trackExternalEmotes = featureModeService.featureModeActive(StatisticFeatures.EMOTE_TRACKING, serverId, EmoteTrackingMode.EXTERNAL_EMOTES);
|
||||
if(!trackExternalEmotes) {
|
||||
throw new IncorrectFeatureModeException(StatisticFeatures.EMOTE_TRACKING, Arrays.asList(EmoteTrackingMode.EXTERNAL_EMOTES));
|
||||
}
|
||||
featureModeService.validateActiveFeatureMode(serverId, StatisticFeatures.EMOTE_TRACKING, EmoteTrackingMode.EXTERNAL_EMOTES);
|
||||
}
|
||||
trackedEmoteService.createFakeTrackedEmote(emoteToTrack.getEmote(), commandContext.getGuild());
|
||||
trackedEmoteService.createFakeTrackedEmote(emoteToTrack.getEmote(), commandContext.getGuild(), external);
|
||||
} else {
|
||||
throw new IncorrectParameterException(this, getConfiguration().getParameters().get(0).getName());
|
||||
}
|
||||
|
||||
@@ -173,6 +173,11 @@ public class TrackedEmoteServiceBean implements TrackedEmoteService {
|
||||
@Override
|
||||
public TrackedEmote createFakeTrackedEmote(Emote emote, Guild guild) {
|
||||
boolean external = !emoteService.emoteIsFromGuild(emote, guild);
|
||||
return createFakeTrackedEmote(emote, guild, external);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackedEmote createFakeTrackedEmote(Emote emote, Guild guild, boolean external) {
|
||||
return trackedEmoteManagementService.createTrackedEmote(emote, guild, external);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user