Skip to content

Commit

Permalink
Add internal command /printEditCommands
Browse files Browse the repository at this point in the history
  • Loading branch information
jnccd committed Feb 19, 2024
1 parent a9ebd6c commit 5251101
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions MEE7-Discord-Bot/Backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Discord.WebSocket;
using MEE7.Backend;
using MEE7.Backend.HelperFunctions;
using MEE7.Commands.Edit;
using MEE7.Configuration;
using NAudio.Wave;
using System;
Expand Down Expand Up @@ -523,7 +524,7 @@ static void HandleConsoleCommandsLoop()
{
ConsoleWrapper.WriteLine(e, ConsoleColor.Red);
}
}
}
else if (!input.StartsWith("/"))
{
if (CurrentChannel == null)
Expand Down Expand Up @@ -721,13 +722,20 @@ static void HandleConsoleCommandsLoop()
{
try
{
//ConsoleWrapper.WriteLine(commandTypes[0].GetConstructor(new Type[] { typeof(string), typeof(string), typeof(bool), typeof(bool) }).GetCustomAttributes(true).Length , ConsoleColor.Cyan);
ConsoleWrapper.WriteLine("Command | Description\n" +
"---------------|--------------\n" +
commands.Select(x => $"{x.CommandLine} | {x.Desc}").Combine("\n"), ConsoleColor.Cyan);
}
catch (Exception e) { ConsoleWrapper.WriteLine(e.ToString(), ConsoleColor.Red); }
}
else if (input.StartsWith("/printEditCommands"))
{
try
{
ConsoleWrapper.WriteLine(Edit.EditCommandsOverview, ConsoleColor.Cyan);
}
catch (Exception e) { ConsoleWrapper.WriteLine(e.ToString(), ConsoleColor.Red); }
}
else
ConsoleWrapper.WriteLine("I dont know that command.", ConsoleColor.Red);
}
Expand Down
2 changes: 1 addition & 1 deletion MEE7-Discord-Bot/BuildDate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.02.2024 20:56:19,60
20.02.2024 0:10:05,13
8 changes: 7 additions & 1 deletion MEE7-Discord-Bot/Commands/Edit/Backend/Edit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ public class EditVariable { public string VarName; }

private static IEnumerable<EditCommand> Commands;
private static Dictionary<string, EmbedBuilder> groupHelpMenus = new Dictionary<string, EmbedBuilder>();
public static string EditCommandsOverview { get; private set; }

public Edit() : base("edit", "This is a little more advanced command which allows you to chain together functions that were made specific for this command. " +
public Edit() : base("edit", "This is a more advanced command which allows you to chain together functions that were made specific for this command. " +
$"Shortcut: **{Program.Prefix}-**\nFor more information just type **{Program.Prefix}edit**.")
{
Commands = new List<EditCommand>();
Expand All @@ -172,6 +173,7 @@ public class EditVariable { public string VarName; }
$"\neg. {PrefixAndCommand} \"omegaLUL\" > swedish > Aestheticify\n" +
$"\nIf you want to find more commands you can write \"{PrefixAndCommand} help [groupName]\"" +
"The following command groups are currently loaded:");
EditCommandsOverview = "";

// Load Functions
Type[] classesWithEditCommands = (from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
Expand Down Expand Up @@ -274,6 +276,10 @@ void AddToHelpmenus(string Name, EditCommand[] editCommands)
$"{new string(Enumerable.Repeat(' ', maxlength - c.Command.Length - 1).ToArray())}{c.Desc}\n").
Combine() + "");
}
EditCommandsOverview += $"{Name} | Description\n" +
$"-------|--------------\n" +
editCommands.Select(x => $"{x.Command} | {x.Desc}").Combine("\n") +
"\n\n";
}
public override void Execute(IMessage message)
{
Expand Down

0 comments on commit 5251101

Please sign in to comment.