Document Formatted all JSON files. Added sub commands Flag and Flag-Count to the QuickChatHandler.cs
This commit is contained in:
1 parent
afca839596
commit
990aca3e41
4 files changed
+193
-21
No files matched your search
@@ -18,7 +18,7 @@ namespace StarsiegeBot
|
|||||||
class BotSettings : BaseCommandModule
|
class BotSettings : BaseCommandModule
|
||||||
{
|
{
|
||||||
public static Dictionary<string, GuildSettings> GuildSettings;
|
public static Dictionary<string, GuildSettings> GuildSettings;
|
||||||
private readonly string fileName = "guildsettings.json";
|
private readonly string fileName = "Json/guildsettings.json";
|
||||||
private readonly CancellationTokenSource cancelToken;
|
private readonly CancellationTokenSource cancelToken;
|
||||||
public BotSettings()
|
public BotSettings()
|
||||||
{
|
{
|
||||||
@@ -127,8 +127,8 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
string output = JsonConvert.SerializeObject(BotSettings.GuildSettings);
|
string output = JsonConvert.SerializeObject(GuildSettings);
|
||||||
await File.WriteAllTextAsync("guildsettings.json", output);
|
await File.WriteAllTextAsync(fileName, output);
|
||||||
await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken);
|
await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken);
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "%sound",
|
"name": "%sound",
|
||||||
"value":"[Optiona Parameter] This part is the sound file (.wav) that you want to play along with the message."
|
"value": "[Optional Parameter] This part is the sound file (.wav) that you want to play along with the message."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -61,11 +61,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "%zRot",
|
"name": "%zRot",
|
||||||
"value":"[Optiona Parameter] What direction the %objectId will end up facing."
|
"value": "[Optional Parameter] What direction the %objectId will end up facing."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "%xRot",
|
"name": "%xRot",
|
||||||
"value":"[Optiona Parameter]"
|
"value": "[Optional Parameter]"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"setteam": {
|
"setteam": {
|
||||||
"title":"reloadObject(%objectId, *IDSTR_TEAM_<TEAM>);",
|
"title": "setteam(%objectId, *IDSTR_TEAM_<TEAM>);",
|
||||||
"description": "Changes the team of the given object.",
|
"description": "Changes the team of the given object.",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1,138 @@
|
|||||||
{"default":{"UseGlobalPrefix":true,"UseSelfRoles":false,"UseLevelRoles":false,"UseLevels":false,"AllowRolesPurchase":false,"UseAutoRoles":false,"Prefixes":["::"],"SelfRoles":{},"LevelRoles":{},"HiddenRolesList":null,"WelcomeChannel":null,"UseWelcome":false,"WelcomeMessage":null},"297873205316681728":{"UseGlobalPrefix":true,"UseSelfRoles":false,"UseLevelRoles":false,"UseLevels":false,"AllowRolesPurchase":false,"UseAutoRoles":false,"Prefixes":[">","::","~"],"SelfRoles":{},"LevelRoles":{},"HiddenRolesList":null,"WelcomeChannel":null,"UseWelcome":false,"WelcomeMessage":null},"376937422010974209":{"UseGlobalPrefix":true,"UseSelfRoles":false,"UseLevelRoles":false,"UseLevels":false,"AllowRolesPurchase":false,"UseAutoRoles":false,"Prefixes":[">"],"SelfRoles":{},"LevelRoles":{},"HiddenRolesList":null,"WelcomeChannel":null,"UseWelcome":false,"WelcomeMessage":null},"768366579468468244":{"UseGlobalPrefix":true,"UseSelfRoles":false,"UseLevelRoles":false,"UseLevels":false,"AllowRolesPurchase":false,"UseAutoRoles":false,"Prefixes":[">"],"SelfRoles":{},"LevelRoles":{},"HiddenRolesList":null,"WelcomeChannel":null,"UseWelcome":false,"WelcomeMessage":null},"831348953097961534":{"UseGlobalPrefix":true,"UseSelfRoles":false,"UseLevelRoles":false,"UseLevels":false,"AllowRolesPurchase":false,"UseAutoRoles":false,"Prefixes":[">","::","~","!","%","^","&","*","(",")","-","_","=","+","[","]","{","}",";",":","<",">",",",".","?"],"SelfRoles":{},"LevelRoles":{},"HiddenRolesList":null,"WelcomeChannel":{"permission_overwrites":[],"guild_id":831348953097961534,"parent_id":831348953097961535,"name":"general","type":0,"position":0,"topic":"","last_message_id":836202598540509245,"bitrate":0,"user_limit":0,"rate_limit_per_user":0,"nsfw":false,"id":831348953097961537},"UseWelcome":true,"WelcomeMessage":"Welcome to channel <#831348953097961537>!"}}
|
{
|
||||||
|
"default": {
|
||||||
|
"UseGlobalPrefix": true,
|
||||||
|
"UseSelfRoles": false,
|
||||||
|
"UseLevelRoles": false,
|
||||||
|
"UseLevels": false,
|
||||||
|
"AllowRolesPurchase": false,
|
||||||
|
"UseAutoRoles": false,
|
||||||
|
"Prefixes": [
|
||||||
|
"::"
|
||||||
|
],
|
||||||
|
"SelfRoles": {
|
||||||
|
},
|
||||||
|
"LevelRoles": {
|
||||||
|
},
|
||||||
|
"HiddenRolesList": null,
|
||||||
|
"WelcomeChannel": null,
|
||||||
|
"UseWelcome": false,
|
||||||
|
"WelcomeMessage": null
|
||||||
|
},
|
||||||
|
"297873205316681728": {
|
||||||
|
"UseGlobalPrefix": true,
|
||||||
|
"UseSelfRoles": false,
|
||||||
|
"UseLevelRoles": false,
|
||||||
|
"UseLevels": false,
|
||||||
|
"AllowRolesPurchase": false,
|
||||||
|
"UseAutoRoles": false,
|
||||||
|
"Prefixes": [
|
||||||
|
">",
|
||||||
|
"::",
|
||||||
|
"~"
|
||||||
|
],
|
||||||
|
"SelfRoles": {
|
||||||
|
},
|
||||||
|
"LevelRoles": {
|
||||||
|
},
|
||||||
|
"HiddenRolesList": null,
|
||||||
|
"WelcomeChannel": null,
|
||||||
|
"UseWelcome": false,
|
||||||
|
"WelcomeMessage": null
|
||||||
|
},
|
||||||
|
"376937422010974209": {
|
||||||
|
"UseGlobalPrefix": true,
|
||||||
|
"UseSelfRoles": false,
|
||||||
|
"UseLevelRoles": false,
|
||||||
|
"UseLevels": false,
|
||||||
|
"AllowRolesPurchase": false,
|
||||||
|
"UseAutoRoles": false,
|
||||||
|
"Prefixes": [
|
||||||
|
">"
|
||||||
|
],
|
||||||
|
"SelfRoles": {
|
||||||
|
},
|
||||||
|
"LevelRoles": {
|
||||||
|
},
|
||||||
|
"HiddenRolesList": null,
|
||||||
|
"WelcomeChannel": null,
|
||||||
|
"UseWelcome": false,
|
||||||
|
"WelcomeMessage": null
|
||||||
|
},
|
||||||
|
"768366579468468244": {
|
||||||
|
"UseGlobalPrefix": true,
|
||||||
|
"UseSelfRoles": false,
|
||||||
|
"UseLevelRoles": false,
|
||||||
|
"UseLevels": false,
|
||||||
|
"AllowRolesPurchase": false,
|
||||||
|
"UseAutoRoles": false,
|
||||||
|
"Prefixes": [
|
||||||
|
">"
|
||||||
|
],
|
||||||
|
"SelfRoles": {
|
||||||
|
},
|
||||||
|
"LevelRoles": {
|
||||||
|
},
|
||||||
|
"HiddenRolesList": null,
|
||||||
|
"WelcomeChannel": null,
|
||||||
|
"UseWelcome": false,
|
||||||
|
"WelcomeMessage": null
|
||||||
|
},
|
||||||
|
"831348953097961534": {
|
||||||
|
"UseGlobalPrefix": true,
|
||||||
|
"UseSelfRoles": false,
|
||||||
|
"UseLevelRoles": false,
|
||||||
|
"UseLevels": false,
|
||||||
|
"AllowRolesPurchase": false,
|
||||||
|
"UseAutoRoles": false,
|
||||||
|
"Prefixes": [
|
||||||
|
">",
|
||||||
|
"::",
|
||||||
|
"~",
|
||||||
|
"!",
|
||||||
|
"%",
|
||||||
|
"^",
|
||||||
|
"&",
|
||||||
|
"*",
|
||||||
|
"(",
|
||||||
|
")",
|
||||||
|
"-",
|
||||||
|
"_",
|
||||||
|
"=",
|
||||||
|
"+",
|
||||||
|
"[",
|
||||||
|
"]",
|
||||||
|
"{",
|
||||||
|
"}",
|
||||||
|
";",
|
||||||
|
":",
|
||||||
|
"<",
|
||||||
|
">",
|
||||||
|
",",
|
||||||
|
".",
|
||||||
|
"?"
|
||||||
|
],
|
||||||
|
"SelfRoles": {
|
||||||
|
},
|
||||||
|
"LevelRoles": {
|
||||||
|
},
|
||||||
|
"HiddenRolesList": null,
|
||||||
|
"WelcomeChannel": {
|
||||||
|
"permission_overwrites": [
|
||||||
|
],
|
||||||
|
"guild_id": 831348953097961534,
|
||||||
|
"parent_id": 831348953097961535,
|
||||||
|
"name": "general",
|
||||||
|
"type": 0,
|
||||||
|
"position": 0,
|
||||||
|
"topic": "",
|
||||||
|
"last_message_id": 836202598540509245,
|
||||||
|
"bitrate": 0,
|
||||||
|
"user_limit": 0,
|
||||||
|
"rate_limit_per_user": 0,
|
||||||
|
"nsfw": false,
|
||||||
|
"id": 831348953097961537
|
||||||
|
},
|
||||||
|
"UseWelcome": true,
|
||||||
|
"WelcomeMessage": "Welcome to channel <#831348953097961537>!"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,7 +113,7 @@ namespace StarsiegeBot
|
|||||||
for (int i = 0; i < quickchats.Count; i++)
|
for (int i = 0; i < quickchats.Count; i++)
|
||||||
{
|
{
|
||||||
// If this file doesnt exist, log the ID in the console, and add to the count.
|
// If this file doesnt exist, log the ID in the console, and add to the count.
|
||||||
if (!File.Exists($"./qc/{quickchats[i.ToString()].soundFile}"))
|
if (!File.Exists($"./qc/{quickchats[i.ToString()].SoundFile}"))
|
||||||
{
|
{
|
||||||
missingFiles++;
|
missingFiles++;
|
||||||
Console.Write($"{i}, ");
|
Console.Write($"{i}, ");
|
||||||
@@ -149,7 +149,7 @@ namespace StarsiegeBot
|
|||||||
id = Math.Abs(id);
|
id = Math.Abs(id);
|
||||||
}
|
}
|
||||||
chat = quickchats[id.ToString()];
|
chat = quickchats[id.ToString()];
|
||||||
output = id + ": " + chat.text;
|
output = id + ": " + chat.Text;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -160,7 +160,7 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
id = Program.rnd.Next(quickchats.Count);
|
id = Program.rnd.Next(quickchats.Count);
|
||||||
chat = quickchats[id.ToString()];
|
chat = quickchats[id.ToString()];
|
||||||
output = $"[{id}] " + chat.text;
|
output = $"[{id}] " + chat.Text;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -172,13 +172,13 @@ namespace StarsiegeBot
|
|||||||
|
|
||||||
// If the sound file to the select QC exists, upload it as well.
|
// If the sound file to the select QC exists, upload it as well.
|
||||||
msg.Embed = StartEmbed(output);
|
msg.Embed = StartEmbed(output);
|
||||||
if (File.Exists($"./qc/{chat.soundFile}"))
|
if (File.Exists($"./qc/{chat.SoundFile}"))
|
||||||
{
|
{
|
||||||
// Open the file.
|
// Open the file.
|
||||||
FileStream sound = new FileStream($"./qc/{chat.soundFile}", FileMode.Open, FileAccess.Read);
|
FileStream sound = new FileStream($"./qc/{chat.SoundFile}", FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
// feed it to the Message Builder.
|
// feed it to the Message Builder.
|
||||||
msg.WithFile(chat.soundFile, sound);
|
msg.WithFile(chat.SoundFile, sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send either the text QC or sound file if we have it
|
// Send either the text QC or sound file if we have it
|
||||||
@@ -210,16 +210,16 @@ namespace StarsiegeBot
|
|||||||
foreach (KeyValuePair<string, Quickchat> qc in quickchats)
|
foreach (KeyValuePair<string, Quickchat> qc in quickchats)
|
||||||
{
|
{
|
||||||
// do we have a match?
|
// do we have a match?
|
||||||
if (qc.Value.text.ToLower().Contains(toSearch.ToLower()))
|
if (qc.Value.Text.ToLower().Contains(toSearch.ToLower()))
|
||||||
{
|
{
|
||||||
// add it to the list!
|
// add it to the list!
|
||||||
sb.Append($"[{qc.Key}][T] {quickchats[qc.Key].text}\r\n");
|
sb.Append($"[{qc.Key}][T] {quickchats[qc.Key].Text}\r\n");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (qc.Value.soundFile.ToLower().Contains(toSearch.ToLower()))
|
if (qc.Value.SoundFile.ToLower().Contains(toSearch.ToLower()))
|
||||||
{
|
{
|
||||||
// add it to the list!
|
// add it to the list!
|
||||||
sb.Append($"[{qc.Key}][S] {quickchats[qc.Key].text}\r\n");
|
sb.Append($"[{qc.Key}][S] {quickchats[qc.Key].Text}\r\n");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,6 +241,37 @@ namespace StarsiegeBot
|
|||||||
await ctx.RespondAsync(msg);
|
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 flagRerason = "")
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
Quickchat chat = quickchats[id.ToString()];
|
||||||
|
DiscordEmbedBuilder embed;
|
||||||
|
chat.FlagCount++;
|
||||||
|
embed = StartEmbed($"Flagging QC ID `{id}` with reason of `{flagRerason}`. (F{chat.FlagCount})");
|
||||||
|
chat.IsFlagged = true;
|
||||||
|
string output = JsonConvert.SerializeObject(quickchats);
|
||||||
|
await File.WriteAllTextAsync(fileName, output);
|
||||||
|
await ctx.RespondAsync(embed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("flag-count")]
|
||||||
|
public async Task FlagCount(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
int count = 0;
|
||||||
|
foreach (var chat in quickchats)
|
||||||
|
{
|
||||||
|
if (chat.Value.IsFlagged)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await ctx.RespondAsync(StartEmbed($"There are {count} flagged Quick Chats."));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Command("toggle"), Aliases("t")]
|
[Command("toggle"), Aliases("t")]
|
||||||
[RequireOwner]
|
[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`")]
|
[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`")]
|
||||||
@@ -286,11 +317,15 @@ namespace StarsiegeBot
|
|||||||
|
|
||||||
public class Quickchat
|
public class Quickchat
|
||||||
{
|
{
|
||||||
public string text;
|
[JsonProperty("text")]
|
||||||
public string soundFile;
|
public string Text { get; protected set; }
|
||||||
|
[JsonProperty("soundFile")]
|
||||||
|
public string SoundFile { get; protected set; }
|
||||||
|
public bool IsFlagged { get; set; }
|
||||||
|
public int FlagCount { get; set; }
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"say(0,0, \"{text}\", \"{soundFile}\");";
|
return $"say(0,0, \"{Text}\", \"{SoundFile}\");";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user