Skip to content

Commit

Permalink
fix button message styles
Browse files Browse the repository at this point in the history
  • Loading branch information
twonirwana committed Oct 18, 2023
1 parent bbf407a commit e7bf566
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ protected void updateCurrentMessageStateData(UUID configUUID, long guildId, long
protected @NonNull Optional<EmbedOrMessageDefinition> createNewButtonMessageWithState(UUID configUUID, CustomParameterConfig config, State<CustomParameterStateData> state, long guildId, long channelId) {
if (!hasMissingParameter(state)) {
return Optional.of(EmbedOrMessageDefinition.builder()
.type(EmbedOrMessageDefinition.Type.MESSAGE)
.descriptionOrContent(formatMessageContent(config, state, null))
.componentRowDefinitions(getButtonLayoutWithOptionalState(configUUID, config, null))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ private boolean rollFinished(State<HoldRerollStateData> state, HoldRerollConfig
|| FINISH_BUTTON_ID.equals(state.getButtonValue())
|| rollFinished(state, config)) {
return Optional.of(EmbedOrMessageDefinition.builder()
.type(EmbedOrMessageDefinition.Type.MESSAGE)
.descriptionOrContent(String.format("Click on the buttons to roll dice. Reroll set: %s, Success Set: %s and Failure Set: %s",
config.getRerollSet(), config.getSuccessSet(), config.getFailureSet()))
.componentRowDefinitions(getButtonLayoutWithState(configUUID, state, config))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ protected Optional<List<ComponentRowDefinition>> getCurrentMessageComponentChang
protected @NonNull Optional<EmbedOrMessageDefinition> createNewButtonMessageWithState(UUID configUUID, PoolTargetConfig config, State<PoolTargetStateData> state, long guildId, long channelId) {
if (Optional.ofNullable(state.getData()).map(PoolTargetStateData::getDicePool).orElse(null) != null && state.getData().getTargetNumber() != null && state.getData().getDoReroll() != null) {
return Optional.of(EmbedOrMessageDefinition.builder()
.type(EmbedOrMessageDefinition.Type.MESSAGE)
.descriptionOrContent(String.format("Click on the buttons to roll dice%s", getConfigDescription(config)))
.componentRowDefinitions(getButtonLayoutWithState(configUUID, state, config))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public Optional<MessageConfigDTO> createMessageConfig(@NonNull UUID configUUID,
.orElse(false)) {
return Optional.of(EmbedOrMessageDefinition.builder()
.descriptionOrContent(EMPTY_MESSAGE)
.type(EmbedOrMessageDefinition.Type.MESSAGE)
.componentRowDefinitions(createButtonLayout(customUuid, config, true))
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private int limit(int input) {
}
return Optional.of(EmbedOrMessageDefinition.builder()
.descriptionOrContent(EMPTY_MESSAGE)
.type(EmbedOrMessageDefinition.Type.MESSAGE)
.componentRowDefinitions(createButtonLayout(configUUID))
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public Requester getRequester() {
}

@Override
public Mono<Void> createResultMessageWithReference(EmbedOrMessageDefinition answer) {
public Mono<Long> createResultMessageWithReference(EmbedOrMessageDefinition answer) {
actions.add(String.format("createResultMessageWithReference: %s", answer));
return Mono.just("").then();
return Mono.just(1L);
}

@Override
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void handleComponentInteractEvent() {
.build();
when(slashEventAdaptor.getOption(any())).thenReturn(Optional.of(interactionOption));
when(slashEventAdaptor.getChannelId()).thenReturn(1L);
when(slashEventAdaptor.createResultMessageWithReference(any())).thenReturn(Mono.just(mock(Void.class)));
when(slashEventAdaptor.createResultMessageWithReference(any())).thenReturn(Mono.just(0L));
when(slashEventAdaptor.deleteMessageById(anyLong())).thenReturn(Mono.empty());
when(slashEventAdaptor.acknowledgeAndRemoveSlash()).thenReturn(Mono.just(mock(Void.class)));
when(slashEventAdaptor.getCommandString()).thenReturn("/r expression:1d6");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void handleComponentInteractEvent() {
.build();
when(slashEventAdaptor.getOption(any())).thenReturn(Optional.of(interactionOption));
when(slashEventAdaptor.getChannelId()).thenReturn(1L);
when(slashEventAdaptor.createResultMessageWithReference(any())).thenReturn(Mono.just(mock(Void.class)));
when(slashEventAdaptor.createResultMessageWithReference(any())).thenReturn(Mono.just(0L));
when(slashEventAdaptor.deleteMessageById(anyLong())).thenReturn(Mono.empty());
when(slashEventAdaptor.reply(any(), anyBoolean())).thenReturn(Mono.just(mock(Void.class)));
when(slashEventAdaptor.getCommandString()).thenReturn("/validation expression:1d6");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void roll_full() {
"editMessage: message:processing ..., buttonValues=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",
"createResultMessageWithReference: EmbedOrMessageDefinition(title=9d10 ≥6 ⇒ 3, descriptionOrContent=[**1**,**1**,**1**,3,3,5,5,**6**,**6**,**9**,**10**,**10**,**10**], fields=[], componentRowDefinitions=[], hasImage=false, type=EMBED), targetChannelId: null",
"deleteMessageById: 0",
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=EMBED)"
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)"
);
}

Expand Down Expand Up @@ -81,7 +81,7 @@ void roll_compact() {
"editMessage: message:processing ..., buttonValues=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",
"createResultMessageWithReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=__**9d10 ≥6 ⇒ 3**__ [**1**,**1**,**1**,3,3,5,5,**6**,**6**,**9**,**10**,**10**,**10**], fields=[], componentRowDefinitions=[], hasImage=false, type=MESSAGE), targetChannelId: null",
"deleteMessageById: 0",
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=EMBED)"
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)"
);
}

Expand Down Expand Up @@ -111,7 +111,7 @@ void roll_minimal() {
"editMessage: message:processing ..., buttonValues=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",
"createResultMessageWithReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=9d10 ≥6 ⇒ 3, fields=[], componentRowDefinitions=[], hasImage=false, type=MESSAGE), targetChannelId: null",
"deleteMessageById: 0",
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=EMBED)"
"createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on the buttons to roll dice, with ask reroll:9,10 and botch:1,2, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d10, id=pool_target100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=pool_target200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3d10, id=pool_target300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4d10, id=pool_target400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=5d10, id=pool_target500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=6d10, id=pool_target600000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7d10, id=pool_target700000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=8d10, id=pool_target800000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=9d10, id=pool_target900000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=10d10, id=pool_target1000000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=11d10, id=pool_target1100000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=12d10, id=pool_target1200000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=13d10, id=pool_target1300000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=14d10, id=pool_target1400000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=15d10, id=pool_target1500000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)"
);
}

Expand Down
Loading

0 comments on commit e7bf566

Please sign in to comment.