Open up admin-lb run#2662
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR broadens /admin-lb run from a home-guild-only operation to a guild-scoped run, limiting collection/posting to the invoking guild when triggered manually.
Changes:
- Adds guild-specific leaderboard config loading.
- Adds a
guildIDparameter to collection/posting flows. - Updates
/admin-lb runto invoke collection for the current guild and changes admin permission checks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/leaderboard/leaderboard.go |
Adds GetGuildLBConfigs and minor exported comments. |
src/leaderboard/leaderboard_task.go |
Adds guild-scoped opt-in filtering and passes guild scope to posting. |
src/leaderboard/leaderboard_slashcmd.go |
Removes home-guild restriction for run and invokes guild-scoped collection. |
src/leaderboard/leaderboard_post.go |
Allows posting either all configured guilds or one specified guild. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+155
to
+156
| if err != nil || perms&discordgo.PermissionAdministrator == 0 { | ||
| respondEphemeral(s, i, "You need the Administrator permission to use admin commands.") |
|
|
||
| go func() { | ||
| RunLeaderboardCollection(s, dryRun, onProgress) | ||
| RunLeaderboardCollection(s, dryRun, i.GuildID, onProgress) |
Comment on lines
+144
to
+146
| if guildID != "" && o.GuildID != guildID { | ||
| continue | ||
| } |
Comment on lines
+106
to
+114
| if err == nil { | ||
| seen := make(map[string]bool) | ||
| for _, o := range optins { | ||
| if !seen[o.UserID] { | ||
| seen[o.UserID] = true | ||
| userIDs = append(userIDs, o.UserID) | ||
| } | ||
| } | ||
| } |
| @@ -76,7 +76,7 @@ var ( | |||
| // RunLeaderboardCollection is the main weekly entry point. It fans out API | |||
| // calls through a bounded worker pool, saves results, then posts to Discord. | |||
| // Pass dryRun=true to skip the Discord post step. | |||
Comment on lines
+521
to
+531
| cfgs := make([]LBConfig, 0, len(rows)) | ||
| for _, row := range rows { | ||
| cfg := LBConfig{ | ||
| LBType: row.LbType, | ||
| GuildID: row.GuildID, | ||
| ChannelID: row.ChannelID, | ||
| } | ||
| if row.MessageIds.Valid && row.MessageIds.String != "" { | ||
| _ = json.Unmarshal([]byte(row.MessageIds.String), &cfg.MessageIDs) | ||
| } | ||
| cfgs = append(cfgs, cfg) |
|
|
||
| go func() { | ||
| RunLeaderboardCollection(s, dryRun, onProgress) | ||
| RunLeaderboardCollection(s, dryRun, i.GuildID, onProgress) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.