-
Notifications
You must be signed in to change notification settings - Fork 0
Editor Menu
By far the most powerful menu, this one allows you to create a menu with custom options that run custom logic with the purpose of editing a file.
In order to create this menu you first must create a list of EditorOptions. All options in the menu are displayed as embed fields, and thus each editor option has a Name, a body and their logic.
MyClass MyObject;
List<EditorOptions> Options = new List<EditorOptions>();
Options.Add(
new EditorOption("Make it Burpl","Currently not Burble",
async (context) =>
{
((MyClass)Context.EditableObject).Color = Color.Burple;
Context.CurrentOption.Description = "It is now Burple!";
return Context.EditableObject
}
)
);Let's break down what this option does: All options have a name and a description which are displayed as a field inside the menu embed. Then you have the third field, the Logic.
Logic is a function that receives the a special Context class that contains:
- The Command Context of the command being executed
- The Menu Service
- The Current Option listed
- The Index Position of the current option on the menu
- The object being edited
You can do any changes to the object inside the logic, however you must always return the edited object. If you don't return the object the end result will be null.
After you have created your options, you can create an instance of the menu:
EditorMenu Menu = new EditorMenu("Editing MyClass",MyObject,Options);
//You then initialize the menu
await MenuService.CreateMenu(Context,Menu,true);
//Then you await for the finished, edited object
var EditedObject = (MyClass)Menu.GetObject();Home
Types of Menus
Other Tools