Modified the Flag sub command of QuickChatHandler. Added '.editorconfig' and conformed majority of files to fit within it's scopes.
This commit is contained in:
1 parent
990aca3e41
commit
1e3e8eb69b
16 files changed
+581
-330
No files matched your search
@@ -14,31 +14,31 @@ namespace StarsiegeBot
|
||||
[Group("notfact")]
|
||||
class NotFacts : BaseCommandModule
|
||||
{
|
||||
private List<string> notfacts;
|
||||
private bool IsEnabled;
|
||||
private readonly string fileName = "Json/notfacts.json";
|
||||
private List<string> _notfacts;
|
||||
private bool _isEnabled;
|
||||
private static readonly string s_fileName = "Json/notfacts.json";
|
||||
|
||||
public NotFacts()
|
||||
{
|
||||
Console.WriteLine("NotFacts Command Loaded");
|
||||
IsEnabled = Load();
|
||||
_isEnabled = Load();
|
||||
}
|
||||
|
||||
[GroupCommand, Description("Get a NotFact")]
|
||||
public async Task NotFact(CommandContext ctx, [Description("[Optional] A NotFact ID")] int notFactID = 0)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
await ctx.TriggerTypingAsync();
|
||||
string output;
|
||||
notFactID--;
|
||||
try
|
||||
{
|
||||
output = notfacts[notFactID];
|
||||
output = _notfacts[notFactID];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
output = notfacts[Program.rnd.Next(0, notfacts.Count)];
|
||||
output = _notfacts[Program.rnd.Next(0, _notfacts.Count)];
|
||||
}
|
||||
await ctx.RespondAsync(StartEmbed(output));
|
||||
}
|
||||
@@ -46,10 +46,10 @@ namespace StarsiegeBot
|
||||
[Command("count"), Aliases("c"), Description("Get a count of the NotFacts")]
|
||||
public async Task NotFactCount(CommandContext ctx)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
await ctx.TriggerTypingAsync();
|
||||
await ctx.RespondAsync(StartEmbed(notfacts.Count + " NotFacts in the NotFacts Bank"));
|
||||
await ctx.RespondAsync(StartEmbed(_notfacts.Count + " NotFacts in the NotFacts Bank"));
|
||||
}
|
||||
|
||||
[Command("load"), RequireOwner, Aliases("l")]
|
||||
@@ -60,14 +60,14 @@ namespace StarsiegeBot
|
||||
// start the response.
|
||||
DiscordEmbedBuilder embed = StartEmbed("Reloading NotFacts");
|
||||
// our old setting...
|
||||
embed.AddField("Old", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("Old", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// run this, we dont care about its actual results.
|
||||
_ = Load();
|
||||
// report our new setting.
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// since the only thing that *should* go wrong is a missing file, report it if thats the case.
|
||||
if (!File.Exists(fileName))
|
||||
embed.WithFooter($":warning: {fileName} file is missing.");
|
||||
if (!File.Exists(s_fileName))
|
||||
embed.WithFooter($":warning: {s_fileName} file is missing.");
|
||||
// send our results.
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
@@ -83,34 +83,34 @@ namespace StarsiegeBot
|
||||
string[] turnOff = { "off", "false", "0" };
|
||||
//start our response.
|
||||
DiscordEmbedBuilder embed = StartEmbed("NotFact Toggle");
|
||||
embed.AddField("Old", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("Old", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// check for file.
|
||||
if (File.Exists(fileName))
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
// compare desired input against on or off values.
|
||||
if (turnOn.Contains(isEnabled))
|
||||
{
|
||||
IsEnabled = true;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
_isEnabled = true;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else if (turnOff.Contains(isEnabled))
|
||||
{
|
||||
IsEnabled = false;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
_isEnabled = false;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// we dont know what they were trying to do, throw an error in the footer with a :warning: emote.
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter(":warning: Invalid command given?");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// file is missing, disable this, regardless of their desires. Report the file is missing in the footer with a :warning:
|
||||
IsEnabled = false;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter($":warning: {fileName} file is missing, and it can not be enabled.");
|
||||
_isEnabled = false;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter($":warning: {s_fileName} file is missing, and it can not be enabled.");
|
||||
}
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
@@ -129,17 +129,17 @@ namespace StarsiegeBot
|
||||
private bool Load()
|
||||
{
|
||||
bool ret;
|
||||
if (File.Exists(fileName))
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
string json = File.ReadAllText(fileName);
|
||||
notfacts = JsonConvert.DeserializeObject<List<string>>(json);
|
||||
string json = File.ReadAllText(s_fileName);
|
||||
_notfacts = JsonConvert.DeserializeObject<List<string>>(json);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
IsEnabled = ret;
|
||||
_isEnabled = ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,21 +14,21 @@ namespace StarsiegeBot
|
||||
[Group("snapple"), Aliases("snap")]
|
||||
class SnappleFacts : BaseCommandModule
|
||||
{
|
||||
private List<string> facts;
|
||||
private bool IsEnabled;
|
||||
private readonly string fileName = "Json/snapple.json";
|
||||
private List<string> _facts;
|
||||
private bool _isEnabled;
|
||||
private static readonly string s_fileName = "Json/snapple.json";
|
||||
|
||||
public SnappleFacts()
|
||||
{
|
||||
Console.WriteLine("Snapple Commands Loaded");
|
||||
IsEnabled = Load();
|
||||
_isEnabled = Load();
|
||||
}
|
||||
|
||||
[GroupCommand, Description("Get a Snapple \"Real Fact\".")]
|
||||
public async Task Snapplefact(CommandContext ctx, [Description("[Optional] A Snapple Fact ID")] int snapId = 0)
|
||||
{
|
||||
// if we're not enabled, exit out.
|
||||
if (!IsEnabled)
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
// trigger typing.
|
||||
await ctx.TriggerTypingAsync();
|
||||
@@ -39,12 +39,12 @@ namespace StarsiegeBot
|
||||
try
|
||||
{
|
||||
// attempt to get the desired fact.
|
||||
output = facts[snapId];
|
||||
output = _facts[snapId];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// we couldn't find the exact one, give them a random one.
|
||||
output = facts[Program.rnd.Next(0, facts.Count)];
|
||||
output = _facts[Program.rnd.Next(0, _facts.Count)];
|
||||
}
|
||||
// give them what they want.
|
||||
await ctx.RespondAsync(StartEmbed(output));
|
||||
@@ -53,11 +53,11 @@ namespace StarsiegeBot
|
||||
[Command("count"), Description("Get a Snapple \"Real Fact\"."), Aliases("c")]
|
||||
public async Task SnappleCount(CommandContext ctx)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
if (!_isEnabled)
|
||||
return;
|
||||
await ctx.TriggerTypingAsync();
|
||||
// trigger the typing, and report how many facts are in teh bank.
|
||||
await ctx.RespondAsync(StartEmbed(facts.Count + " facts in the Snapple \"Real Facts\" Bank"));
|
||||
await ctx.RespondAsync(StartEmbed(_facts.Count + " facts in the Snapple \"Real Facts\" Bank"));
|
||||
}
|
||||
|
||||
[Command("load"), RequireOwner, Aliases("l")]
|
||||
@@ -68,20 +68,20 @@ namespace StarsiegeBot
|
||||
// start the response.
|
||||
DiscordEmbedBuilder embed = StartEmbed("Reloading Snapple Facts");
|
||||
// our old setting...
|
||||
embed.AddField("Old", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("Old", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// run this, we dont care about its actual results.
|
||||
_ = Load();
|
||||
// report our new setting.
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// since the only thing that *should* go wrong is a missing file, report it if thats the case.
|
||||
if (!File.Exists(fileName))
|
||||
embed.WithFooter($":warning: {fileName} file is missing.");
|
||||
if (!File.Exists(s_fileName))
|
||||
embed.WithFooter($":warning: {s_fileName} file is missing.");
|
||||
// send our results.
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("toggle"), RequireOwner, Aliases("t")]
|
||||
public async Task Enable (CommandContext ctx, [RemainingText]string isEnabled = null)
|
||||
public async Task Enable(CommandContext ctx, [RemainingText] string isEnabled = null)
|
||||
{
|
||||
// trigger the typing.
|
||||
await ctx.TriggerTypingAsync();
|
||||
@@ -91,34 +91,34 @@ namespace StarsiegeBot
|
||||
string[] turnOff = { "off", "false", "0" };
|
||||
//start our response.
|
||||
DiscordEmbedBuilder embed = StartEmbed("Snapple Toggle");
|
||||
embed.AddField("Old", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("Old", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
// check for file.
|
||||
if (File.Exists(fileName))
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
// compare desired input against on or off values.
|
||||
if (turnOn.Contains(isEnabled))
|
||||
{
|
||||
IsEnabled = true;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
_isEnabled = true;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else if (turnOff.Contains(isEnabled))
|
||||
{
|
||||
IsEnabled = false;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
_isEnabled = false;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// we dont know what they were trying to do, throw an error in the footer with a :warning: emote.
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter(":warning: Invalid command given?");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// file is missing, disable this, regardless of their desires. Report the file is missing in the footer with a :warning:
|
||||
IsEnabled = false;
|
||||
embed.AddField("New", (IsEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter($":warning: {fileName} file is missing, and it can not be enabled.");
|
||||
_isEnabled = false;
|
||||
embed.AddField("New", (_isEnabled ? "Enabled" : "Disabled"));
|
||||
embed.WithFooter($":warning: {s_fileName} file is missing, and it can not be enabled.");
|
||||
}
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
@@ -136,17 +136,17 @@ namespace StarsiegeBot
|
||||
private bool Load()
|
||||
{
|
||||
bool ret;
|
||||
if (File.Exists(fileName))
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
string json = File.ReadAllText(fileName);
|
||||
facts = JsonConvert.DeserializeObject<List<string>>(json);
|
||||
string json = File.ReadAllText(s_fileName);
|
||||
_facts = JsonConvert.DeserializeObject<List<string>>(json);
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
IsEnabled = ret;
|
||||
_isEnabled = ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,17 @@ namespace StarsiegeBot.Raven
|
||||
{
|
||||
class TriviaHandler : BaseCommandModule
|
||||
{
|
||||
private readonly List<Questions> QuizQuestions;
|
||||
private readonly Random rnd = new Random();
|
||||
private readonly List<Questions> _quizQuestions;
|
||||
private static readonly string s_fileName = "Json/trivia.json";
|
||||
public TriviaHandler()
|
||||
{
|
||||
// Load all the Quick Chat texts and sound wav file info.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("Json/questions.json"))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
string json = "";
|
||||
using (FileStream fs = File.OpenRead(s_fileName))
|
||||
using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
Dictionary<string, Questions> tempQC = JsonConvert.DeserializeObject<Dictionary<string, Questions>>(json);
|
||||
QuizQuestions = Enumerable.ToList(tempQC.Values);
|
||||
_quizQuestions = Enumerable.ToList(tempQC.Values);
|
||||
|
||||
}
|
||||
[Command("quiz")]
|
||||
@@ -36,25 +36,25 @@ namespace StarsiegeBot.Raven
|
||||
await ctx.TriggerTypingAsync();
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder();
|
||||
|
||||
int[] ids = { rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count), rnd.Next(QuizQuestions.Count) };
|
||||
int selection = rnd.Next(ids.Length);
|
||||
int[] ids = { Program.rnd.Next(_quizQuestions.Count), Program.rnd.Next(_quizQuestions.Count), Program.rnd.Next(_quizQuestions.Count), Program.rnd.Next(_quizQuestions.Count) };
|
||||
int selection = Program.rnd.Next(ids.Length);
|
||||
int mainId = ids[selection];
|
||||
string[] options = { "a", "b", "c", "d" };
|
||||
|
||||
var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:");
|
||||
|
||||
Questions myQuestion = QuizQuestions[mainId];
|
||||
Questions myQuestion = _quizQuestions[mainId];
|
||||
|
||||
embed.Description = myQuestion.Question;
|
||||
|
||||
embed.AddField($":regional_indicator_{options[0]}:", QuizQuestions[ids[0]].Answers[rnd.Next(QuizQuestions[ids[0]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[1]}:", QuizQuestions[ids[1]].Answers[rnd.Next(QuizQuestions[ids[1]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[0]}:", _quizQuestions[ids[0]].Answers[Program.rnd.Next(_quizQuestions[ids[0]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[1]}:", _quizQuestions[ids[1]].Answers[Program.rnd.Next(_quizQuestions[ids[1]].Answers.Length)], true);
|
||||
embed.AddField("_ _", "_ _", false);
|
||||
embed.AddField($":regional_indicator_{options[2]}:", QuizQuestions[ids[2]].Answers[rnd.Next(QuizQuestions[ids[2]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[3]}:", QuizQuestions[ids[3]].Answers[rnd.Next(QuizQuestions[ids[3]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[2]}:", _quizQuestions[ids[2]].Answers[Program.rnd.Next(_quizQuestions[ids[2]].Answers.Length)], true);
|
||||
embed.AddField($":regional_indicator_{options[3]}:", _quizQuestions[ids[3]].Answers[Program.rnd.Next(_quizQuestions[ids[3]].Answers.Length)], true);
|
||||
|
||||
var message = await ctx.RespondAsync(embed);
|
||||
foreach (var item in options)
|
||||
DiscordMessage message = await ctx.RespondAsync(embed);
|
||||
foreach (string item in options)
|
||||
{
|
||||
var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:");
|
||||
await message.CreateReactionAsync(itemEmote);
|
||||
@@ -72,16 +72,16 @@ namespace StarsiegeBot.Raven
|
||||
[Hidden]
|
||||
public async Task CollectionCommand(CommandContext ctx)
|
||||
{
|
||||
var message = await ctx.RespondAsync("React here!");
|
||||
DiscordMessage message = await ctx.RespondAsync("React here!");
|
||||
var reactions = await message.CollectReactionsAsync();
|
||||
|
||||
var strBuilder = new StringBuilder();
|
||||
Dictionary<DiscordUser, bool> winners = new Dictionary<DiscordUser, bool>();
|
||||
Dictionary<DiscordUser, bool> losers = new Dictionary<DiscordUser, bool>();
|
||||
var correctEmote = reactions[0].Emoji;
|
||||
DiscordEmoji correctEmote = reactions[0].Emoji;
|
||||
foreach (var reaction in reactions)
|
||||
{
|
||||
foreach (var person in reaction.Users)
|
||||
foreach (DiscordUser person in reaction.Users)
|
||||
{
|
||||
if (!correctEmote.Equals(reaction.Emoji))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user