func messageFunc(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) { if service.IsMe(message) || !bruxism.MatchesCommand(service, "myson", message) || service.Name() != bruxism.DiscordServiceName { return } discord := service.(*bruxism.Discord) discord.Session.ChannelMessageSendEmbed(message.Channel(), &discordgo.MessageEmbed{ Color: discord.UserColor(service.UserID(), message.Channel()), Description: "Don't ever talk to me or my son ever again.", Author: &discordgo.MessageEmbedAuthor{ Name: discord.NicknameForID(service.UserID(), service.UserName(), message.Channel()), IconURL: discordgo.EndpointUserAvatar(service.UserID(), discord.Session.State.User.Avatar), }, }) }
func avatarMessageFunc(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) { if !service.IsMe(message) { if bruxism.MatchesCommand(service, "avatar", message) { query := strings.Join(strings.Split(message.RawMessage(), " ")[1:], " ") id := message.UserID() match := userIDRegex.FindStringSubmatch(query) if match != nil { id = match[1] } discord := service.(*bruxism.Discord) u, err := discord.Session.User(id) if err != nil { return } service.SendMessage(message.Channel(), discordgo.EndpointUserAvatar(u.ID, u.Avatar)) } } }
// UserAvatar returns the avatar url for this message. func (m *DiscordMessage) UserAvatar() string { if m.DiscordgoMessage.Author == nil { return "" } return discordgo.EndpointUserAvatar(m.DiscordgoMessage.Author.ID, m.DiscordgoMessage.Author.Avatar) }