Browse Source

Fix some inconsistency with docs

pull/1923/head
quin lynch 4 years ago
parent
commit
1a2e8432fb
3 changed files with 36 additions and 27 deletions
  1. +1
    -1
      docs/guides/interactions/application-commands/01-getting-started.md
  2. +28
    -20
      docs/guides/interactions/application-commands/context-menu-commands/creating-context-menu-commands.md
  3. +7
    -6
      docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md

+ 1
- 1
docs/guides/interactions/application-commands/01-getting-started.md View File

@@ -18,7 +18,7 @@ There is a new special OAuth2 scope for applications called `applications.comman

Head over to your discord applications OAuth2 screen and make sure to select the `application.commands` scope.

![OAuth2 scoping](images/oauth.png)
![OAuth2 scoping](slash-commands/images/oauth.png)

From there you can then use the link to add your bot to a server.



+ 28
- 20
docs/guides/interactions/application-commands/context-menu-commands/creating-context-menu-commands.md View File

@@ -19,21 +19,21 @@ If you don't have the code for a bot ready yet please follow [this guide](https:

The context menu user command builder will help you create user commands. The builder has these available fields and methods:

| Name | Type | Description |
| --------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- |
| Name | string | The name of this context menu command. |
| WithName | Function | Sets the field name. |
| Build | Function | Builds the builder into the appropriate `CommandCreationProperties` class used to make Menu commands |
| Name | Type | Description |
| -------- | -------- | ------------------------------------------------------------------------------------------------ |
| Name | string | The name of this context menu command. |
| WithName | Function | Sets the field name. |
| Build | Function | Builds the builder into the appropriate `UserCommandProperties` class used to make Menu commands |

## MessageCommandBuilder

The context menu message command builder will help you create message commands. The builder has these available fields and methods:

| Name | Type | Description |
| --------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- |
| Name | string | The name of this context menu command. |
| WithName | Function | Sets the field name. |
| Build | Function | Builds the builder into the appropriate `CommandCreationProperties` class used to make Menu commands |
| Name | Type | Description |
| -------- | -------- | --------------------------------------------------------------------------------------------------- |
| Name | string | The name of this context menu command. |
| WithName | Function | Sets the field name. |
| Build | Function | Builds the builder into the appropriate `MessageCommandProperties` class used to make Menu commands |

**Note**: Context Menu command names can be upper and lowercase, and use spaces.

@@ -47,8 +47,8 @@ client.Ready += Client_Ready;

public async Task Client_Ready()
{
// Let's build a guild command! We're going to need a guild id so lets just put that in a variable.
ulong guildId = 848176216011046962;
// Let's build a guild command! We're going to need a guild so lets just put that in a variable.
var guild = client.GetGuild(guildId);

// Next, lets create our user and message command builder. This is like the embed builder but for context menu commands.
var guildUserCommand = new UserCommandBuilder();
@@ -62,20 +62,27 @@ public async Task Client_Ready()
//guildCommand.WithDescription("");

// Let's do our global commands
var globalCommand = new UserCommandBuilder();
var globalUserCommand = new UserCommandBuilder();
globalCommand.WithName("Global User Command");
var globalMessageCommand = new MessageCommandBuilder();
globalMessageCommand.WithName("Global Message Command");


try
{
// Now that we have our builder, we can call the rest API to make our slash command.
await client.Rest.CreateGuildUserCommand(guildUserCommand.Build(), guildId);
await client.Rest.CreateGuildMessageCommand(guildMessageCommand.Build(), guildId);

// With global commands we dont need the guild id.
await client.Rest.CreateGlobalUserCommand(globalUserCommand.Build());
await client.Rest.CreateGlobalMessageCommand(globalMessageCommand.Build());
// Now that we have our builder, we can call the BulkOverwriteApplicationCommandAsync to make our context commands. Note: this will overwrite all your previous commands with this array.
await guild.BulkOverwriteApplicationCommandAsync(new ApplicationCommandProperties[]
{
guildUserCommand.Build(),
guildMessageCommand.Build()
});

// With global commands we dont need the guild.
await client.BulkOverwriteGlobalApplicationCommandsAsync(new ApplicationCommandProperties[]
{
globalUserCommand.Build(),
globalMessageCommand.Build()
})
}
catch(ApplicationCommandException exception)
{
@@ -88,4 +95,5 @@ public async Task Client_Ready()
}

```

**Note**: Application commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register application commands.

+ 7
- 6
docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md View File

@@ -45,8 +45,8 @@ client.Ready += Client_Ready;

public async Task Client_Ready()
{
// Let's build a guild command! We're going to need a guild id so lets just put that in a variable.
ulong guildId = 848176216011046962;
// Let's build a guild command! We're going to need a guild so lets just put that in a variable.
var guild = client.GetGuild(guildId);

// Next, lets create our slash command builder. This is like the embed builder but for slash commands.
var guildCommand = new SlashCommandBuilder();
@@ -64,11 +64,11 @@ public async Task Client_Ready()

try
{
// Now that we have our builder, we can call the rest API to make our slash command.
await client.Rest.CreateGuildCommand(guildCommand.Build(), guildId);
// Now that we have our builder, we can call the CreateApplicationCommandAsync method to make our slash command.
await guild.CreateApplicationCommandAsync(guildCommand.Build());

// With global commands we dont need the guild id.
await client.Rest.CreateGlobalCommand(globalCommand.Build());
// With global commands we dont need the guild.
await client.CreateGlobalApplicationCommandAsync(globalCommand.Build());
}
catch(ApplicationCommandException exception)
{
@@ -81,4 +81,5 @@ public async Task Client_Ready()
}

```

**Note**: Slash commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register slash commands.

Loading…
Cancel
Save