Skip to content

Commit

Permalink
feat: use global_name if available, will increase immersion
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisTM committed Feb 25, 2024
1 parent 7bd6869 commit 5a23809
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/commands/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ use serenity::prelude::RwLock;
use crate::god::God;

pub async fn run(ctx: &Context, command: &CommandInteraction, god: Arc<RwLock<God>>) {
let author_name = command.user.name.clone();
let author_name = if let Some(global_name) = &command.user.global_name {
global_name.clone()
} else {
command.user.name.clone()
};
if let Some(ResolvedOption {
value: ResolvedValue::String(prompt_slice),
..
Expand All @@ -22,10 +26,9 @@ pub async fn run(ctx: &Context, command: &CommandInteraction, god: Arc<RwLock<Go
let response = { god.read().await.brain.request(&prompt).await };
if let Some(response) = response {
let content = format!(
"{}\n\n{}: {}",
&prompt.last().unwrap().content,
"\nFrom **{author_name}:**```{prompt_slice}```**{}:**```{}```",
god.read().await.get_botname(),
response.content.clone()
response.content,
);
let builder = EditInteractionResponse::new().content(content);
if let Err(why) = command.edit_response(&ctx.http, builder).await {
Expand Down

0 comments on commit 5a23809

Please sign in to comment.