Merge branch 'main' of https://github.com/cmd276/DiscordBot into main
This commit is contained in:
commit
f5c21ef51b
1 file changed
+31
-20
@@ -23,12 +23,12 @@ namespace StarsiegeBot
|
|||||||
class QuickchatHandler : BaseCommandModule
|
class QuickchatHandler : BaseCommandModule
|
||||||
{
|
{
|
||||||
private Dictionary<string, Quickchat> quickchats;
|
private Dictionary<string, Quickchat> quickchats;
|
||||||
private bool IsQuickChatEnabled;
|
private bool IsEnabled;
|
||||||
|
|
||||||
public QuickchatHandler()
|
public QuickchatHandler()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Quick Chat Handler Loaded");
|
Console.WriteLine("Quick Chat Handler Loaded");
|
||||||
IsQuickChatEnabled = LoadQuickChatsImpl();
|
IsEnabled = LoadQuickChatsImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,10 +44,8 @@ namespace StarsiegeBot
|
|||||||
var json = "";
|
var json = "";
|
||||||
using (var fs = File.OpenRead("quickchats.json"))
|
using (var fs = File.OpenRead("quickchats.json"))
|
||||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||||
|
|
||||||
json = sr.ReadToEnd();
|
json = sr.ReadToEnd();
|
||||||
quickchats = JsonConvert.DeserializeObject<Dictionary<string, Quickchat>>(json);
|
quickchats = JsonConvert.DeserializeObject<Dictionary<string, Quickchat>>(json);
|
||||||
|
|
||||||
// enable the commands.
|
// enable the commands.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -62,15 +60,22 @@ namespace StarsiegeBot
|
|||||||
public async Task LoadQuickChats(CommandContext ctx)
|
public async Task LoadQuickChats(CommandContext ctx)
|
||||||
{
|
{
|
||||||
await ctx.TriggerTypingAsync();
|
await ctx.TriggerTypingAsync();
|
||||||
|
string output;
|
||||||
IsQuickChatEnabled = LoadQuickChatsImpl();
|
IsEnabled = LoadQuickChatsImpl();
|
||||||
if (IsQuickChatEnabled)
|
if (IsEnabled)
|
||||||
{
|
{
|
||||||
await ctx.RespondAsync("Loading Quick Chats successful.");
|
output = "Loading Quick Chats successful.";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
await ctx.RespondAsync("Loading Quick Chats failed. File does not exist.");
|
{
|
||||||
|
output = "Loading Quick Chats failed. File does not exist.";
|
||||||
|
}
|
||||||
|
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||||
|
{
|
||||||
|
Description = output,
|
||||||
|
Color = Program.colours[Program.rnd.Next(0, Program.colours.Length)]
|
||||||
|
};
|
||||||
|
await ctx.RespondAsync(embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("script")]
|
[Command("script")]
|
||||||
@@ -81,7 +86,7 @@ namespace StarsiegeBot
|
|||||||
await ctx.TriggerTypingAsync();
|
await ctx.TriggerTypingAsync();
|
||||||
|
|
||||||
// If we're disabled, let them know. And exit out.
|
// If we're disabled, let them know. And exit out.
|
||||||
if (!IsQuickChatEnabled)
|
if (!IsEnabled)
|
||||||
{
|
{
|
||||||
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
||||||
return;
|
return;
|
||||||
@@ -109,7 +114,7 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
await ctx.TriggerTypingAsync();
|
await ctx.TriggerTypingAsync();
|
||||||
// If we're disabled, let them know. And exit out.
|
// If we're disabled, let them know. And exit out.
|
||||||
if (!IsQuickChatEnabled)
|
if (!IsEnabled)
|
||||||
{
|
{
|
||||||
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
||||||
return;
|
return;
|
||||||
@@ -128,7 +133,13 @@ namespace StarsiegeBot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reply to the message and let the user know we're missing X files.
|
// Reply to the message and let the user know we're missing X files.
|
||||||
await ctx.RespondAsync($"Missing files: {missingFiles}");
|
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||||
|
{
|
||||||
|
Description = $"Missing files: {missingFiles}",
|
||||||
|
Color = Program.colours[Program.rnd.Next(0, Program.colours.Length)]
|
||||||
|
};
|
||||||
|
|
||||||
|
await ctx.RespondAsync(embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
[GroupCommand]
|
[GroupCommand]
|
||||||
@@ -139,7 +150,7 @@ namespace StarsiegeBot
|
|||||||
string output;
|
string output;
|
||||||
|
|
||||||
// If we're disabled, let them know. And exit out.
|
// If we're disabled, let them know. And exit out.
|
||||||
if (!IsQuickChatEnabled)
|
if (!IsEnabled)
|
||||||
{
|
{
|
||||||
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
||||||
return;
|
return;
|
||||||
@@ -202,7 +213,7 @@ namespace StarsiegeBot
|
|||||||
string output;
|
string output;
|
||||||
|
|
||||||
// If we're disabled, let them know. And exit out.
|
// If we're disabled, let them know. And exit out.
|
||||||
if (!IsQuickChatEnabled)
|
if (!IsEnabled)
|
||||||
{
|
{
|
||||||
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
||||||
return;
|
return;
|
||||||
@@ -263,18 +274,18 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
if (turnOn.Contains(isEnabled))
|
if (turnOn.Contains(isEnabled))
|
||||||
{
|
{
|
||||||
IsQuickChatEnabled = true;
|
IsEnabled = true;
|
||||||
}
|
}
|
||||||
if (turnOff.Contains(isEnabled))
|
if (turnOff.Contains(isEnabled))
|
||||||
{
|
{
|
||||||
IsQuickChatEnabled = false;
|
IsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = $"Quickchats {(IsQuickChatEnabled ? "Enabled":"Disabled")}";
|
output = $"Quickchats {(IsEnabled ? "Enabled":"Disabled")}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IsQuickChatEnabled = false;
|
IsEnabled = false;
|
||||||
output = "QuickChats.json file is missing, and it can not be enabled.";
|
output = "QuickChats.json file is missing, and it can not be enabled.";
|
||||||
}
|
}
|
||||||
await ctx.RespondAsync(output);
|
await ctx.RespondAsync(output);
|
||||||
|
|||||||
Reference in new issue
Block a user