feat: reintroduce support onboarding
Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
parent
368b5e0cb0
commit
604a81fb44
2 changed files with 46 additions and 0 deletions
|
@ -6,6 +6,7 @@ use poise::{Event, FrameworkContext};
|
||||||
|
|
||||||
mod delete;
|
mod delete;
|
||||||
mod eta;
|
mod eta;
|
||||||
|
mod support_onboard;
|
||||||
|
|
||||||
pub async fn handle(
|
pub async fn handle(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
|
@ -30,6 +31,8 @@ pub async fn handle(
|
||||||
|
|
||||||
Event::ReactionAdd { add_reaction } => delete::handle(ctx, add_reaction).await?,
|
Event::ReactionAdd { add_reaction } => delete::handle(ctx, add_reaction).await?,
|
||||||
|
|
||||||
|
Event::ThreadCreate { thread } => support_onboard::handle(ctx, thread).await?,
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
43
src/handlers/event/support_onboard.rs
Normal file
43
src/handlers/event/support_onboard.rs
Normal 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(())
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue