diff --git a/aria/bot.go b/aria/bot.go index 2213e53..f82ea10 100644 --- a/aria/bot.go +++ b/aria/bot.go @@ -353,16 +353,34 @@ func (b *bot) deleteMessageAfter(m *discordgo.Message, t time.Duration, force bo } } +func (b *bot) deleteAfterChannelMessageSend( + d time.Duration, + ignoreKeepMsgChannel bool, + channelID string, + content string, +) (*discordgo.Message, error) { + m, err := b.ChannelMessageSend(channelID, content) + if err != nil { + return nil, err + } + + go b.deleteMessageAfter(m, d, ignoreKeepMsgChannel) + return m, nil +} + // send MessageEmbed to channel then delete message after d // Returns Message and error immidiately after message is sent func (b *bot) deleteAfterChannelMessageSendEmbed( - d time.Duration, force bool, - channelID string, embed *discordgo.MessageEmbed, + d time.Duration, + ignoreKeepMsgChannel bool, + channelID string, + embed *discordgo.MessageEmbed, ) (*discordgo.Message, error) { m, err := b.ChannelMessageSendEmbed(channelID, embed) if err != nil { return nil, err } - go b.deleteMessageAfter(m, d, force) + + go b.deleteMessageAfter(m, d, ignoreKeepMsgChannel) return m, nil } diff --git a/aria/commands.go b/aria/commands.go index 6cc095c..a3f7158 100644 --- a/aria/commands.go +++ b/aria/commands.go @@ -386,7 +386,7 @@ func (b *bot) cmdInvite(m *discordgo.Message, _ []string) { func (b *bot) cmdToken(m *discordgo.Message, _ []string) { b.sendAriaRequest(&request{ OP: "token", - Postback: m.ChannelID, + Postback: m.Author.ID, }) } diff --git a/aria/packets.go b/aria/packets.go index d4cfb99..5ec1b5e 100644 --- a/aria/packets.go +++ b/aria/packets.go @@ -109,6 +109,7 @@ func onInvite(b *bot, pb string, d *inviteData) { uc, err := b.UserChannelCreate(pb) if err != nil { log.Printf("failed to create user channel: %v", err) + return } e := newEmbed() @@ -133,15 +134,23 @@ func onToken(b *bot, pb string, d *tokenData) { return } - e := newEmbed() - e.Color = 0x57ffae - e.Title = "New token" - e.Description = fmt.Sprintf("Your token is:\n`%s`", d.Token) - - if _, err := b.deleteAfterChannelMessageSendEmbed(msgTimeout, true, pb, e); err != nil { - log.Printf("failed to send token embed: %v\n", err) + uc, err := b.UserChannelCreate(pb) + if err != nil { + log.Printf("failed to create user channel: %v", err) return } + + contents := []string{ + "Your new token is:", + d.Token, + } + + for _, content := range contents { + if _, err := b.deleteAfterChannelMessageSend(msgTimeout, true, uc.ID, content); err != nil { + log.Printf("failed to send token embed: %v\n", err) + return + } + } } func onStateEvent(b *bot, pb string, ed *stateEventData) {