Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var About *include.Command = &include.Command{ Data: &discordgo.ApplicationCommand{ Name: "about", Description: "View detailed information about the current installation of BloqGo.", IntegrationTypes: &[]discordgo.ApplicationIntegrationType{ discordgo.ApplicationIntegrationUserInstall, discordgo.ApplicationIntegrationGuildInstall, }, Contexts: &[]discordgo.InteractionContextType{ discordgo.InteractionContextGuild, discordgo.InteractionContextPrivateChannel, discordgo.InteractionContextBotDM, }, NSFW: include.NSFW(false), }, Handler: func(s *discordgo.Session, c *discordgo.ApplicationCommandInteractionData, i *discordgo.Interaction) error { ver, err := include.Version() if err != nil { return err } else { log.Info("Sending about message in guild of ID %s", i.GuildID) respondEmbed := &discordgo.MessageEmbed{ Author: &discordgo.MessageEmbedAuthor{ Name: s.State.User.Username, IconURL: s.State.User.AvatarURL("512"), }, Title: fmt.Sprintf("BloqGo `v%s`", ver), Description: fmt.Sprintf("Running as Discord bot client **`%s`**`#%s` (`%s`) on shard **#%v**", s.State.User.Username, s.State.User.Discriminator, s.State.User.ID, s.ShardID), Color: assets.Colors.Primary, Fields: []*discordgo.MessageEmbedField{ { Name: "Go Version", Value: fmt.Sprintf("`%s`", runtime.Version()), Inline: true, }, { Name: "Uptime", Value: fmt.Sprintf("%s • <t:%v:R>", include.GetUptimeFormatted(), include.GetUptime()), Inline: true, }, { Name: fmt.Sprintf("%s Need Help?", assets.Icons.Self), Value: "Join **[dsc.gg/bloqbit](https://www.dsc.gg/bloqbit)**", Inline: false, }, }, Footer: &discordgo.MessageEmbedFooter{ Text: "This command is in the works - expect more information to be added soon.", }, } return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ respondEmbed, }, }, }) } }, }
View Source
var Avatar *include.Command = &include.Command{ Data: &discordgo.ApplicationCommand{ Name: "avatar", Description: "View a user's profile picture.", IntegrationTypes: &[]discordgo.ApplicationIntegrationType{ discordgo.ApplicationIntegrationUserInstall, discordgo.ApplicationIntegrationGuildInstall, }, Contexts: &[]discordgo.InteractionContextType{ discordgo.InteractionContextGuild, }, NSFW: include.NSFW(false), Options: []*discordgo.ApplicationCommandOption{ { Name: "user", Description: "The user whose profile picture to view.", Type: discordgo.ApplicationCommandOptionUser, Required: false, }, }, }, Handler: func(s *discordgo.Session, c *discordgo.ApplicationCommandInteractionData, i *discordgo.Interaction) error { user := c.GetOption("user") var username string var globalAv string var serverAv string if user != nil { u := user.UserValue(s) if u != nil { m, err := s.GuildMember(i.GuildID, u.ID) globalAv = u.AvatarURL("1024") if err != nil { serverAv = u.AvatarURL("1024") } else { serverAv = m.AvatarURL("1024") } username = u.Username } else { return fmt.Errorf("couldn't get user from option") } } else { if i.Member != nil { globalAv = i.Member.User.AvatarURL("1024") serverAv = i.Member.AvatarURL("1024") username = i.Member.User.Username } else if i.User != nil { globalAv = i.User.AvatarURL("1024") serverAv = globalAv username = i.User.Username } else { return fmt.Errorf("couldn't get member who executed avatar command") } } respondEmbed := &discordgo.MessageEmbed{ Title: fmt.Sprintf("%s %s's Avatar", assets.Icons.Info, username), Color: assets.Colors.Primary, Thumbnail: &discordgo.MessageEmbedThumbnail{ URL: globalAv, Width: 1024, Height: 1024, }, Image: &discordgo.MessageEmbedImage{ URL: serverAv, Width: 1024, Height: 1024, }, } return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ respondEmbed, }, }, }) }, }
View Source
var MemberCount *include.Command = &include.Command{ Data: &discordgo.ApplicationCommand{ Name: "member-count", Description: "View the member count of this server.", IntegrationTypes: &[]discordgo.ApplicationIntegrationType{ discordgo.ApplicationIntegrationGuildInstall, }, Contexts: &[]discordgo.InteractionContextType{ discordgo.InteractionContextGuild, }, NSFW: include.NSFW(false), }, Handler: func(s *discordgo.Session, c *discordgo.ApplicationCommandInteractionData, i *discordgo.Interaction) error { guild, err := s.GuildWithCounts(i.GuildID) if err != nil { return err } else { total := guild.MemberCount bots := 0 log.Debug("Getting member and bot counts for guild of ID %s", guild.ID) for _, Member := range guild.Members { if Member.User.Bot { bots++ } } respondEmbed := &discordgo.MessageEmbed{ Author: &discordgo.MessageEmbedAuthor{ Name: guild.Name, IconURL: guild.IconURL("128"), }, Color: assets.Colors.Primary, Fields: []*discordgo.MessageEmbedField{ { Name: "Member Count", Value: fmt.Sprintf("**```%v```**", total), Inline: false, }, }, Footer: &discordgo.MessageEmbedFooter{ Text: fmt.Sprintf("%v Bots", bots), }, } log.Info("Guild of ID %s has %v members (%v bots)", guild.ID, total, bots) return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ respondEmbed, }, }, }) } }, }
View Source
var Ping *include.Command = &include.Command{ Data: &discordgo.ApplicationCommand{ Name: "ping", Description: "Ping the bot, test its latency.", IntegrationTypes: &[]discordgo.ApplicationIntegrationType{ discordgo.ApplicationIntegrationUserInstall, discordgo.ApplicationIntegrationGuildInstall, }, Contexts: &[]discordgo.InteractionContextType{ discordgo.InteractionContextGuild, discordgo.InteractionContextPrivateChannel, discordgo.InteractionContextBotDM, }, NSFW: include.NSFW(false), }, Handler: func(s *discordgo.Session, c *discordgo.ApplicationCommandInteractionData, i *discordgo.Interaction) error { created, err := discordgo.SnowflakeTimestamp(i.ID) if err == nil { latency := time.Since(created).Milliseconds() respondEmbed := &discordgo.MessageEmbed{ Title: fmt.Sprintf("%s Ping", assets.Icons.Info), Color: assets.Colors.Primary, Fields: []*discordgo.MessageEmbedField{ { Name: "Latency", Value: fmt.Sprintf("%vms", latency), Inline: false, }, { Name: "API Latency", Value: fmt.Sprintf("%vms", s.HeartbeatLatency().Milliseconds()), Inline: false, }, }, } return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ respondEmbed, }, Flags: discordgo.MessageFlagsEphemeral, }, }) } else { return err } }, }
View Source
var Say *include.Command = &include.Command{ Data: &discordgo.ApplicationCommand{ Name: "say", Description: "Send a message in a channel", IntegrationTypes: &[]discordgo.ApplicationIntegrationType{ discordgo.ApplicationIntegrationGuildInstall, }, Contexts: &[]discordgo.InteractionContextType{ discordgo.InteractionContextGuild, }, NSFW: include.NSFW(false), Options: []*discordgo.ApplicationCommandOption{ { Name: "message", Description: "The message to send in the channel", Type: discordgo.ApplicationCommandOptionString, Required: true, }, { Name: "channel", Description: "The channel to send a message to.", Type: discordgo.ApplicationCommandOptionChannel, ChannelTypes: []discordgo.ChannelType{ discordgo.ChannelTypeGuildText, discordgo.ChannelTypeGuildNews, discordgo.ChannelTypeGuildPublicThread, discordgo.ChannelTypeGuildPrivateThread, discordgo.ChannelTypeGuildNewsThread, discordgo.ChannelTypeGuildVoice, discordgo.ChannelTypeGuildStageVoice, }, Required: false, }, }, }, Handler: func(s *discordgo.Session, c *discordgo.ApplicationCommandInteractionData, i *discordgo.Interaction) error { message := c.GetOption("message") if message != nil { msg := message.StringValue() respondEmbed := &discordgo.MessageEmbed{ Description: msg, Color: assets.Colors.Primary, } channel := c.GetOption("channel") if channel != nil { chnl := channel.ChannelValue(s) msg, err := s.ChannelMessageSendEmbed(chnl.ID, respondEmbed) if err != nil { return err } else { if chnl.ID == i.ChannelID { return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ { Description: fmt.Sprintf("%s Message sent.", assets.Icons.Check), Color: assets.Colors.Primary, }, }, Flags: discordgo.MessageFlagsEphemeral, }, }) } else { url := fmt.Sprintf("https://discord.com/channels/%s/%s/%s", chnl.GuildID, chnl.ID, msg.ID) return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ { Description: fmt.Sprintf("%s Message sent in %s.", assets.Icons.Check, url), Color: assets.Colors.Primary, }, }, }, }) } } } else { return s.InteractionRespond(i, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Embeds: []*discordgo.MessageEmbed{ respondEmbed, }, }, }) } } else { return fmt.Errorf("couldn't get message for say command") } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.