Merge pull request #4 from Neo-Desktop/main

Rework Fact commands
This commit is contained in:
cmd276 authored and GitHub committed 2021-04-30 18:14:05 -07:00
commit 50c5bd0caa
5 files changed
+1179 -1013

No files matched your search

+1
View File
@@ -130,6 +130,7 @@ namespace StarsiegeBot
this.Commands.RegisterCommands<PrefixManagement>();
this.Commands.RegisterCommands<RoleManagement>(); // Main Folder. Test Items.
this.Commands.RegisterCommands<SnappleFacts>();
this.Commands.RegisterCommands<NotFacts>();
this.Commands.RegisterCommands<StarsiegeCommands>();
this.Commands.RegisterCommands<WelcomeMessage>(); // Main Folder. Test Items.
+50
View File
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using Newtonsoft.Json;
namespace StarsiegeBot
{
class NotFacts : BaseCommandModule
{
private List<string> notfacts;
public NotFacts()
{
Console.WriteLine("NotFacts Command Loaded");
string json = File.ReadAllText("notfacts.json");
notfacts = JsonConvert.DeserializeObject<List<string>>(json);
}
[Command("notfact"), Description("Get a NotFact")]
public async Task Snapplefact(CommandContext ctx, [Description("[Optional] A NotFact ID")] int notFactID = 0)
{
await ctx.TriggerTypingAsync();
notFactID--;
try
{
await ctx.RespondAsync(notfacts[notFactID]);
return;
}
catch(Exception)
{
await ctx.RespondAsync(notfacts[Program.rnd.Next(0, notfacts.Count)]);
}
// await ctx.RespondAsync("**Warning:** The Id's used here are arbitrary");
}
[Command("notfactcount"), Description("Get a count of the NotFacts")]
public async Task SnappleCount(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
await ctx.RespondAsync(notfacts.Count + " NotFacts in the NotFacts Bank");
}
}
}
File diff suppressed because it is too large. Load diff