feat: added member summary command and apply leave command#105
Open
tejasai2007 wants to merge 1 commit into
Open
feat: added member summary command and apply leave command#105tejasai2007 wants to merge 1 commit into
tejasai2007 wants to merge 1 commit into
Conversation
tejasai2007
force-pushed
the
develop
branch
9 times, most recently
from
March 14, 2026 10:32
f4df892 to
8b2e600
Compare
Author
|
@hrideshmg can you please review this pr |
There was a problem hiding this comment.
Pull request overview
Adds new Discord slash commands and GraphQL client functionality to support member summaries and leave application/approval workflows for attendance tracking.
Changes:
- Introduces
/member_summaryand/apply_leaveslash commands. - Adds GraphQL query/mutation methods and models for member summaries and leave tracking/approval.
- Implements reaction-based leave approval flow on ✅ reactions.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/status_update.rs | Minor formatting updates in break/year label rendering. |
| src/main.rs | Adds ✅ reaction-based leave approval handling in the event handler. |
| src/graphql/queries.rs | Adds member summary + leave count fetching GraphQL queries. |
| src/graphql/mutations.rs | Adds leave application + approval GraphQL mutations. |
| src/graphql/models.rs | Adds structs for member summary and leave records. |
| src/graphql/mod.rs | Exposes the new mutations module. |
| src/config.rs | Minor formatting change in env var loading. |
| src/commands/summary.rs | New /member_summary command and default date range logic. |
| src/commands/mod.rs | Registers new commands. |
| src/commands/apply_leave.rs | New /apply_leave command and leave request embed posting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
157
to
+160
| FullEvent::ReactionAdd { add_reaction } => { | ||
| handle_reaction(ctx, add_reaction, data, true).await?; | ||
| if add_reaction.user_id == Some(ctx.cache.current_user().id) { | ||
| return Ok(()); | ||
| } |
Comment on lines
+181
to
+187
| if let Some(line) = description.lines().find(|l| l.contains("User:")) { | ||
| let discord_id = line | ||
| .replace("**User:**", "") | ||
| .replace("<@", "") | ||
| .replace(">", "") | ||
| .trim() | ||
| .to_string(); |
Comment on lines
+210
to
+212
| let total_days = (end_date - start_date).num_days().max(1); | ||
|
|
||
| let update_percent = (updates as f32 * 100.0) / total_days as f32; |
Comment on lines
+264
to
+267
| let leaves: LeaveCountRecord = LeaveCountRecord { | ||
| discord_id: discord_id.to_string(), | ||
| leave_count: json["data"]["members"]["leaveCount"].as_i64().unwrap_or(0) as i32, | ||
| }; |
Comment on lines
+80
to
+84
| approveLeave( | ||
| discordId: $discord_id, | ||
| approvedBy: $mentor_discord_id, | ||
|
|
||
| ) { |
Comment on lines
+13
to
+19
| let discord_id = ctx.author().id.to_string(); | ||
|
|
||
| let duration = duration.unwrap_or(1); | ||
| ctx.data() | ||
| .graphql_client | ||
| .apply_leave(&discord_id, start_date, duration, reason) | ||
| .await?; |
Comment on lines
+21
to
+41
| let embed = if duration == 1 { | ||
| CreateEmbed::new() | ||
| .title("📝 Leave Request") | ||
| .description(format!( | ||
| "**User :** <@{}>\n\ | ||
| **Start Date :** {}\n\ | ||
| **Duration :** {} day\n\n\ | ||
| ", | ||
| discord_id, start_date, duration | ||
| )) | ||
| } else { | ||
| CreateEmbed::new() | ||
| .title("📝 Leave Request") | ||
| .description(format!( | ||
| "**User:** <@{}>\n\ | ||
| **Start Date:** {}\n\ | ||
| **Duration:** {} days\n\n\ | ||
| React with ✅ to approve.", | ||
| discord_id, start_date, duration | ||
| )) | ||
| }; |
Comment on lines
+48
to
+57
| if duration != 1 { | ||
| message | ||
| .react(ctx, serenity::ReactionType::Unicode("✅".into())) | ||
| .await?; | ||
|
|
||
| message | ||
| .react(ctx, serenity::ReactionType::Unicode("❌".into())) | ||
| .await?; | ||
| } | ||
| ctx.say("Leave request submitted.").await?; |
Comment on lines
+22
to
+41
| let time = Local::now(); | ||
| let year = time.year(); | ||
| let month = time.month(); | ||
| let end = time.date_naive(); | ||
|
|
||
| let (target_year, target_month) = if end.day() == 1 { | ||
| if month == 1 { | ||
| (year - 1, 12) | ||
| } else { | ||
| (year, month - 1) | ||
| } | ||
| } else { | ||
| (year, month) | ||
| }; | ||
|
|
||
| let start = NaiveDate::from_ymd_opt(target_year, target_month, 1) | ||
| .ok_or_else(|| anyhow::anyhow!("Invalid date"))?; | ||
|
|
||
| (start, end) | ||
| } |
| anyhow::anyhow!("Either provide both start and end dates, or none.").into(), | ||
| ); | ||
| } | ||
| }; |
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.
Developed member summary and apply leave commands to enforce strict attendance tracking and leave limits.