Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add ID to CreateCommandData #417

Merged
merged 1 commit into from Jan 7, 2024
Merged

Conversation

Benbebop
Copy link
Contributor

@Benbebop Benbebop commented Jan 6, 2024

CreateCommandData doesn't have an ID parameter, adding it allows you to rename commands with BulkOverwriteCommands and BulkOverwriteGuildCommands.

func main() {
	client := api.NewClient("Bot " + token)

	var cmds []api.CreateCommandData
	cmds = append(cmds, api.CreateCommandData{
		Type:        1,
		Name:        "newcommand",
		Description: "this is a fresh new command",
	})

	app, _ := client.CurrentApplication()

	newCmds, _ := client.BulkOverwriteGuildCommands(app.ID, testGuild, cmds)

	fmt.Printf("%d, '%s', '%s'\n", newCmds[0].ID, newCmds[0].Name, newCmds[0].Description)

	cmds[0] = api.CreateCommandData{
		ID:          newCmds[0].ID,
		Type:        1,
		Name:        "replacedcommand",
		Description: "this is an overwritten command",
	}

	newCmds, _ = client.BulkOverwriteGuildCommands(app.ID, testGuild, cmds)

	fmt.Printf("%d, '%s', '%s'\n", newCmds[0].ID, newCmds[0].Name, newCmds[0].Description)

	client.DeleteGuildCommand(app.ID, guildID, newCmds[0].ID)
}

1193307101997580370, 'newcommand', 'this is a fresh new command'
1193307101997580370, 'replacedcommand', 'this is an overwritten command'

@diamondburned diamondburned merged commit 10d3626 into diamondburned:v3 Jan 7, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants