-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add server activity leaderboard #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using Discord.WebSocket; | ||
|
|
||
| namespace BaseBotService.Core.Messages; | ||
| public class UserLeftNotification : INotification | ||
| { | ||
| public SocketGuild Guild { get; } | ||
| public SocketUser User { get; } | ||
|
|
||
| public UserLeftNotification(SocketGuild guild, SocketUser user) | ||
| { | ||
| Guild = guild; | ||
| User = user; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,4 +38,10 @@ public int DeleteGuild(ulong guildId) | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| public IEnumerable<GuildMemberHC> GetTopUsers(ulong guildId, int limit) | ||||||||||||||||||||||||||||||||
| => _guildMembers | ||||||||||||||||||||||||||||||||
| .Find(a => a.GuildId == guildId) | ||||||||||||||||||||||||||||||||
| .OrderByDescending(u => u.ActivityPoints) | ||||||||||||||||||||||||||||||||
| .Take(limit); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add input validation for the limit parameter. The implementation is correct but should validate the limit parameter to prevent potential issues with negative values. public IEnumerable<GuildMemberHC> GetTopUsers(ulong guildId, int limit)
- => _guildMembers
+{
+ if (limit < 0)
+ throw new ArgumentOutOfRangeException(nameof(limit), "Limit must be non-negative.");
+
+ return _guildMembers
.Find(a => a.GuildId == guildId)
.OrderByDescending(u => u.ActivityPoints)
.Take(limit);
+}Note: For very large guilds, consider implementing database-level ordering and limiting to improve performance, though the current approach should be sufficient for typical Discord server sizes. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -134,6 +134,9 @@ profile = { $username } @ { $guildname } | |||||||||
| *[other] Invalid activity score | ||||||||||
| } | ||||||||||
|
|
||||||||||
| leaderboard-title = Top { $amount } active users | ||||||||||
| leaderboard-entry = { $rank }. { $user } - { $points } pts | ||||||||||
|
Comment on lines
+137
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Translate strings to German for proper localization. The leaderboard strings are in English within the German localization file. For proper internationalization, these should be translated to German. -leaderboard-title = Top { $amount } active users
-leaderboard-entry = { $rank }. { $user } - { $points } pts
+leaderboard-title = Top { $amount } aktive Benutzer
+leaderboard-entry = { $rank }. { $user } - { $points } Punkte📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,9 @@ profile = { $username } @ { $guildname } | |
| *[other] Invalid activity score | ||
| } | ||
|
|
||
| leaderboard-title = Top { $amount } active users | ||
| leaderboard-entry = { $rank }. { $user } - { $points } pts | ||
|
Comment on lines
+137
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Translate strings to Spanish for proper localization. The leaderboard strings are in English within the Spanish localization file. For proper internationalization, these should be translated to Spanish. -leaderboard-title = Top { $amount } active users
-leaderboard-entry = { $rank }. { $user } - { $points } pts
+leaderboard-title = Top { $amount } usuarios activos
+leaderboard-entry = { $rank }. { $user } - { $points } pts
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -134,6 +134,9 @@ profile = { $username } @ { $guildname } | |||||||||
| *[other] Invalid activity score | ||||||||||
| } | ||||||||||
|
|
||||||||||
| leaderboard-title = Top { $amount } active users | ||||||||||
| leaderboard-entry = { $rank }. { $user } - { $points } pts | ||||||||||
|
Comment on lines
+137
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Translate strings to French for proper localization. The leaderboard strings are in English within the French localization file. For proper internationalization, these should be translated to French. -leaderboard-title = Top { $amount } active users
-leaderboard-entry = { $rank }. { $user } - { $points } pts
+leaderboard-title = Top { $amount } utilisateurs actifs
+leaderboard-entry = { $rank }. { $user } - { $points } pts📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing using statement for MediatR.
The
INotificationinterface requires a using statement for MediatR.Apply this diff to add the missing using statement:
using Discord.WebSocket; +using MediatR;📝 Committable suggestion
🤖 Prompt for AI Agents