allow discord channel id to have a # in front. This is mainly to work around a problem in the lua module where a string channel id becomes a float and loses precision, but to also allow for a use case where we allow channel names and not just ids.

This commit is contained in:
Adrian Malacoda 2018-02-26 23:34:30 -06:00
parent 80bcfe0580
commit 4e8e290730

View File

@ -112,7 +112,8 @@ impl EventLoop for DiscordModule {
if let Ok(envelope) = receiver.recv() { if let Ok(envelope) = receiver.recv() {
if let event::Event::Message { ref message } = envelope.event { if let event::Event::Message { ref message } = envelope.event {
if let Some(ref channel) = message.channel { if let Some(ref channel) = message.channel {
if let Ok(channel_id) = channel.name.parse::<u64>() { let channel_string = channel.name.trim_left_matches('#');
if let Ok(channel_id) = channel_string.parse::<u64>() {
discord_sender.send_message(discord::model::ChannelId(channel_id), &message.content, "", false); discord_sender.send_message(discord::model::ChannelId(channel_id), &message.content, "", false);
} }
} }