|
@@ -1,6 +1,6 @@
|
|
|
//! Allows to close an issue or a PR
|
|
|
|
|
|
-use crate::{config::CloseConfig, github::Event, handlers::Context};
|
|
|
+use crate::{config::CloseConfig, github::Event, handlers::Context, interactions::ErrorComment};
|
|
|
use parser::command::close::CloseCommand;
|
|
|
|
|
|
pub(super) async fn handle_command(
|
|
@@ -9,12 +9,17 @@ pub(super) async fn handle_command(
|
|
|
event: &Event,
|
|
|
_cmd: CloseCommand,
|
|
|
) -> anyhow::Result<()> {
|
|
|
+ let issue = event.issue().unwrap();
|
|
|
let is_team_member = event
|
|
|
.user()
|
|
|
.is_team_member(&ctx.github)
|
|
|
.await
|
|
|
.unwrap_or(false);
|
|
|
- let issue = event.issue().unwrap();
|
|
|
-
|
|
|
- unimplemented!();
|
|
|
+ if !is_team_member {
|
|
|
+ let cmnt = ErrorComment::new(&issue, "Only team members can close issues.");
|
|
|
+ cmnt.post(&ctx.github).await?;
|
|
|
+ return Ok(());
|
|
|
+ }
|
|
|
+ issue.close(&ctx.github).await?;
|
|
|
+ Ok(())
|
|
|
}
|