Skip to content

Commit f23e3d0

Browse files
committed
Should be re sending leagues messages
1 parent 52df9de commit f23e3d0

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

trackscape-discord-api/src/controllers/chat_controller.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async fn new_clan_chats(
120120

121121
if chat.is_league_world.is_some() {
122122
if chat.is_league_world.unwrap() {
123-
info!("Broadcast from League World")
123+
// info!("Broadcast from League World")
124124
}
125125
}
126126
//Checks to make sure the message has not already been process since multiple people could be submitting them
@@ -148,7 +148,8 @@ async fn new_clan_chats(
148148
}
149149

150150
if registered_guild.clan_name.clone().unwrap() != chat.clan_name {
151-
error!("Clan name does not match the clan name saved in the database");
151+
//TODO may remove. it happens a lot assuming from ppl moving clans
152+
// error!("Clan name does not match the clan name saved in the database");
152153
continue;
153154
}
154155

trackscape-discord-bot/src/commands/set_leagues_broadcast_channel.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use log::error;
12
use serenity::all::{
23
CommandDataOption, CommandDataOptionValue, CommandOptionType, CreateCommandOption,
34
};
@@ -9,7 +10,7 @@ use std::any::Any;
910
use tracing::info;
1011
use trackscape_discord_shared::database::BotMongoDb;
1112

12-
pub fn _register() -> CreateCommand {
13+
pub fn register() -> CreateCommand {
1314
CreateCommand::new("set_leagues_channel")
1415
.description("Sets a channel to receive league broadcasts. This is off by default")
1516
.default_member_permissions(Permissions::MANAGE_GUILD)
@@ -32,10 +33,21 @@ pub async fn run(
3233
let option = options.get(0).expect("Expected Channel Id option");
3334

3435
if let CommandDataOptionValue::Channel(channel) = option.value {
35-
if channel.type_id() != ChannelType::Text.type_id() {
36+
let possible_actual_channel = channel.to_channel(&ctx).await;
37+
if possible_actual_channel.is_err() {
38+
error!("Error getting channel: {:?}", possible_actual_channel.err());
39+
return Some("Error getting channel".to_string());
40+
}
41+
let guild_channel = possible_actual_channel
42+
.expect("Expected channel")
43+
.guild()
44+
.expect("Expected guild channel");
45+
46+
if guild_channel.kind != ChannelType::Text {
47+
error!("Please select a text channel.");
3648
return Some("Please select a text channel.".to_string());
3749
}
38-
info!("Channel: {:?}", channel);
50+
3951
let saved_guild_query = db.guilds.get_by_guild_id(guild_id).await;
4052

4153
return match saved_guild_query {

trackscape-discord-bot/src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ fn get_commands() -> Vec<CreateCommand> {
338338
commands.push(commands::expel_clanmate_command::register());
339339
commands.push(commands::name_change_command::register());
340340
commands.push(commands::manually_run_wom_sync_command::register());
341-
//leagues didnt have any braodcasts this time around and over now
342-
// commands.push(commands::set_leagues_broadcast_channel::register());
341+
commands.push(commands::set_leagues_broadcast_channel::register());
343342
commands
344343
}
345344
pub async fn create_commands_for_guild(guild_id: &GuildId, ctx: Context) {

0 commit comments

Comments
 (0)