Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ protected final String generateComponentId(String... args) {
*/
@SuppressWarnings({"OverloadedVarargsMethod", "WeakerAccess"})
protected final String generateComponentId(Lifespan lifespan, String... args) {
return componentIdGenerator.generate(new ComponentId(getName(), Arrays.asList(args)),
lifespan);
return componentIdGenerator
.generate(new ComponentId(UserInteractorPrefix.getPrefixedNameFromInstance(this),
Arrays.asList(args)), lifespan);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public BotCore(JDA jda, Database database, Config config) {
componentIdParser = uuid -> componentIdStore.get(UUID.fromString(uuid));
Collection<UserInteractor> interactors = getInteractors();

interactors.forEach(slashCommand -> slashCommand
.acceptComponentIdGenerator(((componentId, lifespan) -> {
UUID uuid = UUID.randomUUID();
componentIdStore.putOrThrow(uuid, componentId, lifespan);
return uuid.toString();
})));
interactors.forEach(
interactor -> interactor.acceptComponentIdGenerator(((componentId, lifespan) -> {
UUID uuid = UUID.randomUUID();
componentIdStore.putOrThrow(uuid, componentId, lifespan);
return uuid.toString();
})));

if (logger.isInfoEnabled()) {
logger.info("Available user interactors: {}", interactors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

final class SlashCommandAdapterTest {
private static final String NAME = "foo";
private static final String PREFIXED_NAME =
UserInteractorPrefix.SLASH_COMMAND.getPrefix() + NAME;
private static final String DESCRIPTION = "Foo command";
private static final CommandVisibility VISIBILITY = CommandVisibility.GUILD;
private static final int UNIQUE_ID_ITERATIONS = 20;
Expand Down Expand Up @@ -71,15 +73,15 @@ void generateComponentId() {
String[] elements = {"foo", "bar", "baz"};
String[] componentIdText = adapter.generateComponentId(elements).split(";");
assertEquals(3, componentIdText.length);
assertEquals(NAME, componentIdText[0]);
assertEquals(PREFIXED_NAME, componentIdText[0]);
assertEquals(Integer.toString(elements.length), componentIdText[1]);
assertEquals(Lifespan.REGULAR.toString(), componentIdText[2]);

// Explicit lifespan
for (Lifespan lifespan : Lifespan.values()) {
componentIdText = adapter.generateComponentId(lifespan, elements).split(";");
assertEquals(3, componentIdText.length);
assertEquals(NAME, componentIdText[0]);
assertEquals(PREFIXED_NAME, componentIdText[0]);
assertEquals(Integer.toString(elements.length), componentIdText[1]);
assertEquals(lifespan.toString(), componentIdText[2]);
}
Expand Down