Fixed players not being able to send images
parent
98bc997ff3
commit
4ff36d3fe8
|
@ -99,7 +99,7 @@ async fn say(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||||
|
|
||||||
let msg = format!("**wOxlf **> {}", args.rest());
|
let msg = format!("**wOxlf **> {}", args.rest());
|
||||||
|
|
||||||
send_msg_to_player_channels(ctx, &guild, &global_data, MessageSource::Host, &msg, false).await;
|
send_msg_to_player_channels(ctx, &guild, &global_data, MessageSource::Host, &msg, None, false).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ async fn broadcast(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||||
|
|
||||||
let msg = build_system_message(args.rest());
|
let msg = build_system_message(args.rest());
|
||||||
|
|
||||||
send_msg_to_player_channels(ctx, &guild, &global_data, MessageSource::Host, &msg, true).await;
|
send_msg_to_player_channels(ctx, &guild, &global_data, MessageSource::Host, &msg, None,true).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,7 @@ async fn next_phase(ctx: &Context, msg: &Message, mut args: Args) -> CommandResu
|
||||||
&global_data,
|
&global_data,
|
||||||
MessageSource::Host,
|
MessageSource::Host,
|
||||||
&broadcast,
|
&broadcast,
|
||||||
|
None,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
@ -275,6 +276,7 @@ async fn add_time(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
||||||
&global_data,
|
&global_data,
|
||||||
MessageSource::Host,
|
MessageSource::Host,
|
||||||
&broadcast,
|
&broadcast,
|
||||||
|
None,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -14,6 +14,7 @@ use serenity::utils::MessageBuilder;
|
||||||
|
|
||||||
use crate::data::{BotConfig, GameState, GlobalData, MessageSource, PlayerData};
|
use crate::data::{BotConfig, GameState, GlobalData, MessageSource, PlayerData};
|
||||||
use std::time::UNIX_EPOCH;
|
use std::time::UNIX_EPOCH;
|
||||||
|
use serenity::http::AttachmentType;
|
||||||
|
|
||||||
pub async fn send_msg_to_player_channels(
|
pub async fn send_msg_to_player_channels(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
|
@ -21,6 +22,7 @@ pub async fn send_msg_to_player_channels(
|
||||||
global_data: &GlobalData,
|
global_data: &GlobalData,
|
||||||
msg_source: MessageSource,
|
msg_source: MessageSource,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
|
attachment: Option<Vec<AttachmentType<'_>>>,
|
||||||
pin: bool,
|
pin: bool,
|
||||||
) {
|
) {
|
||||||
for player_data in &global_data.game_state.player_data {
|
for player_data in &global_data.game_state.player_data {
|
||||||
|
@ -36,7 +38,15 @@ pub async fn send_msg_to_player_channels(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let msg = channel
|
let msg = channel
|
||||||
.send_message(&ctx.http, |m| m.content(&msg))
|
.send_message(&ctx.http, |m| {
|
||||||
|
m.content(&msg);
|
||||||
|
|
||||||
|
if let Some(attachment) = attachment.clone() {
|
||||||
|
m.add_files(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
m
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -71,7 +81,15 @@ pub async fn send_msg_to_player_channels(
|
||||||
};
|
};
|
||||||
|
|
||||||
host_channel
|
host_channel
|
||||||
.send_message(&ctx.http, |m| m.content(format!("({}): {}", source, msg)))
|
.send_message(&ctx.http, |m| {
|
||||||
|
m.content(format!("({}): {}", source, msg));
|
||||||
|
if let Some(attachment) = attachment {
|
||||||
|
m.add_files(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
m
|
||||||
|
}
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ use serenity::model::prelude::{Message, Ready};
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
use serenity::http::AttachmentType;
|
||||||
|
|
||||||
struct Handler {}
|
struct Handler {}
|
||||||
|
|
||||||
|
@ -38,12 +39,17 @@ impl EventHandler for Handler {
|
||||||
let guild = msg.guild(&ctx.cache).await.unwrap();
|
let guild = msg.guild(&ctx.cache).await.unwrap();
|
||||||
let user_msg = format!("{} > {}", player_data.codename, msg.content);
|
let user_msg = format!("{} > {}", player_data.codename, msg.content);
|
||||||
|
|
||||||
|
let attachments: Vec<AttachmentType> = msg.attachments.iter().map(|a| {
|
||||||
|
AttachmentType::Image(&a.url)
|
||||||
|
}).collect();
|
||||||
|
|
||||||
send_msg_to_player_channels(
|
send_msg_to_player_channels(
|
||||||
&ctx,
|
&ctx,
|
||||||
&guild,
|
&guild,
|
||||||
&game_data,
|
&game_data,
|
||||||
MessageSource::Player(msg.channel_id.0),
|
MessageSource::Player(msg.channel_id.0),
|
||||||
&user_msg,
|
&user_msg,
|
||||||
|
Some(attachments),
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
Loading…
Reference in New Issue