feat: reintroduce support onboarding

Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
seth 2023-12-04 06:04:38 -05:00
parent 368b5e0cb0
commit 604a81fb44
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
2 changed files with 46 additions and 0 deletions

View file

@ -6,6 +6,7 @@ use poise::{Event, FrameworkContext};
mod delete;
mod eta;
mod support_onboard;
pub async fn handle(
ctx: &Context,
@ -30,6 +31,8 @@ pub async fn handle(
Event::ReactionAdd { add_reaction } => delete::handle(ctx, add_reaction).await?,
Event::ThreadCreate { thread } => support_onboard::handle(ctx, thread).await?,
_ => {}
}

View file

@ -0,0 +1,43 @@
use color_eyre::eyre::{eyre, Result};
use log::*;
use poise::serenity_prelude::{ChannelType, Context, GuildChannel};
pub async fn handle(ctx: &Context, thread: &GuildChannel) -> Result<()> {
if thread.kind != ChannelType::PublicThread {
return Ok(());
}
let parent_id = thread
.parent_id
.ok_or_else(|| eyre!("Couldn't get parent ID from thread {}!", thread.name))?;
let parent_channel = ctx
.cache
.guild_channel(parent_id)
.ok_or_else(|| eyre!("Couldn't get GuildChannel {}!", parent_id))?;
if parent_channel.name != "support" {
debug!("Not posting onboarding message to threads outside of support");
return Ok(());
}
let owner = thread
.owner_id
.ok_or_else(|| eyre!("Couldn't get owner of thread!"))?;
let msg = format!(
"<@{}> We've received your support ticket! {} {}",
owner,
"Please upload your logs and post the link here if possible (run `tag log` to find out how).",
"Please don't ping people for support questions, unless you have their permission."
);
thread
.send_message(ctx, |m| {
m.content(msg)
.allowed_mentions(|am| am.replied_user(true).users(Vec::from([owner])))
})
.await?;
Ok(())
}