{"id":26423350,"url":"https://github.com/switchupcb/disgoform","last_synced_at":"2025-03-18T02:49:16.654Z","repository":{"id":280169527,"uuid":"941155614","full_name":"switchupcb/disgoform","owner":"switchupcb","description":"Disgoform is a tool used to manage the application commands of your Discord Bot with code. Terraform for Discord Application Commands.","archived":false,"fork":false,"pushed_at":"2025-03-01T17:31:47.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T18:31:38.400Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/switchupcb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-01T16:14:39.000Z","updated_at":"2025-03-01T17:40:57.000Z","dependencies_parsed_at":"2025-03-01T18:31:47.534Z","dependency_job_id":"7137ce46-ec5e-4087-96df-75be8f2c0ecc","html_url":"https://github.com/switchupcb/disgoform","commit_stats":null,"previous_names":["switchupcb/disgoform"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fdisgoform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fdisgoform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fdisgoform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fdisgoform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/switchupcb","download_url":"https://codeload.github.com/switchupcb/disgoform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244147378,"owners_count":20405940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-18T02:49:16.048Z","updated_at":"2025-03-18T02:49:16.648Z","avatar_url":"https://github.com/switchupcb.png","language":"Go","funding_links":["https://github.com/sponsors/switchupcb?frequency=one-time)._"],"categories":[],"sub_categories":[],"readme":"# Manage a Discord Bot's Application Commands\n\n[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge\u0026logo=appveyor\u0026logo=appveyor)](https://pkg.go.dev/github.com/switchupcb/disgoform)\n[![License](https://img.shields.io/github/license/switchupcb/disgoform.svg?style=for-the-badge)](https://github.com/switchupcb/disgoform/blob/main/LICENSE)\n\nUse `disgoform` to stop wasting development time sending application command updates to the Discord API.\n\n## What is Disgoform?\nDisgoform is a tool used to manage the application commands of your Discord Bot.\n\nYou run `disgoform` as a program which imports a Go module to synchronize a Discord Bot's declared application commands with the Discord API.\n\n```\ngo get github.com/switchupcb/disgoform@v0.10.0\n```\n\n## Table of Contents\n\n| Topic                                                      | Categories                                                                                                                                        |\n| :--------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------ |\n| [How do you use Disgoform?](#how-do-you-use-disgoform)     | [Define Client](#1-define-your-client), [Declare commands](#2-define-your-application-commands), [Sync](#3-synchronize-your-application-commands) |\n| [What else can Disgoform do?](#what-else-can-disgoform-do) | [Reverse Sync](#what-else-can-disgoform-do)                                                                                                       |\n\n## How do you use Disgoform?\n\nView the [main example](_example\\main.go) for the example `.go` file.\n\n_You can download the Go programming language [here](https://go.dev/learn/)._\n\n### 1. Define your client.\n\nDisgoform uses the [Discord HTTP REST API](https://github.com/switchupcb/disgo/blob/v10/_contribution/concepts/REQUESTS.md) to update application commands from a Go program.\n\n```go\nbot := \u0026disgo.Client{\n    ApplicationID:  \"APPID\",\n    Authentication: disgo.BotToken(\"TOKEN\"), // or BearerToken(\"TOKEN\")\n    Config:         disgo.DefaultConfig(),\n}\n```\n\n### 2. Define your application commands.\n\nRead the [Discord API Documentation](https://discord.com/developers/docs/interactions/application-commands#application-commands) for more information about Application Commands.\n\n_TIP: Use a `Go: Fill struct` macro (e.g., `Ctrl .` on VSCode) to declare each command faster._\n\n```go\ndisgoform.GlobalApplicationCommands = []disgo.CreateGlobalApplicationCommand{\n    // Command 1\n    {\n        Name:        \"main\",\n        Description: disgo.Pointer(\"A basic command.\"),\n        Type:        disgo.Pointer(disgo.FlagApplicationCommandTypeCHAT_INPUT),\n    },\n\n    // Command 2\n    {\n        Name:        \"followup\",\n        Description: disgo.Pointer(\"Showcase multiple types of interaction responses.\"),\n    },\n\n    // Command 3\n    {\n        Name:        \"autocomplete\",\n        Description: disgo.Pointer(\"Learn about autocompletion.\"),\n        Options: []*disgo.ApplicationCommandOption{\n            {\n                Name:        \"freewill\",\n                Description: \"Do you have it?\",\n                Type:        disgo.FlagApplicationCommandOptionTypeSTRING,\n                Required:    disgo.Pointer(true),\n                Choices: []*disgo.ApplicationCommandOptionChoice{\n                    {\n                        Name:  \"Yes\",\n                        Value: \"y\",\n                    },\n                    {\n                        Name:  \"No\",\n                        Value: \"n\",\n                    },\n                },\n            },\n            {\n                Name:         \"confirm\",\n                Description:  \"Confirm your answer.\",\n                Type:         disgo.FlagApplicationCommandOptionTypeSTRING,\n                Required:     disgo.Pointer(true),\n                Autocomplete: disgo.Pointer(true),\n            },\n        },\n    },\n\n    // Command...\n    {\n        NameLocalizations:        \u0026map[string]string{},\n        Description:              nil,\n        DescriptionLocalizations: \u0026map[string]string{},\n        DefaultMemberPermissions: nil,\n        Type:                     nil,\n        NSFW:                     nil,\n        Name:                     \"\",\n        Options:                  []*disgo.ApplicationCommandOption{},\n        IntegrationTypes:         []disgo.Flag{},\n        Contexts:                 []disgo.Flag{},\n    },\n}\n```\n\nDefine Guild Application Commands using the same format.\n\n```go\ndisgoform.GuildApplicationCommands = []disgo.CreateGuildApplicationCommand{\n    // Command...\n    {\n        NameLocalizations:        \u0026map[string]string{},\n\tDescription:              nil,\n\tDescriptionLocalizations: \u0026map[string]string{},\n\tDefaultMemberPermissions: nil,\n\tType:                     nil,\n\tNSFW:                     nil,\n\tGuildID:                  \"\",\n\tName:                     \"\",\n\tOptions:                  []*disgo.ApplicationCommandOption{},\n    },\n}\n```\n\n_NOTE: The commands in this example are sourced from [Disgo examples](https://github.com/switchupcb/disgo/tree/v10/_examples/command)._\n\n### 3. Synchronize your application commands.\nSynchronize the Discord Bot's defined application commands with the Discord API.\n\n```go\n// Use disgoform.Sync to synchronize Global and Guild application commands.\n//\n// Use disgoform.SyncGlobalApplicationCommands to only synchronize global application commands.\n// Use disgoform.SyncGuildApplicationCommands to only synchronize guild application commands.\nif err := disgoform.Sync(bot); err != nil {\n    log.Printf(\"can't synchronize application commands with Discord: %v\", err)\n}\n```\n\nUse `go build -o disgoform` to build the executable binary, then run `disgoform` from the command line.\n\n```\n\u003e disgoform\nSynchronizing Global Application Commands...\nSynchronized Global Application Commands.\nSynchronizing Guild Application Commands...\nSynchronized Guild Application Commands.\n```\n\n## What else can Disgoform do?\nYou can also generate a `disgoform` `config.go` file using `disgoform.SyncConfig`.\n\n**Here is an example.**\n\n```go\nbot := \u0026disgo.Client{\n    ApplicationID:  \"APPID\",\n    Authentication: disgo.BotToken(\"TOKEN\"), // or BearerToken(\"TOKEN\")\n    Config:         disgo.DefaultConfig(),\n}\n\nguildIDs := []string{\"...\", \"...\", \"...\"}\n\n// Use disgoform.SyncConfig to output a synchronization file from the Discord Bot's current state.\noutput, err := disgoform.SyncConfig(bot, guildIDs)\nif err != nil {\n    log.Printf(\"can't output Discord application command configuration file: %v\", err)\n\n    return\n}\n\nfmt.Println(output)\n```\n\nUse `go build -o config` to build the executable binary, then run it from the command line and redirect the output to a file.\n\n```\nconfig \u003e config.go\n```\n\n_You can implement this unimplemented feature by [contributing](/_contribution/CONTRIBUTING.md) or [sponsoring SwitchUpCB](https://github.com/sponsors/switchupcb?frequency=one-time)._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswitchupcb%2Fdisgoform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswitchupcb%2Fdisgoform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswitchupcb%2Fdisgoform/lists"}