mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-26 22:02:40 +00:00
[AB-205] making exception message for command not found configurable
making feature config classes more unified in the naming
This commit is contained in:
@@ -12,7 +12,7 @@ import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeature;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureDefinition;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentModuleDefinition;
|
||||
import dev.sheldan.abstracto.entertainment.model.RollResponseModel;
|
||||
@@ -42,7 +42,7 @@ public class Roll extends AbstractConditionableCommand {
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Integer high = configService.getLongValueOrConfigDefault(EntertainmentFeature.ROLL_DEFAULT_HIGH_KEY, commandContext.getGuild().getIdLong()).intValue();
|
||||
Integer high = configService.getLongValueOrConfigDefault(EntertainmentFeatureConfig.ROLL_DEFAULT_HIGH_KEY, commandContext.getGuild().getIdLong()).intValue();
|
||||
Integer low = 1;
|
||||
if(parameters.size() > 1) {
|
||||
low = (Integer) parameters.get(1);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.entertainment.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeature;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -45,7 +45,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
||||
|
||||
@Override
|
||||
public boolean executeRoulette(Member memberExecuting) {
|
||||
Long possibilities = configService.getLongValueOrConfigDefault(EntertainmentFeature.ROULETTE_BULLETS_CONFIG_KEY, memberExecuting.getGuild().getIdLong());
|
||||
Long possibilities = configService.getLongValueOrConfigDefault(EntertainmentFeatureConfig.ROULETTE_BULLETS_CONFIG_KEY, memberExecuting.getGuild().getIdLong());
|
||||
// 1/possibilities of chance, we don't have a state, each time its reset
|
||||
return secureRandom.nextInt(possibilities.intValue()) == 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static dev.sheldan.abstracto.entertainment.config.EntertainmentFeature.ROLL_DEFAULT_HIGH_KEY;
|
||||
import static dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig.ROLL_DEFAULT_HIGH_KEY;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.sheldan.abstracto.entertainment.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeature;
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import org.junit.Assert;
|
||||
@@ -79,7 +79,7 @@ public class EntertainmentServiceBeanTest {
|
||||
when(guild.getIdLong()).thenReturn(serverId);
|
||||
when(member.getGuild()).thenReturn(guild);
|
||||
Long sides = 6L;
|
||||
when(configService.getLongValue(EntertainmentFeature.ROULETTE_BULLETS_CONFIG_KEY, serverId)).thenReturn(sides);
|
||||
when(configService.getLongValue(EntertainmentFeatureConfig.ROULETTE_BULLETS_CONFIG_KEY, serverId)).thenReturn(sides);
|
||||
when(secureRandom.nextInt(sides.intValue())).thenReturn(randomValue);
|
||||
boolean shot = testUnit.executeRoulette(member);
|
||||
Assert.assertEquals(randomValue == 0, shot);
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class EntertainmentFeature implements FeatureConfig {
|
||||
public class EntertainmentFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String ROULETTE_BULLETS_CONFIG_KEY = "rouletteBullets";
|
||||
public static final String ROLL_DEFAULT_HIGH_KEY = "rollDefaultHigh";
|
||||
Reference in New Issue
Block a user