Skip to content

Commit 0509a94

Browse files
committed
javadoc + reordered methods
1 parent 1bd233e commit 0509a94

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableRoleBasedAction.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
77

8+
/**
9+
* {@link RevocableModerationAction} abstract implementation for a role based moderation action.
10+
* <br />
11+
* <br />
12+
* Implements {@link RevocableModerationAction#handleRevokeFailure(ErrorResponse, long)} to handle
13+
* possible errors for a role-based revocation action.
14+
*/
815
abstract class RevocableRoleBasedAction implements RevocableModerationAction {
916
private static final Logger logger = LoggerFactory.getLogger(RevocableRoleBasedAction.class);
1017

1118
private final String actionName;
1219

20+
/**
21+
* Creates an instance of {@link RevocableRoleBasedAction} with the given action name.
22+
*
23+
* @param actionName the name of the moderation action
24+
*/
1325
RevocableRoleBasedAction(String actionName) {
1426
this.actionName = actionName;
1527
}

application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryModerationRoutine.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ private void revokeAction(@NotNull RevocationGroupIdentifier groupIdentifier) {
126126
}, failure -> handleFailure(failure, groupIdentifier));
127127
}
128128

129+
private @NotNull RestAction<Void> executeRevocation(@NotNull Guild guild, @NotNull User target,
130+
@NotNull ModerationAction actionType) {
131+
logger.info("Revoked temporary action {} against user '{}' ({}).", actionType,
132+
target.getAsTag(), target.getId());
133+
RevocableModerationAction action = getRevocableActionByType(actionType);
134+
135+
String reason = "Automatic revocation of temporary action.";
136+
actionsStore.addAction(guild.getIdLong(), jda.getSelfUser().getIdLong(), target.getIdLong(),
137+
action.getRevokeType(), null, reason);
138+
139+
return action.revokeAction(guild, target, reason);
140+
}
141+
129142
private void handleFailure(@NotNull Throwable failure,
130143
@NotNull RevocationGroupIdentifier groupIdentifier) {
131144
if (failure instanceof ErrorResponseException errorResponseException
@@ -140,19 +153,6 @@ private void handleFailure(@NotNull Throwable failure,
140153
groupIdentifier.targetId, failure);
141154
}
142155

143-
private @NotNull RestAction<Void> executeRevocation(@NotNull Guild guild, @NotNull User target,
144-
@NotNull ModerationAction actionType) {
145-
logger.info("Revoked temporary action {} against user '{}' ({}).", actionType,
146-
target.getAsTag(), target.getId());
147-
RevocableModerationAction action = getRevocableActionByType(actionType);
148-
149-
String reason = "Automatic revocation of temporary action.";
150-
actionsStore.addAction(guild.getIdLong(), jda.getSelfUser().getIdLong(), target.getIdLong(),
151-
action.getRevokeType(), null, reason);
152-
153-
return action.revokeAction(guild, target, reason);
154-
}
155-
156156
private @NotNull RevocableModerationAction getRevocableActionByType(
157157
@NotNull ModerationAction type) {
158158
return Objects.requireNonNull(typeToRevocableAction.get(type),

0 commit comments

Comments
 (0)