From 4e8e29073088fce8412cef4904a08183f8c07bdc Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Mon, 26 Feb 2018 23:34:30 -0600 Subject: [PATCH] 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. --- src/modules/discord.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/discord.rs b/src/modules/discord.rs index 68533bc..4cd4526 100644 --- a/src/modules/discord.rs +++ b/src/modules/discord.rs @@ -112,7 +112,8 @@ impl EventLoop for DiscordModule { if let Ok(envelope) = receiver.recv() { if let event::Event::Message { ref message } = envelope.event { if let Some(ref channel) = message.channel { - if let Ok(channel_id) = channel.name.parse::() { + let channel_string = channel.name.trim_left_matches('#'); + if let Ok(channel_id) = channel_string.parse::() { discord_sender.send_message(discord::model::ChannelId(channel_id), &message.content, "", false); } }