Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var About = &framework.Command{ Name: "about", Exec: func(ctx *framework.Context) error { avatarUrl := ctx.Hanamaru.State.User.AvatarURL("2048") _, _ = ctx.ReplyEmbed(&discordgo.MessageEmbed{ URL: "https://github.com/ninjawarrior1337/framework-go", Title: "初めまして、", Description: `I am a bot created by Treelar#1974 built as a replacement for crocs-and-socks which has been put into the archives. I am built using Go and smaller and faster than crocs-and-socks and also comes with some helpful Japanese learning features if the JP build tag has been added.`, Color: 0x3399ff, Image: nil, Thumbnail: &discordgo.MessageEmbedThumbnail{URL: avatarUrl}, Video: nil, Fields: []*discordgo.MessageEmbedField{ { Name: "Version", Value: version.Version(), }, }, Author: &discordgo.MessageEmbedAuthor{ URL: "https://github.com/ninjawarrior1337/hanamaru-go", Name: "Hanamaru", IconURL: avatarUrl, ProxyIconURL: "", }, }) return nil }, }
View Source
var Avatar = &framework.Command{ Name: "avatar", Exec: func(ctx *framework.Context) error { user, err := ctx.GetUser(0) if err != nil { return fmt.Errorf("please enter a valid user") } ctx.Reply(user.AvatarURL("2048")) return nil }, }
View Source
var EmojiInfo = &framework.Command{ Name: "einfo", PermissionRequired: 0, OwnerOnly: false, Help: "", Exec: func(ctx *framework.Context) error { msg, err := ctx.GetPreviousMessage() if err != nil { return err } emojis := util.ParseEmojis(msg.Content) emojiInfoMsg := "" for _, emoji := range emojis { emojiInfoMsg += fmt.Sprintf("%s: %s\n", emoji.Name, emoji.ID) } ctx.Reply(emojiInfoMsg) return nil }, Setup: nil, }
View Source
var ExchangeRates = &framework.Command{ Name: "xr", PermissionRequired: 0, OwnerOnly: false, Help: "Provides conversion from one currency to another: <val> <fromcurr> <tocurr (Default USD)>", Exec: func(ctx *framework.Context) error { currValStr, err := ctx.GetArgIndex(0) if err != nil { return nil } currValF, err := strconv.ParseFloat(currValStr, 64) if err != nil { return nil } fromCurr, err := ctx.GetArgIndex(1) if err != nil { return nil } toCurr := ctx.GetArgIndexDefault(2, "USD") newVal, err := util.ConvertCurrency(currValF, fromCurr, toCurr) if err != nil { return err } ctx.Reply(fmt.Sprintf("%.2f %v -> %.2f %v", currValF, fromCurr, newVal, toCurr)) return nil }, }
View Source
var Invite = &framework.Command{ Name: "invite", PermissionRequired: 0, OwnerOnly: false, Help: "", Exec: func(ctx *framework.Context) error { var inviteString bytes.Buffer InviteTemplate.Execute(&inviteString, ctx.Hanamaru.State.User.ID) ctx.Reply(fmt.Sprintf("Have fun with this: <%v>", inviteString.String())) return nil }, }
View Source
var InviteTemplate = template.Must(template.New("invite").Parse(`https://discordapp.com/oauth2/authorize?client_id={{.}}&scope=bot&permissions=8`))
View Source
var Minecraft = &framework.Command{ Name: "mc", PermissionRequired: 0, OwnerOnly: false, Help: "", Exec: func(ctx *framework.Context) error { mcName, err := ctx.GetArgIndex(0) rt := ctx.GetArgIndexDefault(1, util.Body) if err != nil { return err } p, err := util.LookupMinecraft(mcName) if err != nil { return fmt.Errorf("player not found: %v", mcName) } img, err := util.GetMinecraftSkin(p, util.MinecraftRenderType(rt)) if err != nil { return err } ctx.ReplyPNGImg(img, mcName) return nil }, }
View Source
var ServerInfo = &framework.Command{ Name: "server", PermissionRequired: 0, OwnerOnly: false, Exec: func(ctx *framework.Context) error { serverid, err := ctx.GetArgIndex(0) if err != nil { return err } g, err := ctx.Hanamaru.Guild(serverid) if err != nil { return err } ctx.Reply(fmt.Sprintf("%v: %v", g.Name, g.Channels)) return nil }, }
View Source
var Tag = &framework.Command{ Name: "tag", PermissionRequired: 0, OwnerOnly: false, Help: "Let's you tag messages", Exec: func(ctx *framework.Context) error { db := ctx.Hanamaru.Db if target := ctx.Message.ReferencedMessage; target != nil { name, err := ctx.GetArgIndex(0) if err != nil { return err } err = hdb.MutateAddTag(db, name, ctx.GuildID, target.ChannelID, target.ID) if err != nil { return err } ctx.Reply("Message tagged!") } else { option, err := ctx.GetArgIndex(0) if err != nil { return err } switch option { case "list": pageStr := ctx.GetArgIndexDefault(1, "1") page, err := strconv.Atoi(pageStr) if err != nil { return err } res, err := hdb.QueryListTags(db, ctx.GuildID, page-1) if err != nil { return err } if len(res) < 1 { return errors.New("no results found") } var s = "Tags: \n" s += strings.Join(res, "\n") ctx.Reply(s) case "delete": tagName, err := ctx.GetArgIndex(1) if err != nil { return err } hdb.MutateRemoveTagByName(db, ctx.GuildID, tagName) case "search": query, err := ctx.GetArgIndex(1) if err != nil { return err } res, err := hdb.QuerySearchTags(db, query, ctx.GuildID) if err != nil { return err } if len(res) < 1 { return errors.New("no results found") } var s = "Results: \n" s += strings.Join(res, "\n") ctx.Reply(s) default: tag, err := hdb.QueryTagByName(db, option, ctx.GuildID) if err != nil { return err } ctx.Reply(fmt.Sprintf("https://discord.com/channels/%v/%v/%v", tag.GuildID, tag.ChannelID, tag.MessageID)) } } return nil }, }
View Source
var Timezone = &framework.Command{ Name: "tz", PermissionRequired: 0, OwnerOnly: false, Help: `Converts the current time to another timezone. <time|now fmt. hh:mmAM/PM> <dest zone> <src zone>`, Exec: func(ctx *framework.Context) error { timeStr, err := ctx.GetArgIndex(0) if err != nil { return err } destTzStr, err := ctx.GetArgIndex(1) if err != nil { return err } srcTzStr := ctx.GetArgIndexDefault(2, "America/Los_Angeles") t, err := util.ConvertTimezone(timeStr, srcTzStr, destTzStr) if err != nil { return err } ctx.Reply(t.Format(time.Stamp)) return nil }, }
View Source
var Translate = &framework.Command{ Name: "translate", PermissionRequired: 0, OwnerOnly: false, Help: "Translates text: <text> <src lang (def. auto)> <target lang (def. en)>", Exec: func(ctx *framework.Context) error { text, err := ctx.GetArgIndex(0) if err != nil { return err } srcLang := ctx.GetArgIndexDefault(1, "") destLang := ctx.GetArgIndexDefault(2, "en") tr, err := util.Translate(text, srcLang, destLang) ctx.ReplyEmbed(GenTranslationEmbed(text, tr)) return nil }, }
View Source
var UserInfo = &framework.Command{ Name: "user", PermissionRequired: 0, OwnerOnly: false, Exec: func(ctx *framework.Context) error { return nil }, }
View Source
var WhatAnimeIsThat = &framework.Command{ Name: "wait", PermissionRequired: 0, OwnerOnly: false, Help: "Uses trace.moe to look up what anime the picture just sent is from", Exec: func(ctx *framework.Context) error { img, err := ctx.GetImage(0) if err != nil { return err } ta, err := util.TraceAnime(img) if err != nil { return err } if len(ta.Result) > 0 { _, err = ctx.ReplyEmbed(waitEmbed(ta.Result[0])) return err } return nil }, Setup: nil, }
Functions ¶
func GenTranslationEmbed ¶
func GenTranslationEmbed(orig, trans string) *discordgo.MessageEmbed
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.