Removed extra spaces. Removed double \r\n across all code files.
This commit is contained in:
1 parent
91d6d1531b
commit
5bb1b43e81
19 files changed
+68
-389
No files matched your search
@@ -10,19 +10,16 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
|
||||
[Group("deathmessage"), Aliases("dm")]
|
||||
[Description("Gives a random death message. Or interacts with the death messages.")]
|
||||
[Cooldown(1, 2, CooldownBucketType.Guild)]
|
||||
class DeathMessages : BaseCommandModule
|
||||
{
|
||||
private DeathMessageLines _dmLines;
|
||||
private bool _deathMessagesEnabled;
|
||||
private bool _isEnabled;
|
||||
private static readonly string s_fileName = "Json/deathmessages.json";
|
||||
|
||||
public DeathMessages()
|
||||
{
|
||||
Console.WriteLine("Death Message Commands Loaded.");
|
||||
@@ -38,21 +35,19 @@ namespace StarsiegeBot
|
||||
// Decode the JSON and set it to dmLines.
|
||||
_dmLines = JsonConvert.DeserializeObject<DeathMessageLines>(json);
|
||||
// Enable all the commands.
|
||||
_deathMessagesEnabled = true;
|
||||
_isEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Echo out that we're missing a file. Disable the commands due to that.
|
||||
Console.WriteLine($" --- --- --- --- {s_fileName} is missing");
|
||||
_deathMessagesEnabled = false;
|
||||
_isEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
[Command("load")]
|
||||
[RequireOwner]
|
||||
public async Task LoadDeathMessages(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
// set some JSON text to blank.
|
||||
@@ -63,68 +58,56 @@ namespace StarsiegeBot
|
||||
// Decode the JSON and set it to dmLines.
|
||||
_dmLines = JsonConvert.DeserializeObject<DeathMessageLines>(json);
|
||||
// Enable all the commands.
|
||||
_deathMessagesEnabled = true;
|
||||
_isEnabled = true;
|
||||
await ctx.RespondAsync("Loading Death Messages successul.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Echo out that we're missing a file. Disable the commands due to that.
|
||||
await ctx.RespondAsync("Can't load Death Messages. File missing.");
|
||||
_deathMessagesEnabled = false;
|
||||
_isEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
[Command("toggle"), Aliases("t")]
|
||||
[RequireOwner]
|
||||
public async Task ToggleDM(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(s_fileName))
|
||||
{
|
||||
if (turnOn.Contains(isEnabled))
|
||||
{
|
||||
_deathMessagesEnabled = true;
|
||||
_isEnabled = true;
|
||||
}
|
||||
else if (turnOff.Contains(isEnabled))
|
||||
{
|
||||
_deathMessagesEnabled = false;
|
||||
_isEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
output = $"DeathMessages Enabled: {_deathMessagesEnabled}";
|
||||
output = $"DeathMessages Enabled: {_isEnabled}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_deathMessagesEnabled = false;
|
||||
_isEnabled = false;
|
||||
output = $"{s_fileName} file is missing, and it can not be enabled.";
|
||||
}
|
||||
await ctx.RespondAsync(output);
|
||||
}
|
||||
|
||||
[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)
|
||||
{
|
||||
// We're typing! (In all honesty, this is just used to avoid the 'async task not using await' messages I get.
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// IF we're missing the Death Messages dot JSON file, we're going to get disabled... Check for that.
|
||||
// If disabled, let the person know the command set is disabled, and return.
|
||||
if (!_deathMessagesEnabled)
|
||||
if (!_isEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Death Messages Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set some basic output incase something goes south.
|
||||
string line = "Something went wrong.";
|
||||
// if there is no target, we're going to "kill" the author.
|
||||
@@ -156,24 +139,21 @@ namespace StarsiegeBot
|
||||
await ctx.RespondAsync(string.Format(line, ctx.Message.Author.Mention, target.Mention));
|
||||
}
|
||||
}
|
||||
|
||||
[Command("inventory"), Aliases("count")]
|
||||
[Description("Gets the total of each type of death message")]
|
||||
public async Task DeathMessageCount(CommandContext ctx)
|
||||
{
|
||||
// IF we're missing the Death Messages dot JSON file, we're going to get disabled... Check for that.
|
||||
// If disabled, let the person know the command set is disabled, and return.
|
||||
if (!_deathMessagesEnabled)
|
||||
if (!_isEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Death Messages Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
// We're typing here!
|
||||
await ctx.TriggerTypingAsync();
|
||||
// List all the types of Death Message types, and how many we have of each one.
|
||||
await ctx.RespondAsync($"\r\nActive: {_dmLines.Active.Length}\r\nPassive: {_dmLines.Passive.Length}\r\nGeneric: {_dmLines.Generic.Length}");
|
||||
}
|
||||
|
||||
[Command("Add")]
|
||||
[Description("Adds a message to the Pending Death Message Queue. Generic Death Messages require just a [Killed] while any other death message requires both a [Killed] and a [Killer] tags. These will be replaced with the correct information in game, and in the usage of random DM generation.")]
|
||||
[Cooldown(1, 2, CooldownBucketType.Guild)]
|
||||
@@ -181,15 +161,13 @@ namespace StarsiegeBot
|
||||
{
|
||||
// IF we're missing the Death Messages dot JSON file, we're going to get disabled... Check for that.
|
||||
// If disabled, let the person know the command set is disabled, and return.
|
||||
if (!_deathMessagesEnabled)
|
||||
if (!_isEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Death Messages Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
// Let Discord know we're typing.
|
||||
await ctx.TriggerTypingAsync();
|
||||
// Message the owner know some one wants to add a new death message, along with a code block to that message.
|
||||
|
||||
// if the Queue is null, make it exist.
|
||||
if (_dmLines.Queue is null)
|
||||
_dmLines.Queue = new List<string>();
|
||||
@@ -200,34 +178,28 @@ namespace StarsiegeBot
|
||||
// Tell the person that the message has been added to a 'queue'.
|
||||
await ctx.RespondAsync("Your request has been added to the pending queue of requests.");
|
||||
}
|
||||
|
||||
[Command("script")]
|
||||
[Description("Gets a script file for all the death messages on the bot.")]
|
||||
public async Task DeathMessagesScript(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
// IF we're missing the Death Messages dot JSON file, we're going to get disabled... Check for that.
|
||||
// If disabled, let the person know the command set is disabled, and return.
|
||||
if (!_deathMessagesEnabled)
|
||||
if (!_isEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Death Messages Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If this file exists... We could do one of two things. Delete it and remake it, or serve it up.
|
||||
if (File.Exists("deathmessages.cs"))
|
||||
{
|
||||
File.Delete("deathmessages.cs");
|
||||
}
|
||||
|
||||
// We're going to remake it. Open it.
|
||||
// We're going to remake it. Open it.
|
||||
using StreamWriter file = new StreamWriter("deathmessages.cs");
|
||||
|
||||
// Write out the total lines for each. Requirement for Starsiege.
|
||||
await file.WriteLineAsync($"$deathMessage::genericCount = {_dmLines.Generic.Length};");
|
||||
await file.WriteLineAsync($"$deathMessage::activeCount = {_dmLines.Active.Length};");
|
||||
await file.WriteLineAsync($"$deathMessage::passiveCount = {_dmLines.Passive.Length};\r\n");
|
||||
|
||||
// Set count to 0. Iterate over each type of Death Message, and put it into the file.
|
||||
int count = 0;
|
||||
foreach (string death in _dmLines.Generic)
|
||||
@@ -249,10 +221,8 @@ namespace StarsiegeBot
|
||||
await file.WriteLineAsync(string.Format($"$deathMessage::passive{count} = \"{death}\";", "%s", "%s"));
|
||||
count++;
|
||||
}
|
||||
|
||||
// We're done writing to it... So close the file.
|
||||
file.Close();
|
||||
|
||||
// We're going to Message Build the response.
|
||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||
// Open the file to upload.
|
||||
@@ -266,7 +236,6 @@ namespace StarsiegeBot
|
||||
// We're done with the file, so close access to it.
|
||||
sound.Close();
|
||||
}
|
||||
|
||||
private async Task StoreDeathMessages()
|
||||
{
|
||||
string output = JsonConvert.SerializeObject(_dmLines);
|
||||
|
||||
@@ -10,7 +10,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("functions"), Aliases("func")]
|
||||
@@ -22,7 +21,6 @@ namespace StarsiegeBot
|
||||
public Functions()
|
||||
{
|
||||
Console.WriteLine("Starsiege Function Commands Loaded");
|
||||
|
||||
// Check for file, if not there, disable commands.
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
@@ -40,19 +38,16 @@ namespace StarsiegeBot
|
||||
Console.WriteLine(" --- --- --- Functions JSON not found.");
|
||||
}
|
||||
}
|
||||
|
||||
[GroupCommand]
|
||||
[Description("Gives information on desired function.")]
|
||||
public async Task StarsiegeFunctions(CommandContext ctx, [RemainingText, Description("The function to attempt to look up.")] string command = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
if (!_functionsEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Function Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If the function command is empty make a list of commands in Starsiege.
|
||||
// If the function command is empty make a list of commands in Starsiege.
|
||||
if (command.Equals(string.Empty))
|
||||
{
|
||||
// Get a list of the Keys.
|
||||
@@ -76,7 +71,6 @@ namespace StarsiegeBot
|
||||
// send the output.
|
||||
await ctx.RespondAsync("List of known Functions in Starsiege: " + output);
|
||||
}
|
||||
|
||||
// we have a command the want to try to find.
|
||||
else if (_ssFunctions.TryGetValue(command.ToLower(), out SSFunction outItem))
|
||||
{
|
||||
@@ -106,12 +100,9 @@ namespace StarsiegeBot
|
||||
await ctx.RespondAsync("That command wasn't food, pot-head.");
|
||||
}
|
||||
}
|
||||
|
||||
[Command("count")]
|
||||
public async Task FunctionCount(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// check ot make sure these commands are enabled. if disabled, report it.
|
||||
if (!_functionsEnabled)
|
||||
{
|
||||
@@ -121,20 +112,14 @@ namespace StarsiegeBot
|
||||
// they wanted to know how many functions were documented... so tell them!
|
||||
await ctx.RespondAsync($"There are {_ssFunctions.Count} functions in the known list.");
|
||||
}
|
||||
|
||||
[Command("toggle"), Aliases("t")]
|
||||
[RequireOwner]
|
||||
public async Task ToggleFunctions(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(s_fileName))
|
||||
{
|
||||
if (turnOn.Contains(isEnabled))
|
||||
@@ -147,7 +132,6 @@ namespace StarsiegeBot
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
output = $"Functions Enabled: {_functionsEnabled}";
|
||||
}
|
||||
@@ -161,8 +145,6 @@ namespace StarsiegeBot
|
||||
[Command("load"), RequireOwner]
|
||||
public async Task LoadFunctions(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// Check for file, if not there, disable commands.
|
||||
if (File.Exists(s_fileName))
|
||||
{
|
||||
@@ -182,14 +164,12 @@ namespace StarsiegeBot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SSFunction
|
||||
{
|
||||
public string name;
|
||||
public string title;
|
||||
public string description;
|
||||
public Fields[] fields;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string fs = "";
|
||||
@@ -197,8 +177,6 @@ namespace StarsiegeBot
|
||||
{
|
||||
fs += $"[{field}] ";
|
||||
}
|
||||
|
||||
|
||||
return $"Name: {name} || Title: {title} || Desc: {description} || Fields: {{{fs}}}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Group("servers")]
|
||||
@@ -42,7 +41,6 @@ namespace StarsiegeBot
|
||||
[GroupCommand]
|
||||
public async Task Overview(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
Update();
|
||||
// setup an exit point check.
|
||||
bool exit = false;
|
||||
@@ -65,12 +63,10 @@ namespace StarsiegeBot
|
||||
embed.AddField("Errors", _gameData.Errors.Length.ToString(), true);
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("Errors"), Aliases("e")]
|
||||
[Description("Lists all the errors from the server listing.")]
|
||||
public async Task ErrorsServer(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
Update();
|
||||
// setup an exit point check.
|
||||
bool exit = false;
|
||||
@@ -93,12 +89,10 @@ namespace StarsiegeBot
|
||||
}
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
|
||||
[Command("Masters"), Aliases("m")]
|
||||
[Description("Gives all the master servers as a script to be improted into `master.cs`.")]
|
||||
public async Task MasterServers(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
Update();
|
||||
// setup an exit point check.
|
||||
bool exit = false;
|
||||
@@ -124,12 +118,10 @@ namespace StarsiegeBot
|
||||
msg.Content += "```";
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
|
||||
[Command("games"), Aliases("g")]
|
||||
[Description("Currently: Lists games that have been started (Player dropped in). End Result: Lists all games that have a player in the server (either dropped in or not)")]
|
||||
public async Task GameServers(CommandContext ctx, [Description("Number of players you want to check for. Game servers will need at least this meaning or more to be listed.")] int playerCount = 1)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
Update();
|
||||
playerCount = Math.Abs(playerCount);
|
||||
// setup an exit point check.
|
||||
@@ -174,7 +166,6 @@ namespace StarsiegeBot
|
||||
[JsonProperty("games")]
|
||||
public GameServer[] Games { get; private set; }
|
||||
}
|
||||
|
||||
class MasterServer
|
||||
{
|
||||
[JsonProperty("address")]
|
||||
@@ -188,7 +179,6 @@ namespace StarsiegeBot
|
||||
[JsonProperty("Ping")]
|
||||
public int Ping { get; private set; }
|
||||
}
|
||||
|
||||
class GameServer
|
||||
{
|
||||
[JsonProperty("GameName")]
|
||||
|
||||
@@ -10,7 +10,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StarsiegeBot
|
||||
{
|
||||
[Aliases("qc"), Group("quickchat")]
|
||||
@@ -19,14 +18,11 @@ namespace StarsiegeBot
|
||||
private Dictionary<string, Quickchat> _quickchats;
|
||||
private bool _isEnabled;
|
||||
private static readonly string s_fileName = "Json/quickchats.json";
|
||||
|
||||
|
||||
public QuickchatHandler()
|
||||
{
|
||||
Console.WriteLine("Quick Chat Handler Loaded");
|
||||
_isEnabled = LoadQuickChatsImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* LoadQuickChatsImpl loads the quickchats.json file from the current path,
|
||||
* parses the file, and populates the private quickchats dictionary.
|
||||
@@ -45,17 +41,14 @@ namespace StarsiegeBot
|
||||
// enable the commands.
|
||||
return true;
|
||||
}
|
||||
|
||||
// else, file not found. disable commands, leave a comment in console.
|
||||
Console.WriteLine(" -- --- --- Quick Chat JSON file not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
[Command("load"), RequireOwner]
|
||||
[Description("[Owner Only] Reloads the QuickChat files, if they exist. Also enables QC's if the file is found.")]
|
||||
public async Task LoadQuickChats(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string output;
|
||||
_isEnabled = LoadQuickChatsImpl();
|
||||
if (_isEnabled)
|
||||
@@ -68,7 +61,6 @@ namespace StarsiegeBot
|
||||
}
|
||||
await ctx.RespondAsync(StartEmbed(output));
|
||||
}
|
||||
|
||||
[Command("script")]
|
||||
[Description("Gives the `say()` for use in the Quickchat.cs file.")]
|
||||
public async Task GetQuickChatScript(CommandContext ctx, [Description("ID of Quick chat to get script for.")] int index)
|
||||
@@ -79,11 +71,8 @@ namespace StarsiegeBot
|
||||
return;
|
||||
}
|
||||
// trigger some typing on discord's side.
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// We're good to go... If we have an index, pull it up.
|
||||
index = Math.Abs(index);
|
||||
|
||||
// is our index within bounds?
|
||||
if (index < _quickchats.Count)
|
||||
{
|
||||
@@ -92,11 +81,9 @@ namespace StarsiegeBot
|
||||
await ctx.RespondAsync("```" + chat.ToString() + "```");
|
||||
return;
|
||||
}
|
||||
|
||||
// we couldn't find it... Oh well, let the end user know.
|
||||
await ctx.RespondAsync("The ID specified is out of bounds. 0-" + (_quickchats.Count - 1));
|
||||
}
|
||||
|
||||
[Command("check")]
|
||||
[Description("Runs a check to see how many WAV files are missing from all QC's.")]
|
||||
public async Task QuickChatCheck(CommandContext ctx)
|
||||
@@ -106,9 +93,7 @@ namespace StarsiegeBot
|
||||
{
|
||||
return;
|
||||
}
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// Start a count
|
||||
// Start a count
|
||||
int missingFiles = 0;
|
||||
for (int i = 0; i < _quickchats.Count; i++)
|
||||
{
|
||||
@@ -119,11 +104,9 @@ namespace StarsiegeBot
|
||||
Console.Write($"{i}, ");
|
||||
}
|
||||
}
|
||||
|
||||
// Reply to the message and let the user know we're missing X files.
|
||||
await ctx.RespondAsync(StartEmbed($"Missing files: {missingFiles}"));
|
||||
}
|
||||
|
||||
[GroupCommand]
|
||||
[Description("Gives a specific or random Quickchat. If that QC has a sound file that the bot knows, uploads the sound file too.")]
|
||||
public async Task QuickChat(CommandContext ctx, [Description("The ID of the quick Chat.")] int id = -1)
|
||||
@@ -133,14 +116,10 @@ namespace StarsiegeBot
|
||||
{
|
||||
return;
|
||||
}
|
||||
await ctx.TriggerTypingAsync();
|
||||
string output;
|
||||
|
||||
|
||||
// Start a new Message Build.
|
||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||
Quickchat chat;
|
||||
|
||||
// try to get the quick chat, if it doesn't exist, return a random one
|
||||
try
|
||||
{
|
||||
@@ -169,43 +148,35 @@ namespace StarsiegeBot
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the sound file to the select QC exists, upload it as well.
|
||||
msg.Embed = StartEmbed(output);
|
||||
if (File.Exists($"./qc/{chat.SoundFile}"))
|
||||
{
|
||||
// Open the file.
|
||||
FileStream sound = new FileStream($"./qc/{chat.SoundFile}", FileMode.Open, FileAccess.Read);
|
||||
|
||||
// feed it to the Message Builder.
|
||||
msg.WithFile(chat.SoundFile, sound);
|
||||
}
|
||||
|
||||
// Send either the text QC or sound file if we have it
|
||||
// msg.Content = output;
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
|
||||
[Command("search"), Aliases("s")]
|
||||
[Cooldown(1, 5, CooldownBucketType.Global)]
|
||||
[Description("Searches all the [T]ext and [S]ound file names for the Search input.")]
|
||||
public async Task SearchQuickChats(CommandContext ctx, [RemainingText, Description("What to search for.")] string toSearch)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
string output;
|
||||
|
||||
// If we're disabled, let them know. And exit out.
|
||||
if (!_isEnabled)
|
||||
{
|
||||
await ctx.RespondAsync("Quick Chat Commands have been disabled. Please contact the bot owners.");
|
||||
return;
|
||||
}
|
||||
|
||||
// We're going to build a message.
|
||||
StringBuilder sb = new StringBuilder();
|
||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||
int count = 0;
|
||||
|
||||
// We're going to search each QC for the stuff in toSearch.
|
||||
foreach (KeyValuePair<string, Quickchat> qc in _quickchats)
|
||||
{
|
||||
@@ -223,7 +194,6 @@ namespace StarsiegeBot
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a message return it
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
@@ -236,20 +206,15 @@ namespace StarsiegeBot
|
||||
// If message content is still nothing, report we found nothing.
|
||||
output = $"Sorry {ctx.Member.Mention}, no results were found for `{toSearch}`.";
|
||||
}
|
||||
|
||||
msg.Content = output;
|
||||
await ctx.RespondAsync(msg);
|
||||
}
|
||||
|
||||
[Command("flag")]
|
||||
[Description("Flags a Quick Chat for moderator checking.")]
|
||||
public async Task FlagQC(CommandContext ctx, [Description("ID of QC to flag.")] int id, [RemainingText, Description("The reason you believe it needs flagged.")] string flagReason = "")
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
Quickchat chat = _quickchats[id.ToString()];
|
||||
DiscordEmbedBuilder embed;
|
||||
|
||||
|
||||
foreach (FlagEvent item in chat.Flags)
|
||||
{
|
||||
if (item.UserId == ctx.Member.Id)
|
||||
@@ -273,14 +238,11 @@ namespace StarsiegeBot
|
||||
chat.IsFlagged = true;
|
||||
string output = JsonConvert.SerializeObject(_quickchats);
|
||||
await File.WriteAllTextAsync(s_fileName, output);
|
||||
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
|
||||
[Command("flag-count")]
|
||||
public async Task FlagCount(CommandContext ctx)
|
||||
{
|
||||
await ctx.TriggerTypingAsync();
|
||||
int count = 0;
|
||||
foreach (KeyValuePair<string, Quickchat> chat in _quickchats)
|
||||
{
|
||||
@@ -291,18 +253,15 @@ namespace StarsiegeBot
|
||||
}
|
||||
await ctx.RespondAsync(StartEmbed($"There are {count} flagged Quick Chats."));
|
||||
}
|
||||
|
||||
[Command("toggle"), Aliases("t")]
|
||||
[RequireOwner]
|
||||
[Description("[Owner only] Enables or disables, or checks status of QuickChats.\r\nTo turn the feature on, use `TRUE`, `ON`, or `1`\r\nTo turn off, use `FALSE`, `OFF`, or `0`")]
|
||||
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(s_fileName))
|
||||
{
|
||||
if (turnOn.Contains(isEnabled))
|
||||
@@ -313,7 +272,6 @@ namespace StarsiegeBot
|
||||
{
|
||||
_isEnabled = false;
|
||||
}
|
||||
|
||||
output = $"Quickchats {(_isEnabled ? "Enabled" : "Disabled")}";
|
||||
}
|
||||
else
|
||||
@@ -323,7 +281,6 @@ namespace StarsiegeBot
|
||||
}
|
||||
await ctx.RespondAsync(StartEmbed(output));
|
||||
}
|
||||
|
||||
private DiscordEmbedBuilder StartEmbed(string description)
|
||||
{
|
||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||
@@ -334,7 +291,6 @@ namespace StarsiegeBot
|
||||
return embed;
|
||||
}
|
||||
}
|
||||
|
||||
public class Quickchat
|
||||
{
|
||||
[JsonProperty("text")]
|
||||
@@ -354,7 +310,6 @@ namespace StarsiegeBot
|
||||
public ulong UserId { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public string Timestamp { get; set; }
|
||||
|
||||
public FlagEvent(ulong UserId, string Reason, string Timestamp)
|
||||
{
|
||||
this.UserId = UserId;
|
||||
|
||||
Reference in new issue
Block a user