-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from learn-english-community/feature/streaks
feat: Streaks functionality
- Loading branch information
Showing
10 changed files
with
391 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package bot.cmd; | ||
|
||
import bot.service.UserService; | ||
import bot.view.StreakView; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StreakCommand extends BotCommand { | ||
|
||
private final UserService userService; | ||
|
||
public StreakCommand(UserService userService) { | ||
super("streak", "Check out your streak", true); | ||
this.userService = userService; | ||
} | ||
|
||
@Override | ||
public void execute(SlashCommandInteractionEvent event) { | ||
String userId = event.getUser().getId(); | ||
StreakView view = new StreakView(); | ||
|
||
event.reply("") | ||
.setEphemeral(true) | ||
.setEmbeds(view.getStreak(userService.getUser(userId))) | ||
.queue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package bot.entity.session; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
/** | ||
* Represents a session. | ||
* | ||
* <p>This is mostly used to record past sessions, primarily to keep track of user streaks and for | ||
* future metric aggregation. | ||
*/ | ||
@Getter | ||
public class Session { | ||
private int index; | ||
|
||
private final Type type; | ||
|
||
private final long timestamp; | ||
|
||
@Builder | ||
public Session(Type type, long timestamp) { | ||
this.type = type; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public enum Type { | ||
JOURNAL_QUIZ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.