### Start Bot Application in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/bot Provides the Start function for quickly initializing a bot. It prepends 'Bot' to the provided token and returns a function to wait for cleanup and an error value. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // ... implementation details ... } ``` -------------------------------- ### Start Bot with Token and Command Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.6/utils/bot The `Start` function initiates the bot with a given token and command interface, automatically prepending 'Bot' to the token. It returns a wait function and an error. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // Implementation details omitted for brevity } ``` -------------------------------- ### Define Interface for Command Setup in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.4.0/utils/bot_tab=versions Defines the `CanSetup` interface with a `Setup` method, allowing components to perform setup operations when a subcommand is initialized. ```go type CanSetup interface Setup func(*Subcommand) ``` -------------------------------- ### Start Bot Application in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.3/utils/bot Implements the Start function for quickly initializing a bot. It automatically prepends 'Bot' to the provided token and returns a wait function and an error. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // Function implementation would go here } ``` -------------------------------- ### Define Interface for Commands Requiring Setup (Go) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.1.0/utils/bot_tab=versions Defines the `CanSetup` interface, which requires a `Setup` method that takes a `*Subcommand` as an argument. This allows commands to perform initialization or setup tasks before being fully registered. ```go type CanSetup interface Setup func(*Subcommand) ``` -------------------------------- ### Start Bot Function in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.6.0/utils/bot The `Start` function provides a quick way to initialize the bot with a token and command interface. It automatically prepends 'Bot' to the token and returns a wait function and an error. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error ) (wait func() error, err error) ``` -------------------------------- ### Start Bot Function in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.0/utils/bot Implements the 'Start' function for quickly initializing a bot. It automatically prepends 'Bot' to the token and returns a function to wait for completion and any initialization error. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}Я, opts func(*Context) error) (wait func() error, err error) { // Implementation details omitted as only function signature was provided. } ``` -------------------------------- ### Start and Manage Gateway (Go) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/gateway Functions to start the Gateway connection and manage its execution. Includes options to start with or without context, allowing for different control flows. ```Go func (g *Gateway) Start() error func (g *Gateway) StartCtx(ctx context.Context) error ``` -------------------------------- ### Start Bot Quickly with Token in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/utils/bot Defines the Start function for quickly initializing a bot with a given token and command. It automatically prepends 'Bot' to the token and returns a wait function and an error. Refer to the example directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // Implementation details not provided in snippet, but function signature is defined. } ``` -------------------------------- ### Starting and Running Commands in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/utils/bot%40v3 Demonstrates the `Run` and `Start` functions for executing commands. These functions take a token, command interface, and optional context options to initiate command processing. ```go func Run(token string, cmd interface{}, opts func(*Context) error) func Start(token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Application and Role Connection URL (Go) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/discord_tab=versions Extends the Application structure with fields for custom install URLs, install parameters, and role connection verification URLs. This facilitates application integration and setup. ```Go type Application struct { CustomInstallURL string InstallParams InstallParams RoleConnectionsVerificationURL string Tags []string } ``` -------------------------------- ### Go: Start Bot Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.1/utils/bot The `Start` function provides a quick way to initialize the bot with a token and command interface. It prepends 'Bot' to the token and returns a function to wait for cleanup and a potential error. ```go func Start( token string, cmd interface{}Я, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Install Parameters Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.2/discord_tab=versions Defines the structure for installation parameters, used when a bot or application is installed into a guild. It includes necessary permissions and scopes. ```go type InstallParams struct { Permissions Permissions Scopes []string } ``` -------------------------------- ### Define Command Handling Interfaces in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/utils/bot_tab=versions Defines interfaces for commands that can provide help text or setup configurations. Includes types for commands that can be configured with help strings and setup functions. ```go type CanHelp interface Help func() string type CanSetup interface Setup func(*Subcommand) ``` -------------------------------- ### Start Bot with Token and Options in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/utils/bot The `Start` function provides a quick way to initialize a bot with a given token and command interface. It prepends 'Bot' to the token and returns a function to wait for cleanup and an error object. ```go func Start( token string, cmd interface{}Т, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Start and run commands with token and options in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.4/utils/bot_tab=versions Provides functions to start and run commands using a provided token and command interface. The `Start` function returns a wait function and an error, enabling asynchronous command execution and graceful shutdown. `Run` executes commands directly. ```go func Run(token string, cmd interface{}, opts func(*Context) error) { // ... implementation details ... } func Start(token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // ... implementation details ... return nil, nil } ``` -------------------------------- ### Start Bot Application in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.1.0/utils/bot The Start function provides a quick way to initialize and start the bot with a given command. It prepends 'Bot' to the token and returns a function to wait for cleanup and any potential error during startup. ```go func Start( token string, cmd interface{}r, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Start Bot with Token and Options in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.1/bot The 'Start' function provides a quick way to initialize a bot with a given token and command structure. It automatically prepends 'Bot' to the token. It returns a function to wait for cleanup and an error, if any occurred during startup. Refer to the 'example/' directory for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Bot Context Opening and Starting in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.5/utils/bot Open starts the bot context and gateway connection, while Start integrates with session handlers. Start returns a function to remove it from handlers. ```go func (ctx *Context) Open(cancelCtx context.Context) error func (ctx *Context) Start() func() ``` -------------------------------- ### Get Guild Prune Count Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.5/api Returns the number of members that would be pruned (left the server) if a prune were started. ```APIDOC ## GET /guilds/{guild.id}/prune ### Description Returns the number of members that would be pruned. ### Method GET ### Endpoint `/guilds/{guild.id}/prune` ### Parameters #### Path Parameters - **guild.id** (Snowflake) - Required - The ID of the guild. #### Query Parameters - **days** (integer, optional) - The number of days to count prune for (1 or more, default 7). - **include_roles** (array of Snowflake, optional) - The role(s) to include in the prune count. ### Request Example ``` GET /guilds/123456789012345678/prune?days=7&include_roles=role_id_1,role_id_2 ``` ### Response #### Success Response (200) - **pruned** (integer) - The number of members that would be pruned. #### Response Example ```json { "pruned": 150 } ``` #### Error Response (400, 403, 404) See Discord API error documentation. ``` -------------------------------- ### Create and Configure a Gateway in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.0/utils/ws This code illustrates how to initialize a Gateway, which manages WebSocket connections and event handling. It shows creating a new Gateway with specified options and starting its connection. ```go package main import ( "context" "github.com/diamondburned/arikawa/v3/gateway" "github.com/diamondburned/arikawa/v3/gateway/wsutil" ) func main() { // Example: Create a mock Websocket and GatewayOpts // Replace with actual implementations as needed var ws *wsutil.Websocket opts := &gateway.GatewayOpts{} // Create a new Gateway g := gateway.NewGateway(ws, opts) // Example: Connect to the gateway // ctx := context.Background() // var handler gateway.Handler // Implement Handler interface // opChan, err := g.Connect(ctx, handler) // if err != nil { // // Handle error // } // Example: Send an event // event := gateway.Event{ /* ... fill event data ... */ } // err = g.Send(context.Background(), event) // if err != nil { // // Handle error // } } ``` -------------------------------- ### Router Initialization and Command Handling in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.0/api/cmdroute_tab=versions Demonstrates how to create a new router instance and add commands to it. This is a fundamental pattern for setting up command handling within the `cmdroute` package. ```go package main import ( "context" "github.com/diamondburned/arikawa/v3/api" "github.com/diamondburned/arikawa/v3/discord" "github.com/diamondburned/arikawa/v3/examples/cmdroute" ) func main() { router := cmdroute.NewRouter() // Example of adding a command handler router.Add("ping", cmdroute.CommandHandlerFunc(func(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData { return &api.InteractionResponseData{Content: "Pong!"} })) // Example of adding an autocompleter router.AddAutocompleter("search", cmdroute.AutocompleterFunc(func(ctx context.Context, data cmdroute.AutocompleteData) api.AutocompleteChoices { // Logic to handle autocomplete suggestions return nil })) // Example of adding a component handler router.AddComponent("button_click", cmdroute.ComponentHandlerFunc(func(ctx context.Context, data cmdroute.ComponentData) *api.InteractionResponse { return &api.InteractionResponse{Data: api.InteractionResponseData{Content: "Button clicked!"}} })) // The router can then be used to handle interactions... } ``` -------------------------------- ### Get Guild Prune Count Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.1/api Returns the number of members that would be pruned (left) if a prune operation was started. ```APIDOC ## GET /guilds/{guild.id}/prune ### Description Returns the number of members that would be pruned. ### Method GET ### Endpoint `/guilds/{guild.id}/prune` ### Parameters #### Query Parameters - **days** (uint) - Optional - The number of days to count prune for (1 or more, default 7). - **include_roles** ([]discord.RoleID) - Optional - The role(s) to include in the prune count. ### Request Example ``` GET /guilds/123456789012345678/prune?days=7&include_roles=role_id_1,role_id_2 ``` ### Response #### Success Response (200 OK) - **pruned** (int) - The number of members that would be pruned. #### Response Example ```json { "pruned": 150 } ``` #### Error Response - 400 Bad Request - 401 Unauthorized - 403 Forbidden - 429 Too Many Requests ``` -------------------------------- ### Application Custom Install URL and Tags in Arikawa v3 Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.1/discord_tab=versions Adds support for custom install URLs, installation parameters, and tags for applications. This provides more flexibility in how applications are distributed and configured. ```go type Application CustomInstallURL string InstallParams InstallParams RoleConnectionsVerificationURL string Tags []string ``` -------------------------------- ### Client Initialization and Usage Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.1.0/utils/httputil_tab=versions Demonstrates how to create a new HTTP client and configure it with options. ```APIDOC ## Client Structure and Initialization ### Description The `Client` struct provides methods for making HTTP requests. It can be initialized using `NewClient` and configured with various `RequestOption` functions. ### Method `NewClient()` ### Endpoint N/A (Constructor) ### Parameters None ### Request Example ```go client := httputil.NewClient() // Configure client with options client = client.WithContext(ctx) client = client.Copy() ``` ### Response #### Success Response - `*Client` (type) - A pointer to the newly created and potentially configured `Client` instance. #### Response Example ```go // client is a *httputil.Client ``` ``` -------------------------------- ### GET /gateway/bot Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.1/api Retrieves the Gateway URL for connecting to Discord, along with sharding information and session start limits. ```APIDOC ## GET /gateway/bot ### Description Retrieves the WebSocket Gateway URL needed to establish a connection to Discord. This endpoint also provides important metadata for sharding bots, including the recommended number of shards and limits on starting new sessions. ### Method GET ### Endpoint `/gateway/bot` ### Parameters None ### Request Example ``` GET /gateway/bot ``` ### Response #### Success Response (200) - **url** (string) - The WebSocket URL to connect to. - **shards** (integer) - The recommended number of shards to use for the bot. - **session_start_limit** (SessionStartLimit object) - Information about the limits for starting new sessions. - **total** (integer) - The total number of sessions start requests allowed per day. - **remaining** (integer) - The number of remaining session start requests. - **reset_after** (integer) - The number of milliseconds after which the session start limit resets. - **max_concurrency** (integer) - The maximum number of concurrent new sessions you are allowed to open per gateway connection. #### Response Example ```json { "url": "wss://gateway.discord.gg/?v=9&encoding=json", "shards": 1, "session_start_limit": { "total": 1000, "remaining": 999, "reset_after": 7200000, "max_concurrency": 1 } } ``` ``` -------------------------------- ### Start Bot Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.2/utils/bot The Start function quickly initializes the bot with a given command and token, automatically prepending 'Bot' to the token. It returns a function to wait for completion and any initialization error. Refer to example/ for usage. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) { // Function implementation details are not provided in the source. } ``` -------------------------------- ### Gateway Creation and Configuration in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.5.0/gateway_tab=versions Demonstrates how to create and configure a Gateway instance in Go using the Arikawa library. It covers different methods for initialization, including using a token, custom URLs, and specific intents. Dependencies include the `context` package and Arikawa's `ws` and `api` sub-packages. ```go func New(ctx context.Context, token string) (*Gateway, error) func NewCustom(gatewayURL, token string) *Gateway func NewCustomWithIdentifier(gatewayURL string, id Identifier, opts *ws.GatewayOpts) *Gateway func NewFromState(gatewayURL string, state State, opts *ws.GatewayOpts) *Gateway func NewWithIdentifier(ctx context.Context, id Identifier) (*Gateway, error) func NewWithIntents(ctx context.Context, token string, intents ...Intents) (*Gateway, error) func (g *Gateway) AddIntents(i Intents) ``` -------------------------------- ### Start Bot with Token and Command Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.4.0/utils/bot Starts the bot with the given token and command structure, automatically prepending 'Bot' to the token. It returns a function to wait for bot termination and any initialization error. Refer to the example directory for usage guidance. ```go func Start( token string, cmd interface{} , opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Get Bot Info Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.1.0/api_tab=versions Retrieves information about the bot, including shard count and session start limit. ```APIDOC ## GET /api/v1/gateway/bot ### Description Retrieves information about the bot, including shard count and session start limit. ### Method GET ### Endpoint `/api/v1/gateway/bot` ### Response #### Success Response (200) - **shards** (int) - Recommended number of shards to use. - **session_start_limit** (SessionStartLimit) - Information about the session start limit. - **url** (string) - The WebSocket URL for the gateway. #### Response Example ```json { "shards": 1, "session_start_limit": { "total": 1000, "remaining": 999, "reset_after": 14400, "max_concurrency": 1 }, "url": "wss://gateway.discord.gg/?v=9&encoding=json" } ``` ``` -------------------------------- ### Start Bot Function Signature in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.5/utils/bot Defines the 'Start' function which quickly initializes the bot with a given command and token, automatically prepending 'Bot' to the token. It returns a function to wait for completion and an error. ```go func Start( token string, cmd interface{}, opts func(*Context) error) (wait func() error, err error) ``` -------------------------------- ### Get Gateway Error Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.2.0/session Retrieves the gateway's error if it has died. Returns nil if the gateway is alive or has never started. ```APIDOC ## GET /session/gateway/error ### Description GatewayError returns the gateway's error if the gateway is dead. If it's not dead, then nil is always returned. The check is done with GatewayIsAlive(). If the gateway has never been started, nil will be returned. This method would return what Close() would've returned if a fatal gateway error was found. ### Method GET ### Endpoint /session/gateway/error ### Response #### Success Response (200) - **error** (error) - The gateway error or nil. #### Response Example ```json { "error": "gateway_fatal_error" } ``` ``` -------------------------------- ### Get Bot Data Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/api_tab=versions Fetches information about the bot itself, including shard count and gateway start limit. Returns bot data or an error. ```go package main import ( "github.com/diamondburned/arikawa/v3/discord" ) func getBotDataExample(c *discord.Client) (*discord.BotData, error) { botData, err := c.BotURL() // Note: The function name is BotURL, but it returns BotData if err != nil { return nil, err } return botData, nil } ``` -------------------------------- ### Create a new HTTP client with default settings - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.5.0/utils/httputil_tab=versions Initializes a new `Client` instance with default configurations. This client can then be used to make HTTP requests. No external dependencies are required beyond the package itself. ```Go c := httputil.NewClient() ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/api Methods for initializing a new Arikawa client instance. ```APIDOC ## Client Initialization ### Description Functions to create and initialize a new Discord client instance. ### Methods - `NewClient(token string) *Client` - `NewCustomClient(token string, httpClient *httputil.Client) *Client ### Request Body N/A ### Request Example ```go client := arikawa.NewClient("YOUR_BOT_TOKEN") ``` ### Response #### Success Response (200) - `*Client` - A pointer to the initialized client instance. #### Response Example ```go // client is now ready to use ``` ``` -------------------------------- ### GET /users/@me/guilds (before) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.2/api Retrieves a list of partial guild objects the current user is a member of, with pagination support, starting before a specific guild ID. Requires the guilds OAuth2 scope. ```APIDOC ## GET /users/@me/guilds (before) ### Description Retrieves a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all guilds with an id smaller than before. As the underlying endpoint has a maximum of 100 guilds per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available. Requires the guilds OAuth2 scope. ### Method GET ### Endpoint /users/@me/guilds ### Parameters #### Query Parameters - **before** (discord.GuildID) - Required - The ID of the guild to start fetching before. - **limit** (uint) - Optional - The maximum number of guilds to return. If 0, all guilds before the specified ID are fetched. ### Response #### Success Response (200) - **guilds** ([]discord.Guild) - A list of partial guild objects. #### Response Example ```json [ { "id": "987654321098765432", "name": "Example Guild", "icon": "guild_icon_hash", "owner": false, "permissions": 0, "features": [] } ] ``` ``` -------------------------------- ### GET /users/@me/guilds (after) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.2/api Retrieves a list of partial guild objects the current user is a member of, with pagination support, starting after a specific guild ID. Requires the guilds OAuth2 scope. ```APIDOC ## GET /users/@me/guilds (after) ### Description Retrieves a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all guilds with an id higher than after. As the underlying endpoint has a maximum of 100 guilds per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available. Requires the guilds OAuth2 scope. ### Method GET ### Endpoint /users/@me/guilds ### Parameters #### Query Parameters - **after** (discord.GuildID) - Required - The ID of the guild to start fetching after. - **limit** (uint) - Optional - The maximum number of guilds to return. If 0, all guilds after the specified ID are fetched. ### Response #### Success Response (200) - **guilds** ([]discord.Guild) - A list of partial guild objects. #### Response Example ```json [ { "id": "987654321098765432", "name": "Example Guild", "icon": "guild_icon_hash", "owner": false, "permissions": 0, "features": [] } ] ``` ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.1.0/api Provides methods for initializing a new Arikawa client with different configurations. ```APIDOC ## Client Initialization ### Description Methods to create a new `Client` instance. You can initialize with just a token or a token and a custom HTTP client. ### Methods * **NewClient(token string) *Client*** Initializes a new client with the provided authentication token. * **NewCustomClient(token string, httpClient *httputil.Client) *Client*** Initializes a new client with a token and a custom HTTP client for advanced configurations. ``` -------------------------------- ### GET /gateway/bot Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/api_tab=versions Retrieves gateway bot data, including the URL, shards, and session start limit. Useful for bot initialization and sharding. ```APIDOC ## GET /gateway/bot ### Description Retrieves the gateway URL and the recommended number of shards to use for a bot. ### Method GET ### Endpoint /gateway/bot ### Parameters None ### Request Example None ### Response #### Success Response (200) - **URL** (string) - The URL to connect to the gateway. - **Shards** (integer) - The recommended number of shards to use. - **SessionStartLimit** (object) - Information about the bot's session start limit. #### Response Example ```json { "url": "wss://gateway.discord.gg", "shards": 1, "session_start_limit": { "total": 1000, "remaining": 999, "reset_after": 86400000, "max_concurrency": 1 } } ``` ``` -------------------------------- ### Define Interfaces for Command Behavior in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/utils/bot_tab=versions This Go code defines two interfaces: `CanHelp` with a `Help` method for generating help text, and `CanSetup` with a `Setup` method for configuring subcommands. These interfaces allow different command components to adhere to a common contract for help generation and setup. ```go type CanHelp interface { Help() string } type CanSetup interface { Setup(*Subcommand) } ``` -------------------------------- ### CanSetup Interface - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.2.0/utils/bot_tab=versions Defines the `CanSetup` interface, requiring a `Setup` method that takes a `*Subcommand` pointer, likely for configuring or initializing subcommands. ```Go type CanSetup interface { Setup func(*Subcommand) } ``` -------------------------------- ### Get Usage Information in Go MethodContext Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.3/utils/bot Returns a slice of strings representing the usage information for the command method. This can be used to generate help messages or provide command syntax examples. ```Go func (cctx *MethodContext) Usage() []string { // Implementation omitted for brevity return []string{"usage1", "usage2"} } ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.6/api Provides methods for initializing the Discord client with different configurations. ```APIDOC ## Client Initialization ### Description Methods for creating and initializing a new Discord client. ### Methods #### `NewClient(token string) *Client` - **Description**: Creates a new client instance with the provided bot token. - **Parameters**: - `token` (string) - Required - The bot token for authentication. #### `NewCustomClient(token string, httpClient *httputil.Client) *Client` - **Description**: Creates a new client instance with a custom HTTP client and bot token. - **Parameters**: - `token` (string) - Required - The bot token for authentication. - `httpClient` (*httputil.Client) - Required - A pre-configured HTTP client. ### Request Example ```go // Example for NewClient client := arikawa.NewClient("YOUR_BOT_TOKEN") // Example for NewCustomClient customClient := &http.Client{} client := arikawa.NewCustomClient("YOUR_BOT_TOKEN", customClient) ``` ``` -------------------------------- ### Get Guilds After Specific ID - Go Client Method Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.5.0/api Retrieves a list of partial guild objects the current user is a member of, starting from a specific guild ID. This method paginates based on the provided limit and can optionally include the guild's approximate member count if WithCounts is true. It fetches guilds with IDs smaller than the starting ID and requires the guilds OAuth2 scope. ```Go func (c *Client) GuildsAfter(data GuildsAfterData) ([]discord.Guild, error) ``` -------------------------------- ### Start Bot Context and Gateway - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.6/utils/bot Opens the bot context and gateway connection, automatically binding handlers. Start adds itself to session handlers and returns a function to remove it. Calling Open makes calling Start redundant. ```Go func (ctx *Context) Open(cancelCtx context.Context) error func (ctx *Context) Start() func() ``` -------------------------------- ### Discord Thread Management - Start and Get Members Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.2.0/api_tab=versions Initiates a new thread, either from an existing message or without one, using provided thread data. Also retrieves members of a specific thread. ```go func (c *Client) StartThreadWithMessage(channelID discord.ChannelID, messageID discord.MessageID, data StartThreadData) (*discord.Channel, error) func (c *Client) StartThreadWithoutMessage(channelID discord.ChannelID, data StartThreadData) (*discord.Channel, error) func (c *Client) ThreadMembers(threadID discord.ChannelID) ([]discord.ThreadMember, error) ``` -------------------------------- ### Define CanSetup Interface in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.5/utils/bot_tab=versions Defines the `CanSetup` interface, which includes a `Setup` method. This interface is intended for types that need to be configured or set up before they can be used, likely in the context of subcommands. ```go type CanSetup interface { Setup func(*Subcommand) } ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.1/api Provides methods for creating a new Arikawa client instance. ```APIDOC ## Client Initialization ### Description Methods for creating and initializing the Arikawa client. ### NewClient Creates a new client instance with the provided token. #### Method func NewClient(token string) *Client ### NewCustomClient Creates a new client instance with the provided token and a custom HTTP client. #### Method func NewCustomClient(token string, httpClient *httputil.Client) *Client ``` -------------------------------- ### Go - Get Default Gateway Options Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/gateway_tab=versions Retrieves the default configuration options for the Discord Gateway. These defaults provide a sensible starting point for most applications, but can be customized. The `DefaultGatewayOpts` variable holds these default settings. ```go package main import ( "log" "github.com/diamondburned/arikawa/v3/gateway" ) func main() { opts := gateway.DefaultGatewayOpts log.Printf("Default Gateway Options: %+v\n", opts) } ``` -------------------------------- ### Get Bot Information with Arikawa Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.2/api_tab=versions Function to retrieve information about the bot itself, including its shard count and session start limits. This can be useful for monitoring and scaling the bot's operation. Returns bot data or an error. ```go func (c *Client) BotURL() (*BotData, error) ``` -------------------------------- ### Session Initialization and Connection - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.5/session_tab=versions This snippet demonstrates how to initialize and connect a session using different methods provided by the session package. It includes options for standard token-based login, creating sessions with custom clients and handlers, and establishing connections with specific intents. ```go func Login(ctx context.Context, email, password, mfa string) (*Session, error) func New(token string) *Session func NewCustom(id gateway.Identifier, cl *api.Client, h *handler.Handler) *Session func NewWithGateway(g *gateway.Gateway, h *handler.Handler) *Session func NewWithIdentifier(id gateway.Identifier) *Session func NewWithIntents(token string, intents ...gateway.Intents) *Session func (s *Session) Connect(ctx context.Context) error func (s *Session) Open(ctx context.Context) error ``` -------------------------------- ### Get Last Gateway Error - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/voice/voicegateway Retrieves the last encountered error from the gateway. This method is only valid if the gateway's event loop has exited. Calling it before the event loop has started and stopped will result in a panic. ```go func (g *Gateway) LastError() error ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/api_tab=versions Methods for initializing a new Arikawa client with various configurations. ```APIDOC ## Client Initialization ### Description Provides methods to create and configure a new instance of the Arikawa client. ### Methods - `NewClient(token string) *Client` - `NewCustomClient(token string, httpClient *httputil.Client) *Client ### Parameters - **token** (string) - Required - The authentication token for the Discord API. - **httpClient** (*httputil.Client) - Optional - A custom HTTP client to use for requests. ``` -------------------------------- ### Usage: Get Command Usage Information (Go) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.2.0/utils/bot Usage returns a slice of strings representing the command's usage information. This is typically used for generating help messages or providing usage examples to users. ```Go func (cctx *MethodContext) Usage() []string { // Implementation details... } ``` -------------------------------- ### Create and Configure an HTTP Client - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.6/utils/httputil_tab=versions Demonstrates how to create a new HTTP client and configure it with options such as context and request/response hooks. This client can then be used to perform various HTTP operations. ```go client := httputil.NewClient() ctx := context.Background() client = client.WithContext(ctx) // Example of adding request/response options (not shown in detail here) client.OnRequest = append(client.OnRequest, func(r httpdriver.Request) error { // Modify request return nil }) client.OnResponse = append(client.OnResponse, func(r httpdriver.Request, resp httpdriver.Response) error { // Process response return nil }) ``` -------------------------------- ### Get Bot Application Data in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.6/api_tab=versions This Go function retrieves information about the bot's application, including its discovery status and the session start limit. This data can be useful for understanding the bot's operational limits and configuration. ```go package main import ( "context" "log" "github.com/diamondburned/arikawa/v3/discord" "github.com/diamondburned/arikawa/v3/session" ) func main() { // Assume 'ss' is an initialized session.Session // Example initialization (replace with your actual token and setup) const token = "YOUR_BOT_TOKEN" ss, err := session.NewClient(token) if err != nil { log.Fatalf("Failed to create client: %v", err) } if err := ss.Open(context.Background()); err != nil { log.Fatalf("Failed to open gateway connection: %v", err) } defer ss.Close() // Fetch bot application data botData, err := ss.BotURL() // Note: The function name is BotURL(), but it returns BotData if err != nil { log.Printf("Failed to fetch bot data: %v\n", err) } else { log.Printf("Bot discovery status: %t\n", botData.Discoverable) log.Printf("Session start limit: %d\n", botData.StartLimit.MaxConcurrency) } } ``` -------------------------------- ### Go: Install Parameters Structure Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0-rc.3/discord_tab=versions Defines the `InstallParams` struct, which holds parameters related to application installations, specifically `Permissions` and `Scopes`. This is crucial for defining what an application can do and access. ```go type InstallParams struct + Permissions Permissions + Scopes []string ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.0/api Methods for creating a new Arikawa client instance. ```APIDOC ## Client Initialization ### Description Provides methods to initialize a new Arikawa client, either with a default HTTP client or a custom one. ### Functions #### NewClient ```go func NewClient(token string) *Client ``` - **Description**: Creates a new client with the provided bot token. - **Parameters**: - `token` (string) - The bot token for authentication. #### NewCustomClient ```go func NewCustomClient(token string, httpClient *httputil.Client) *Client ``` - **Description**: Creates a new client with the provided bot token and a custom HTTP client. - **Parameters**: - `token` (string) - The bot token for authentication. - `httpClient` (*httputil.Client) - A custom HTTP client to use for requests. ``` -------------------------------- ### GET /users/@me/guilds (after ID) Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/api Retrieves a list of partial guild objects that the current user is a member of, starting from a specific guild ID. Supports pagination and optional inclusion of member counts. Requires the guilds OAuth2 scope. ```APIDOC ## GET /users/@me/guilds (after ID) ### Description GuildsAfter returns a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed Limit, starting from AfterID, or, if the limit is set to 0, has fetched all guilds with an ID smaller than before. If WithCounts is set to true then all partial guild objects will include the guild's approximate member count field. ### Method GET ### Endpoint `/users/@me/guilds` ### Parameters #### Query Parameters - **limit** (uint) - Optional - The maximum number of guilds to return. - **after** (discord.GuildID) - Optional - The ID of the last guild fetched. Guilds will be fetched with IDs greater than this. - **with_counts** (bool) - Optional - Whether to include approximate member counts. ### Requirements - guilds OAuth2 scope ### Response #### Success Response (200) - **Guilds** ([]discord.Guild) - A list of partial guild objects. #### Response Example ```json [ { "id": "234567890123456789", "name": "Example Guild 3", "icon": "c1d2e3f4a5b678901234567890abcdef", "owner": false, "permissions": "1073741823", "approximate_member_count": 500 } ] ``` ``` -------------------------------- ### Arikawa Client: Get Bot Information Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.2/api_tab=versions Provides the Go code to fetch information about the bot itself. This function does not require any parameters and returns a pointer to a `BotData` struct, which includes details like shard count and session start limit, or an error. ```go botData, err := c.BotURL() ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.1/api Provides methods for initializing the Arikawa client with different configurations. ```APIDOC ## Client Initialization ### Description Methods for creating and initializing a new Arikawa client instance. ### NewClient ```go func NewClient(token string) *Client ``` **Description**: Creates a new client with the provided bot token. ### NewCustomClient ```go func NewCustomClient(token string, httpClient *httputil.Client) *Client ``` **Description**: Creates a new client with the provided bot token and a custom HTTP client. ``` -------------------------------- ### Initialize Discord Client in Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.6/api_tab=versions This snippet demonstrates how to initialize a new Discord API client using a provided authentication token. It shows the basic setup required to start making API calls. The client is essential for all subsequent interactions with the Discord API. ```go package main import ( "github.com/diamondburned/arikawa/v3/api" "github.com/diamondburned/arikawa/v3/discord" "github.com/diamondburned/arikawa/v3/gateway" "github.com/diamondburned/arikawa/v3/session" "log" ) func main() { // Replace with your actual bot token const token = "YOUR_BOT_TOKEN" s// Initialize a new Discord client ss, err := session.NewClient(token) if err != nil { log.Fatalf("Failed to create client: %v", err) } // Connect to the gateway if err := ss.Open(context.Background()); err != nil { log.Fatalf("Failed to open gateway connection: %v", err) } defer ss.Close() log.Println("Successfully connected to Discord!") // You can now use the 'ss' client to make API calls // For example, to get the current user: me, err := ss.Me() if err != nil { log.Fatalf("Failed to get current user: %v", err) } log.Printf("Logged in as: %s#%s\n", me.Username, me.Discriminator) } ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/api Functions for initializing a new Arikawa client with different configurations. ```APIDOC ## Client Initialization ### Description These functions are used to create and configure a new `Client` instance for interacting with the Discord API. ### Functions * **NewClient(token string) *Client*** * **Description**: Creates a new client with the provided bot token. * **Parameters**: * `token` (string) - Required - The bot token for authentication. * **Returns**: A pointer to the initialized `Client`. * **NewCustomClient(token string, httpClient *httputil.Client) *Client*** * **Description**: Creates a new client with a custom HTTP client. * **Parameters**: * `token` (string) - Required - The bot token for authentication. * `httpClient` (*httputil.Client) - Required - A custom HTTP client instance. * **Returns**: A pointer to the initialized `Client`. ``` -------------------------------- ### Create and Configure HTTP Client - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/utils/httputil_tab=versions Demonstrates how to create a new HTTP client and configure it with options. The NewClient function initializes a client, and RequestOption functions allow for customization of requests, such as setting headers or bodies. ```Go c := httputil.NewClient() // Example of applying options c.Request(method, url, httputil.WithHeaders(headers), httputil.WithBody(body)) ``` -------------------------------- ### Get Gateway Error - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.2/session Retrieves the gateway's error if it is dead. Returns nil if the gateway is alive or has never started. This check is performed using GatewayIsAlive(). The error returned by this method is equivalent to what Close() would return if a fatal gateway error occurred. ```go func (s *Session) GatewayError() error GatewayError returns the gateway's error if the gateway is dead. If it's not dead, then nil is always returned. The check is done with GatewayIsAlive(). If the gateway has never been started, nil will be returned (even though GatewayIsAlive would've returned true). This method would return what Close() would've returned if a fatal gateway error was found. ``` -------------------------------- ### Get Session Gateway Error - Go Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.0/session Returns the gateway's error if it is dead. If the gateway is alive, nil is returned. This check is performed using GatewayIsAlive(). If the gateway has never been started, nil is returned. This method returns what Close() would have returned if a fatal gateway error occurred. ```Go func (s *Session) GatewayError() error GatewayError returns the gateway's error if the gateway is dead. If it's not dead, then nil is always returned. The check is done with GatewayIsAlive(). If the gateway has never been started, nil will be returned (even though GatewayIsAlive would've returned true). This method would return what Close() would've returned if a fatal gateway error was found. ``` -------------------------------- ### Gateway Client Initialization and Connection Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.0.0/voice/voicegateway_tab=versions Demonstrates how to create a new Gateway client and establish a connection. It requires a State object as input and returns a channel that emits WebSocket operations. It also provides methods to retrieve the last error and the ready event. ```go func New(state State) *Gateway func (g *Gateway) Connect(ctx context.Context) <-chan ws.Op func (g *Gateway) LastError() error func (g *Gateway) Ready() *ReadyEvent ``` -------------------------------- ### Client Initialization and Configuration Source: https://pkg.go.dev/github.com/diamondburned/arikawa/v3/%40v3.3.6/utils/httputil_tab=versions Provides methods for creating a new HTTP client and configuring its behavior, such as setting timeouts and context. ```APIDOC ## Client API ### Description This section details the `Client` struct and its associated methods for managing HTTP requests. ### Methods #### NewClient - **Description**: Creates a new instance of the `Client` with default settings. - **Method**: `func NewClient() *Client` #### WithContext - **Description**: Returns a new `Client` that uses the provided context for its operations. - **Method**: `func (c *Client) WithContext(ctx context.Context) *Client` - **Parameters**: - `ctx` (context.Context) - The context to associate with the new client. #### Copy - **Description**: Returns a deep copy of the `Client`. - **Method**: `func (c *Client) Copy() *Client` ### Fields - **Timeout** (time.Duration) - The maximum duration for requests. - **Retries** (uint) - The number of times to retry a failed request. - **OnRequest** ([]RequestOption) - A slice of functions to apply before a request is sent. - **OnResponse** ([]ResponseFunc) - A slice of functions to apply after a response is received. ```