# Chat Commands

Adding chat commands is as easy as making your method `public` `static` and adding the `ChatCommand` attribute as shown below.

### Example Simple Command Without Permissions

```csharp
[ChatCommand("discord")]
public static void DiscordCommand(Player player)
{
    player.SendChatMessage("You can join our discord at discord.gg/xxxxx");
}
```

### A command with a description and a required permission.

```csharp
[ChatCommand(name: "kickme", permission: "chat.kickme", docs: "Syntax: '/kickme' Kicks yourself from the server.")]
public static void Command_players(Player player)
{
    player.Kick("Such an useful command.");
}
```

### As an example here is the `players` command from SDS.

This command uses a string as the return type for ease of use, it directly sends the message in chat OR in the console if ran by the console. If a command is ran by the console the player will be null. The player can NEVER be null in other cases. The console also bypass any permissions.

```csharp
[ChatCommand(name: "players", permission: "chat.players", docs: "Syntax: '/players' Lists all players in the world.")]
public static string Command_players(Player player, string[] args)
{
    List<Player> players = Player.PlayerList.WithoutServerPlayer();
    string playerList = string.Join(", ", players.Select(x => x.PlayerName));
    return $"Players ({players.Count}): {playerList}.";
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://schedule-i-dedicated-servers.gitbook.io/docs/chat-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
