fixed wowjoke
This commit is contained in:
parent
f8be61690d
commit
c7a83aa58a
@ -1,31 +1,35 @@
|
||||
using NadekoBot.Classes;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Discord.Commands;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Commands
|
||||
{
|
||||
class WowJokes : DiscordCommand
|
||||
class WowJokeCommand : DiscordCommand
|
||||
{
|
||||
public WowJokes(DiscordModule module) : base(module)
|
||||
|
||||
List<WoWJoke> jokes = new List<WoWJoke>();
|
||||
|
||||
public WowJokeCommand(DiscordModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
List<WowJokes> Jokes = new List<WowJokes>();
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "wowjoke")
|
||||
.Description("Get one of Kwoth's penultimate WoW jokes.")
|
||||
.Do(async e =>
|
||||
{
|
||||
if (!Jokes.Any())
|
||||
{
|
||||
Jokes = JsonConvert.DeserializeObject<List<WowJokes>>("data/wowjokes.json");
|
||||
if (!jokes.Any())
|
||||
{
|
||||
jokes = JsonConvert.DeserializeObject<List<WoWJoke>>(File.ReadAllText("data/wowjokes.json"));
|
||||
}
|
||||
await e.Channel.SendMessage(Jokes[new Random().Next(0, Jokes.Count)].ToString());
|
||||
await e.Channel.SendMessage(jokes[new Random().Next(0, jokes.Count)].ToString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Searches
|
||||
commands.Add(new StreamNotifications(this));
|
||||
commands.Add(new ConverterCommand(this));
|
||||
commands.Add(new RedditCommand(this));
|
||||
commands.Add(new WowJokes(this));
|
||||
commands.Add(new WowJokeCommand(this));
|
||||
rng = new Random();
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ namespace NadekoBot
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
Console.WriteLine("-----------------");
|
||||
Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false));
|
||||
Console.WriteLine("-----------------");
|
||||
|
@ -99,15 +99,12 @@ namespace NadekoBot.Classes.JSONModels
|
||||
public bool Missing { get; set; } = false;
|
||||
public string FullUrl { get; set; }
|
||||
}
|
||||
|
||||
public class WoWJoke
|
||||
|
||||
public class WoWJoke
|
||||
{
|
||||
public string Question { get; set; }
|
||||
public string Answer { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return $"**{Question}**\n\n{Answer}!";
|
||||
}
|
||||
public override string ToString() => $"`{Question}`\n\n**{Answer}**";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user