Skip to content

Commit

Permalink
Moved to ChannelId.send_message and error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
fatfingers23 committed Oct 20, 2024
1 parent eba2d3e commit a8d7fa4
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions trackscape-discord-api/src/controllers/chat_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{handler, ChatServerHandle};
use actix_web::web::Data;
use actix_web::{error, post, web, Error, HttpRequest, HttpResponse, Scope};
use celery::Celery;
use log::info;
use log::{error, info};
use serenity::all::{ChannelId, CreateEmbed, CreateEmbedAuthor};
use serenity::builder::CreateMessage;
use serenity::http::Http;
Expand Down Expand Up @@ -166,10 +166,12 @@ async fn new_clan_chats(
.timestamp(right_now),
);

let channel = ChannelId::new(channel_id);
let _ = discord_http_client
.send_message(channel, vec![], &clan_chat_to_discord)
let new_chat_result = ChannelId::new(channel_id)
.send_message(&*discord_http_client, clan_chat_to_discord)
.await;
if let Err(e) = new_chat_result {
error!("Error sending normal cc: {:?}", e);
}
}
_ => {}
}
Expand Down Expand Up @@ -239,8 +241,6 @@ async fn new_clan_chats(
match possible_broadcast {
None => {}
Some(broadcast) => {
info!("Broadcast: {:?}", broadcast);
info!("{}\n", chat.message.clone());
let _ = mongodb
.broadcasts
.create_broadcast(registered_guild.guild_id, broadcast.clone())
Expand All @@ -262,13 +262,12 @@ async fn new_clan_chats(
false => registered_guild.broadcast_channel,
};
if let Some(channel_to_send_broadcast) = possible_channel_to_send_broadcast {
let _ = discord_http_client
.send_message(
ChannelId::new(channel_to_send_broadcast),
vec![],
&broadcast_message,
)
let new_broad_cast = ChannelId::new(channel_to_send_broadcast)
.send_message(&*discord_http_client, broadcast_message)
.await;
if let Err(e) = new_broad_cast {
error!("Error sending broadcast: {:?}", e);
}
}
}
};
Expand Down

0 comments on commit a8d7fa4

Please sign in to comment.