Added lock down functions, and modified search on QuickChats to include soundfiles
This commit is contained in:
1 parent
e7a882724b
commit
4c286d5c15
11 files changed
+138
-8
No files matched your search
@@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
|
||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("Group")]
|
[Group("Group")]
|
||||||
|
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
|
||||||
class GroupManagement : BotSettings
|
class GroupManagement : BotSettings
|
||||||
{
|
{
|
||||||
public GroupManagement()
|
public GroupManagement()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("GroupRole")]
|
[Group("GroupRole")]
|
||||||
|
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
|
||||||
class GroupRoleManagement : BotSettings
|
class GroupRoleManagement : BotSettings
|
||||||
{
|
{
|
||||||
public GroupRoleManagement()
|
public GroupRoleManagement()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("Level")]
|
[Group("Level")]
|
||||||
|
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
|
||||||
class LevelManagement : BotSettings
|
class LevelManagement : BotSettings
|
||||||
{
|
{
|
||||||
public LevelManagement()
|
public LevelManagement()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("LevelRole")]
|
[Group("LevelRole")]
|
||||||
|
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
|
||||||
class LevelRoleManagement : BotSettings
|
class LevelRoleManagement : BotSettings
|
||||||
{
|
{
|
||||||
public LevelRoleManagement()
|
public LevelRoleManagement()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("prefix")]
|
[Group("prefix")]
|
||||||
|
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
|
||||||
class PrefixManagement : BotSettings
|
class PrefixManagement : BotSettings
|
||||||
{
|
{
|
||||||
public PrefixManagement()
|
public PrefixManagement()
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace StarsiegeBot
|
|||||||
if (args.Length > 0)
|
if (args.Length > 0)
|
||||||
BotName = args[0].ToLower();
|
BotName = args[0].ToLower();
|
||||||
else
|
else
|
||||||
BotName = "sspdev";
|
BotName = "ssp";
|
||||||
|
|
||||||
BotEventId = new EventId(276, BotName);
|
BotEventId = new EventId(276, BotName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Threading;
|
|||||||
namespace StarsiegeBot
|
namespace StarsiegeBot
|
||||||
{
|
{
|
||||||
[Group("role")]
|
[Group("role")]
|
||||||
|
[RequireGuild,RequirePermissions(Permissions.ManageRoles)]
|
||||||
class RoleManagement : BotSettings
|
class RoleManagement : BotSettings
|
||||||
{
|
{
|
||||||
public RoleManagement()
|
public RoleManagement()
|
||||||
|
|||||||
@@ -54,6 +54,43 @@ namespace StarsiegeBot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("toggle"), Aliases("t")]
|
||||||
|
[RequireOwner]
|
||||||
|
public async Task ToggleQC(CommandContext ctx, [RemainingText] string isEnabled = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
|
||||||
|
isEnabled = isEnabled.ToLower();
|
||||||
|
|
||||||
|
string output = "";
|
||||||
|
|
||||||
|
string[] turnOn = { "on", "true", "1" };
|
||||||
|
string[] turnOff = { "off", "false", "0" };
|
||||||
|
|
||||||
|
if (File.Exists("DeathMessages.json"))
|
||||||
|
{
|
||||||
|
if (turnOn.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
DeathMessagesEnabled = true;
|
||||||
|
}
|
||||||
|
else if (turnOff.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
DeathMessagesEnabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
output = $"DeathMessages Enabled: {DeathMessagesEnabled}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeathMessagesEnabled = false;
|
||||||
|
output = "DeathMessages.json file is missing, and it can not be enabled.";
|
||||||
|
}
|
||||||
|
await ctx.RespondAsync(output);
|
||||||
|
}
|
||||||
|
|
||||||
[GroupCommand]
|
[GroupCommand]
|
||||||
public async Task DeathMessage(CommandContext ctx, [Description("Optional. Person you want to see kill you. If blank, will show generic death message.")]DiscordMember target = null)
|
public async Task DeathMessage(CommandContext ctx, [Description("Optional. Person you want to see kill you. If blank, will show generic death message.")]DiscordMember target = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace StarsiegeBot
|
|||||||
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
|
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
|
||||||
private readonly Random rnd = new Random();
|
private readonly Random rnd = new Random();
|
||||||
private readonly Dictionary<string, SSFunction> ssFunctions;
|
private readonly Dictionary<string, SSFunction> ssFunctions;
|
||||||
private readonly bool FunctionsEnabled;
|
private bool FunctionsEnabled;
|
||||||
|
|
||||||
public Functions()
|
public Functions()
|
||||||
{
|
{
|
||||||
@@ -136,6 +136,42 @@ namespace StarsiegeBot
|
|||||||
await ctx.RespondAsync($"There are {ssFunctions.Count} functions in the known list.");
|
await ctx.RespondAsync($"There are {ssFunctions.Count} functions in the known list.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("toggle"), Aliases("t")]
|
||||||
|
[RequireOwner]
|
||||||
|
public async Task ToggleQC(CommandContext ctx, [RemainingText] string isEnabled = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
|
||||||
|
isEnabled = isEnabled.ToLower();
|
||||||
|
|
||||||
|
string output = "";
|
||||||
|
|
||||||
|
string[] turnOn = { "on", "true", "1" };
|
||||||
|
string[] turnOff = { "off", "false", "0" };
|
||||||
|
|
||||||
|
if (File.Exists("functions.json"))
|
||||||
|
{
|
||||||
|
if (turnOn.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
FunctionsEnabled = true;
|
||||||
|
}
|
||||||
|
else if (turnOff.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
FunctionsEnabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
output = $"Functions Enabled: {FunctionsEnabled}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FunctionsEnabled = false;
|
||||||
|
output = "Functions.json file is missing, and it can not be enabled.";
|
||||||
|
}
|
||||||
|
await ctx.RespondAsync(output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SSFunction
|
public class SSFunction
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
private readonly List<Quickchats> Quickchats;
|
private readonly List<Quickchats> Quickchats;
|
||||||
private readonly Random rnd = new Random();
|
private readonly Random rnd = new Random();
|
||||||
private readonly bool QuickChatsEnabled;
|
private bool QuickChatsEnabled;
|
||||||
|
|
||||||
public Quickchat()
|
public Quickchat()
|
||||||
{
|
{
|
||||||
@@ -170,8 +170,9 @@ namespace StarsiegeBot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We're going to build a message.
|
// We're going to build a message.
|
||||||
|
using StreamWriter file = new StreamWriter("tempQC.txt");
|
||||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||||
msg.Content = "";
|
int Content = 0;
|
||||||
// We're going to search each QC for the stuff in toSearch.
|
// We're going to search each QC for the stuff in toSearch.
|
||||||
for (int i = 0; i < Quickchats.Count; i++)
|
for (int i = 0; i < Quickchats.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -179,18 +180,67 @@ namespace StarsiegeBot
|
|||||||
if (Quickchats[i].text.ToLower().Contains(toSearch.ToLower()))
|
if (Quickchats[i].text.ToLower().Contains(toSearch.ToLower()))
|
||||||
{
|
{
|
||||||
// add it to the list!
|
// add it to the list!
|
||||||
msg.Content += $"[{i}] {Quickchats[i].text}\r\n";
|
await file.WriteLineAsync($"[{i}][T] {Quickchats[i].text}\r\n");
|
||||||
|
Content++;
|
||||||
|
}
|
||||||
|
if (Quickchats[i].soundFile.ToLower().Contains(toSearch.ToLower()))
|
||||||
|
{
|
||||||
|
// add it to the list!
|
||||||
|
await file.WriteLineAsync($"[{i}][S] {Quickchats[i].text}\r\n");
|
||||||
|
Content++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file.Close();
|
||||||
|
|
||||||
// If message content is still nothing, report we found nothing.
|
// If message content is still nothing, report we found nothing.
|
||||||
if (msg.Content == "")
|
if (Content == 0)
|
||||||
{
|
{
|
||||||
msg.Content = "No results found.";
|
msg.Content = "No results found.";
|
||||||
|
await ctx.RespondAsync(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Content = "Here are your results.";
|
||||||
|
FileStream upload = new FileStream($"tempQC.txt", FileMode.Open);
|
||||||
|
msg.WithFile(upload);
|
||||||
|
await ctx.RespondAsync(msg);
|
||||||
|
upload.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("toggle"), Aliases("t")]
|
||||||
|
[RequireOwner]
|
||||||
|
public async Task ToggleQC (CommandContext ctx, [RemainingText] string isEnabled = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
isEnabled = isEnabled.ToLower();
|
||||||
|
string output = "";
|
||||||
|
string[] turnOn = { "on", "true", "1" };
|
||||||
|
string[] turnOff = { "off", "false", "0" };
|
||||||
|
|
||||||
|
if (File.Exists("quickchats.json"))
|
||||||
|
{
|
||||||
|
if (turnOn.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
QuickChatsEnabled = true;
|
||||||
|
}
|
||||||
|
else if (turnOff.Contains(isEnabled))
|
||||||
|
{
|
||||||
|
QuickChatsEnabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we wont do anything here.
|
||||||
|
}
|
||||||
|
output = $"Quickchats Enabled: {QuickChatsEnabled}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QuickChatsEnabled = false;
|
||||||
|
output = "QuickChats.json file is missing, and it can not be enabled.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the end user our results, or lack of.
|
await ctx.RespondAsync(output);
|
||||||
await ctx.RespondAsync(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Quickchats
|
public class Quickchats
|
||||||
|
|||||||
Reference in new issue
Block a user