func (db Database) GetGuild(guildid string) (guild Guild, err error) {
	err = db.guilds.Find(bson.M{"guildid": guildid}).One(&guild)
	if err != nil {
		guild, err = db.EnsureGuild(guildid)
		if err != nil {
			return guild, err
		}
	}
	return guild, nil
}
GetGuild returns a guild struct containing guild data.
package storage
import (
	mgo "github.com/globalsign/mgo"
	"github.com/globalsign/mgo/bson"
)
type Guild struct {
	GuildID string `bson:"guildid"`
	Balance int    `bson:"balance"`
}
func (db Database) ensureGuildsCollection() (collection *mgo.Collection, err error) {
	collection = db.session.DB(db.config.Name).C("guilds")
	err = db.session.DB(db.config.Name).C("guilds").EnsureIndex(mgo.Index{
		Key:    []string{"guildid"},
		Unique: true,
	})
	return
}
func (db Database) EnsureGuild(guildid string) (guild Guild, err error) {
	inDatabase, err := db.IsGuildInDatabase(guildid)
	if err != nil {
		return
	}
	if !inDatabase {
		guild = Guild{
			GuildID: guildid,
			Balance: 0,
		}
		err = db.CreateGuild(guild)
		if err != nil {
			return
		}
	}
	return guild, nil
}
func (db Database) IsGuildInDatabase(guildid string) (bool, error) {
	count, err := db.guilds.Find(bson.M{"guildid": guildid}).Count()
	if err != nil {
		return false, err
	}
	if count != 0 {
		return true, nil
	}
	return false, nil
}
func (db Database) CreateGuild(guildInfo Guild) (err error) {
	err = db.guilds.Insert(&guildInfo)
	return
}