From 1ea06e064c70b013a59f195240d7234cc7389f13 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 18 Jul 2024 11:56:13 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20documentation=20for=20cont?= =?UTF-8?q?ext=20menus=20(Fixes=20#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/docs/context-menus.md | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 content/docs/context-menus.md diff --git a/content/docs/context-menus.md b/content/docs/context-menus.md new file mode 100644 index 0000000..d9269c8 --- /dev/null +++ b/content/docs/context-menus.md @@ -0,0 +1,85 @@ +--- +slug: context-menus +title: 'Context Menus' +description: 'Allow interacting with your Discord bot using context menus.' +priority: 3 +group: Usage +--- + +Context menus are similar to slash commands, but are instead shown under `Apps` when right clicking/tapping a user or message. + +Unlike slash commands, context menus do not contain options or subcommands. + +## Creating a Context Menu + +Creating your first context menu can be done using the `make:menu` command: + +```sh +$ php laracord make:menu ExampleMenu +``` + +A context menu in it's simplest form will look something like: + +```php +respondWithMessage( + $this + ->message() + ->title('Example Menu') + ->content('Hello world!') + ->build() + ); + } +} +``` + +### Context Menu Types + +By default, the context menu will be shown when right-clicking a **message**. To have it shown when right-clicking a **user** instead, simply change `$type` to `user`: + +```php +/** + * The context menu type. + */ +protected string|int $type = 'user'; +``` + +### Guild Context Menus + +To only register a context menu to a specific guild/server, you may set the `$guild` property: + +```php +/** + * The guild the context menu belongs to. + * + * @var string + */ +protected $guild = 'your-guild-id'; +```