NadekoBot/NadekoBot.Module.Searches/JokeCommands.cs

63 lines
2.2 KiB
C#
Raw Normal View History

using Discord.Commands;
2016-12-09 03:22:23 +00:00
using NadekoBot.Extensions;
2017-07-17 19:42:36 +00:00
using NadekoBot.Modules.Searches.Services;
using System.Linq;
using System.Threading.Tasks;
2017-07-17 19:42:36 +00:00
using NadekoBot.Common;
using NadekoBot.Common.Attributes;
namespace NadekoBot.Modules.Searches
{
public partial class Searches
{
[Group]
2017-07-15 16:34:34 +00:00
public class JokeCommands : NadekoSubmodule<SearchesService>
{
[NadekoCommand, Usage, Description, Aliases]
2016-12-16 18:43:57 +00:00
public async Task Yomama()
{
await Context.Channel.SendConfirmAsync(await _service.GetYomamaJoke()).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
2016-12-16 18:43:57 +00:00
public async Task Randjoke()
{
var jokeInfo = await _service.GetRandomJoke();
await Context.Channel.SendConfirmAsync("", jokeInfo.Text, footer: jokeInfo.BaseUri).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
2016-12-16 18:43:57 +00:00
public async Task ChuckNorris()
{
await Context.Channel.SendConfirmAsync(await _service.GetChuckNorrisJoke()).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
2016-12-16 18:43:57 +00:00
public async Task WowJoke()
{
2017-07-15 16:34:34 +00:00
if (!_service.WowJokes.Any())
{
2017-02-24 16:10:44 +00:00
await ReplyErrorLocalized("jokes_not_loaded").ConfigureAwait(false);
2016-12-09 03:22:23 +00:00
return;
}
2017-07-15 16:34:34 +00:00
var joke = _service.WowJokes[new NadekoRandom().Next(0, _service.WowJokes.Count)];
2016-12-16 18:43:57 +00:00
await Context.Channel.SendConfirmAsync(joke.Question, joke.Answer).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
2016-12-16 18:43:57 +00:00
public async Task MagicItem()
{
2017-07-15 16:34:34 +00:00
if (!_service.WowJokes.Any())
2016-12-09 03:22:23 +00:00
{
2017-02-24 16:10:44 +00:00
await ReplyErrorLocalized("magicitems_not_loaded").ConfigureAwait(false);
2016-12-09 03:22:23 +00:00
return;
}
2017-07-15 16:34:34 +00:00
var item = _service.MagicItems[new NadekoRandom().Next(0, _service.MagicItems.Count)];
2016-12-16 18:43:57 +00:00
await Context.Channel.SendConfirmAsync("✨" + item.Name, item.Description).ConfigureAwait(false);
}
}
}
}