Changed fileName locations to match the new file locations

This commit is contained in:
Chris Darnell committed 2021-05-01 20:36:34 -07:00
1 parent 6f832f0c14
commit b96c4fec55
11 files changed
+177 -128

No files matched your search

+23
View File
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace StarsiegeBot
@@ -18,6 +19,7 @@ namespace StarsiegeBot
{
public static Dictionary<string, GuildSettings> GuildSettings;
private readonly string fileName = "guildSettings.json";
private CancellationToken cancelToken;
public BotSettings()
{
Console.WriteLine("Bot Setting Commands Loaded");
@@ -68,6 +70,7 @@ namespace StarsiegeBot
json = sr.ReadToEnd();
GuildSettings = JsonConvert.DeserializeObject<Dictionary<string, GuildSettings>>(json);
}
_ = StartTimer(cancelToken);
}
[GroupCommand]
[Description("Work in progress. Does nothing yet.")]
@@ -75,6 +78,26 @@ namespace StarsiegeBot
{
await ctx.TriggerTypingAsync();
}
private async Task StartTimer(CancellationToken cancellationToken)
{
await Task.Run(async () =>
{
while (true)
{
string output = JsonConvert.SerializeObject(BotSettings.GuildSettings);
await File.WriteAllTextAsync("guildsettings.json", output);
await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken);
if (cancellationToken.IsCancellationRequested)
{
Console.WriteLine("Token Cancelled.");
break;
}
}
});
}
}
public class GuildSettings
+7 -99
View File
@@ -19,109 +19,17 @@ namespace StarsiegeBot
[Description("Experimental commands. May break the bot.")]
class ExperiemntalCommands : BaseCommandModule
{
private readonly List<Questions> QuizQuestions;
private readonly Random rnd = new Random();
public ExperiemntalCommands()
[Command("exit"), RequireOwner]
public async Task ExitProgram (CommandContext ctx)
{
// Load all the Quick Chat texts and sound wav file info.
var json = "";
using (var fs = File.OpenRead("questions.json"))
using (var 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);
}
[Command("quiz")]
[Hidden]
[Description("")]
public async Task Quiz(CommandContext ctx)
{
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 mainId = ids[selection];
string[] options = { "a", "b", "c", "d" };
var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:");
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("_ _", "_ _", 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);
var message = await ctx.RespondAsync(embed);
foreach (var item in options)
{
var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:");
await message.CreateReactionAsync(itemEmote);
}
var result = message.WaitForReactionAsync(ctx.Message.Author, TimeSpan.FromSeconds(5d));
if (!result.Result.TimedOut)
{
if (result.Result.Result.Emoji == correctAnswer) await ctx.RespondAsync("**CORRECT!!**");
else await ctx.RespondAsync($"Sorry, the right answer was {correctAnswer}");
}
else await ctx.RespondAsync("Sorry, time ran out!");
await ctx.RespondAsync("Attempting a shutdown...");
System.Environment.Exit(0);
}
[Command("test")]
[Hidden]
public async Task CollectionCommand(CommandContext ctx)
[Command("Report")]
public async Task Report (CommandContext ctx)
{
var 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;
foreach (var reaction in reactions)
{
foreach (var person in reaction.Users)
{
if (!correctEmote.Equals(reaction.Emoji))
{
losers.Add(person, true);
}
else
{
winners.Add(person, true);
}
}
}
foreach (KeyValuePair<DiscordUser, bool> pair in winners)
{
if (losers.ContainsKey(pair.Key))
{
winners.Remove(pair.Key);
}
}
strBuilder.AppendLine("Winners are:");
foreach (KeyValuePair<DiscordUser, bool> item in winners)
{
strBuilder.AppendLine(item.Key.Mention);
}
await ctx.RespondAsync(strBuilder.ToString());
await ctx.RespondAsync("Report not generated");
}
}
public class Questions
{
[JsonProperty("question")]
public string Question { get; private set; }
[JsonProperty("answer")]
public string[] Answers { get; private set; }
[JsonProperty("points")]
public int Points { get; private set; }
}
}
+11 -3
View File
@@ -2843,6 +2843,10 @@
"text":"Mr. Wizard, get me the hell out of here!",
"soundFile":"mrwizard.wav"
},
"711":{
"text":"||Hey guys, did you know that in terms of male human and female Pokémon breeding, Vaporeon is the most compatible Pokémon for humans? Not only are they in the field egg group, which is mostly comprised of mammals, Vaporeon are an average of 3”03’ tall and 63.9 pounds, this means they’re large enough to be able handle human dicks, and with their impressive Base Stats for HP and access to Acid Armor, you can be rough with one. Due to their mostly water based biology, there’s no doubt in my mind that an aroused Vaporeon would be incredibly wet, so wet that you could easily have sex with one for hours without getting sore. They can also learn the moves Attract, Baby-Doll Eyes, Captivate, Charm, and Tail Whip, along with not having fur to hide nipples, so it’d be incredibly easy for one to get you in the mood. With their abilities Water Absorb and Hydration, they can easily recover from fatigue with enough water. No other Pokémon comes close to this level of compatibility. Also, fun fact, if you pull out enough, you can make your Vaporeon turn white. Vaporeon is literally built for human dick. Ungodly defense stat+high HP pool+Acid Armor means it can take cock all day, all shapes and sizes and still come for more||",
"soundFile":"SPOILER_Vaporeon Breeding.mp3"
},
"712":{
"text":"Your mother was a dumpster.",
"soundFile":"f2_dm_yourmother.wav"
@@ -5356,7 +5360,7 @@
"soundFile":"sm_rajah_gd1.wav"
},
"1340":{
"text":"I'll over it.",
"text":"I'll cover it.",
"soundFile":"sm_rajah_gd2.wav"
},
"1341":{
@@ -7358,5 +7362,9 @@
"1840":{
"text":"Whadaya gonna do, bleed on me?",
"soundFile":"mp_bleed.wav"
}
}
},
"6969":{
"text":"||OOPSIE WOOPSIE!! Uwu We make a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!||",
"soundFile":"SPOILER_OOPSIE WOOPSIE.mp3"
},
}
+1 -20
View File
@@ -30,25 +30,7 @@ namespace StarsiegeBot
public DiscordClient Client { get; set; }
public CommandsNextExtension Commands { get; set; }
public VoiceNextExtension Voice { get; set; }
protected string BotName { get; set; }
private async Task StartTimer(CancellationToken cancellationToken)
{
await Task.Run(async () =>
{
while (true)
{
string output = JsonConvert.SerializeObject(BotSettings.GuildSettings);
await File.WriteAllTextAsync("guildSettings.json", output);
await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken);
if (cancellationToken.IsCancellationRequested)
{
Console.WriteLine("Token Cancelled.");
break;
}
}
});
}
public string BotName { get; protected set; }
public static void Main(string[] args)
{
@@ -139,7 +121,6 @@ namespace StarsiegeBot
this.Commands.RegisterCommands<DeathMessages>();
this.Commands.RegisterCommands<GameInfo>();
//}
Task thisTimerf = StartTimer(new CancellationToken());
// let's enable voice
this.Voice = this.Client.UseVoiceNext();
+1 -1
View File
@@ -16,7 +16,7 @@ namespace StarsiegeBot
{
private List<string> notfacts;
private bool IsEnabled;
private readonly string fileName = "notfacts.json";
private readonly string fileName = "Json/notfacts.json";
public NotFacts()
{
+2 -2
View File
@@ -16,7 +16,7 @@ namespace StarsiegeBot
{
private List<string> facts;
private bool IsEnabled;
private readonly string fileName = "snapple.json";
private readonly string fileName = "Json/snapple.json";
public SnappleFacts()
{
@@ -32,7 +32,7 @@ namespace StarsiegeBot
return;
// trigger typing.
await ctx.TriggerTypingAsync();
// store our output.
// store our output.
string output;
// @neo, why is this here?
snapId--;
+123
View File
@@ -0,0 +1,123 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StarsiegeBot.Raven
{
class TriviaHandler : BaseCommandModule
{
private readonly List<Questions> QuizQuestions;
private readonly Random rnd = new Random();
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)))
json = sr.ReadToEnd();
Dictionary<string, Questions> tempQC = JsonConvert.DeserializeObject<Dictionary<string, Questions>>(json);
QuizQuestions = Enumerable.ToList(tempQC.Values);
}
[Command("quiz")]
[Hidden]
[Description("")]
public async Task Quiz(CommandContext ctx)
{
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 mainId = ids[selection];
string[] options = { "a", "b", "c", "d" };
var correctAnswer = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{options[selection]}:");
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("_ _", "_ _", 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);
var message = await ctx.RespondAsync(embed);
foreach (var item in options)
{
var itemEmote = DiscordEmoji.FromName(ctx.Client, $":regional_indicator_{item}:");
await message.CreateReactionAsync(itemEmote);
}
var result = message.WaitForReactionAsync(ctx.Message.Author, TimeSpan.FromSeconds(5d));
if (!result.Result.TimedOut)
{
if (result.Result.Result.Emoji == correctAnswer) await ctx.RespondAsync("**CORRECT!!**");
else await ctx.RespondAsync($"Sorry, the right answer was {correctAnswer}");
}
else await ctx.RespondAsync("Sorry, time ran out!");
}
[Command("test")]
[Hidden]
public async Task CollectionCommand(CommandContext ctx)
{
var 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;
foreach (var reaction in reactions)
{
foreach (var person in reaction.Users)
{
if (!correctEmote.Equals(reaction.Emoji))
{
losers.Add(person, true);
}
else
{
winners.Add(person, true);
}
}
}
foreach (KeyValuePair<DiscordUser, bool> pair in winners)
{
if (losers.ContainsKey(pair.Key))
{
winners.Remove(pair.Key);
}
}
strBuilder.AppendLine("Winners are:");
foreach (KeyValuePair<DiscordUser, bool> item in winners)
{
strBuilder.AppendLine(item.Key.Mention);
}
await ctx.RespondAsync(strBuilder.ToString());
}
}
public class Questions
{
[JsonProperty("question")]
public string Question { get; private set; }
[JsonProperty("answer")]
public string[] Answers { get; private set; }
[JsonProperty("points")]
public int Points { get; private set; }
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ namespace StarsiegeBot
{
private DeathMessageLines dmLines;
private bool DeathMessagesEnabled;
private static readonly string fileName = "DeathMessages.json";
private static readonly string fileName = "Json/deathmessages.json";
public DeathMessages()
{
+1 -1
View File
@@ -18,7 +18,7 @@ namespace StarsiegeBot
{
private Dictionary<string, SSFunction> ssFunctions;
private bool FunctionsEnabled;
private static readonly string fileName = "functions.json";
private static readonly string fileName = "Json/functions.json";
public Functions()
{
Console.WriteLine("Starsiege Function Commands Loaded");
+1 -1
View File
@@ -18,7 +18,7 @@ namespace StarsiegeBot
{
private Dictionary<string, Quickchat> quickchats;
private bool IsEnabled;
private readonly string fileName = "quickchats.json";
private readonly string fileName = "Json/quickchats.json";
public QuickchatHandler()
+6
View File
@@ -31,12 +31,18 @@
<None Update="Json\guildsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Json\notfacts.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Json\questions.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Json\quickchats.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Json\snapple.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>