Add !lmgtfy

This commit is contained in:
runebaas 2020-07-22 14:32:47 +02:00
parent fff2324232
commit 4659f793f5
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6

View file

@ -0,0 +1,33 @@
using System;
using System.Threading.Tasks;
using System.Web;
using Discord.Commands;
using Geekbot.net.Lib.ErrorHandling;
namespace Geekbot.net.Commands.Utils
{
public class Lmgtfy : ModuleBase
{
private readonly IErrorHandler _errorHandler;
public Lmgtfy(IErrorHandler errorHandler)
{
_errorHandler = errorHandler;
}
[Command("lmgtfy", RunMode = RunMode.Async)]
[Summary("Get a 'Let me google that for you' link")]
public async Task GetUrl([Remainder] [Summary("question")] string question)
{
try
{
var encoded = HttpUtility.UrlEncode(question).Replace("%20", "+");
await Context.Channel.SendMessageAsync($"<https://lmgtfy.com/?q={encoded}>");
}
catch (Exception e)
{
await _errorHandler.HandleCommandException(e, Context);
}
}
}
}