public async Task Translate(string langs, [Leftover] string text = null) { try { await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false); var translation = await _searches.Translate(langs, text).ConfigureAwait(false); await ctx.Channel.SendConfirmAsync(GetText("translation") + " " + langs, translation).ConfigureAwait(false); } catch { await ReplyErrorLocalizedAsync("bad_input_format").ConfigureAwait(false); } }
public async Task Translate(string langs, [Leftover] string text = null) { try { await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false); Regex regex = new Regex(@".*>.*"); Match match = regex.Match(langs); if (!match.Success) { text = langs + " " + text; langs = "auto>en"; } var translation = await _searches.Translate(langs, text).ConfigureAwait(false); await ctx.Channel.SendConfirmAsync(GetText("translation") + " " + langs, translation).ConfigureAwait(false); } catch { await ReplyErrorLocalizedAsync("bad_input_format").ConfigureAwait(false); } }