Skip to content

Adding Commands

Yiping Su edited this page Apr 13, 2020 · 1 revision

Overview

I created Isabelle with the intention of making her into an Animal Crossing: New Horizons bot. If you want her to have extra features such as moderation or fun commands, you can add your own relatively easily.

Adding Commands

Commands are split into two components:

  1. The definition file located in cmd/
  2. Command loading inside isabellebot/bot.go

Make sure to create your command definition in cmd/ and add the command to the command loader like below.

// compileCommands contains all commands the bot should add to the bot command map
func (b *Bot) compileCommands() {
	b.addCommand("search", cmd.Search)
	b.addCommand("help", cmd.Help)
	b.addCommand("list", cmd.List)
	b.addCommand("event", cmd.Event)
	b.addCommand("queue", cmd.Queue)
	b.addCommand("close", cmd.Close)
	b.addCommand("unregister", cmd.Unregister)
	b.addCommand("trade", cmd.Trade)
	b.addCommand("offer", cmd.Offer)
	b.addCommand("rep", cmd.Rep)
	b.addCommand("accept", cmd.Accept)
	b.addCommand("reject", cmd.Reject)
}