Skip to content

Commit

Permalink
Fix failing build due to incompatible dependency updates (#83)
Browse files Browse the repository at this point in the history
* Fixed broken updates

* Fixed nullptr dereference

* Updated dependencies
  • Loading branch information
Kardbord authored Feb 19, 2023
1 parent 7375be5 commit c4821c2
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 92 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/TannerKvarfordt/Kard-bot
go 1.18

require (
github.com/TannerKvarfordt/gopenai v0.1.1-beta
github.com/TannerKvarfordt/hfapigo v0.0.4
github.com/TannerKvarfordt/imgflipgo v1.0.5
github.com/TannerKvarfordt/ubiquity v0.2.1
github.com/TannerKvarfordt/gopenai v0.1.2-beta
github.com/TannerKvarfordt/hfapigo v0.0.5
github.com/TannerKvarfordt/imgflipgo v1.0.6
github.com/TannerKvarfordt/ubiquity v0.2.2
github.com/bwmarrin/discordgo v0.27.0
github.com/deadshot465/owoify-go v1.0.1
github.com/forPelevin/gomoji v1.1.8
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/TannerKvarfordt/gopenai v0.1.1-beta h1:aocEuxS6jLHLnoa1aH//18fuRbmeYTsFVhFSygmee3I=
github.com/TannerKvarfordt/gopenai v0.1.1-beta/go.mod h1:VJ5vqh+nTGVmZmeAWJBlMjaaFb/XLAO8vW/FzlWvN5U=
github.com/TannerKvarfordt/hfapigo v0.0.4 h1:HDuUoIotKm0hCg7piwc1kQIdGjgDMgFyanMRWPWIFJI=
github.com/TannerKvarfordt/hfapigo v0.0.4/go.mod h1:XKhHnldnhSZNCrRZclWr2D/A/UlEGaQ8OxpM7r8wQpE=
github.com/TannerKvarfordt/imgflipgo v1.0.5 h1:y9q6Vt4cq0bH3FvlDuEfqabZURtdcD7KYZ4EYdWDWIw=
github.com/TannerKvarfordt/imgflipgo v1.0.5/go.mod h1:wvuZ3+UAyCtKuvqn0Thcjhj31yetO8/baXPBYI5i9Ug=
github.com/TannerKvarfordt/ubiquity v0.2.1 h1:50UxqYBrWFuH47o0styX29/zC0PykfyHyqehFbAlkiU=
github.com/TannerKvarfordt/ubiquity v0.2.1/go.mod h1:TeemeL8b8YiXysB1BlOMwmA8nhwIKeg+ZiOJ6Yiwmlg=
github.com/TannerKvarfordt/gopenai v0.1.2-beta h1:Zy4AjMmyyLlwgC49nKWiAdojvYkHf9AT5hG+LMGzdGk=
github.com/TannerKvarfordt/gopenai v0.1.2-beta/go.mod h1:X42mdDQIih6TLzctpf8Wp/cIGpHaMiImMWZ+BQz7nT0=
github.com/TannerKvarfordt/hfapigo v0.0.5 h1:E8OZQxpfQEHRrXjHlc5vHBUMLqL1XvtdqDyNY27rUT4=
github.com/TannerKvarfordt/hfapigo v0.0.5/go.mod h1:s+zHgKdagSPlw8xPMokwQaS32BakBMOljQImxStboF0=
github.com/TannerKvarfordt/imgflipgo v1.0.6 h1:u7HRbGsTBE1VjrQuk2UUJTJEDf/jvbh0QVhGPF6m/zA=
github.com/TannerKvarfordt/imgflipgo v1.0.6/go.mod h1:wLVihMPHZAVEfAzU047L6tIxdm1WZ8KvZc71DrOrseY=
github.com/TannerKvarfordt/ubiquity v0.2.2 h1:SWbXc58MZjrdmJxk/WjdZKbfuHbWTAJ9ToxyDnhZAnQ=
github.com/TannerKvarfordt/ubiquity v0.2.2/go.mod h1:6X6j49wHJuqLF1OBq5hfdo25SZnJDGl59RRvIpnxw4Q=
github.com/bwmarrin/discordgo v0.27.0 h1:4ZK9KN+rGIxZ0fdGTmgdCcliQeW8Zhu6MnlFI92nf0Q=
github.com/bwmarrin/discordgo v0.27.0/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
2 changes: 1 addition & 1 deletion kardbot/bot_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func botInfo(s *discordgo.Session, i *discordgo.InteractionCreate) {
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
Embeds: []*discordgo.MessageEmbed{embed.Truncate().MessageEmbed},
Files: []*discordgo.File{
{
Expand Down
8 changes: 5 additions & 3 deletions kardbot/botdms.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func deleteBotDMs(s *discordgo.Session, i *discordgo.InteractionCreate) {
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -67,8 +67,9 @@ func deleteBotDMs(s *discordgo.Session, i *discordgo.InteractionCreate) {
}

time.Sleep(time.Millisecond * 100)
errMsg := fmt.Sprintf("looks like you tried to use `/%s` outside of our DMs. Run it from there instead! :)", delBotDMCmd)
s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: fmt.Sprintf("looks like you tried to use `/%s` outside of our DMs. Run it from there instead! :)", delBotDMCmd),
Content: &errMsg,
})
return
}
Expand Down Expand Up @@ -117,8 +118,9 @@ func deleteBotDMs(s *discordgo.Session, i *discordgo.InteractionCreate) {
}
}

errMsg := fmt.Sprintf("Deleted last %d bot DMs", mathutils.Min(msgsToDelete, msgLimit))
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: fmt.Sprintf("Deleted last %d bot DMs", mathutils.Min(msgsToDelete, msgLimit)),
Content: &errMsg,
})
if err != nil {
log.Error(err)
Expand Down
13 changes: 7 additions & 6 deletions kardbot/compliments.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func morningComplimentOptIn(s *discordgo.Session, i *discordgo.InteractionCreate
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s, you are subscribed to receive morning compliments as long as the bot is up, but there was an error persisting your subscription. Please try to opt-in again.", metadata.AuthorUsername),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -192,7 +192,7 @@ func morningComplimentOptOut(s *discordgo.Session, i *discordgo.InteractionCreat
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s, you are unsubscribed from morning compliments as long as the bot is up, but there was an error persisting your opt-out. Please try to opt-out again.", metadata.AuthorUsername),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -235,7 +235,7 @@ func eveningComplimentOptIn(s *discordgo.Session, i *discordgo.InteractionCreate
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s, you are subscribed to receive evening compliments as long as the bot is up, but there was an error persisting your subscription. Please try to opt-in again.", metadata.AuthorUsername),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -277,7 +277,7 @@ func eveningComplimentOptOut(s *discordgo.Session, i *discordgo.InteractionCreat
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s, you are unsubscribed from evening compliments as long as the bot is up, but there was an error persisting your opt-out. Please try to opt-out again.", metadata.AuthorUsername),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -319,7 +319,7 @@ func getCompliment(s *discordgo.Session, i *discordgo.InteractionCreate) {
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand All @@ -339,8 +339,9 @@ func getCompliment(s *discordgo.Session, i *discordgo.InteractionCreate) {
log.Infof("Told %s that '%s'", metadata.AuthorUsername, compliment)

time.Sleep(time.Millisecond * 250) // give a bit for the initial response to be received
content := "Sent you a compliment! 💛"
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: "Sent you a compliment! 💛",
Content: &content,
})
if err != nil {
log.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions kardbot/creepydm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func creepyDMsOptIn(s *discordgo.Session, i *discordgo.InteractionCreate) error
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s, you are subscribed to creepy DMs as long as the bot remains up, but there was an error persisting your subscription. Please try to opt-in again.", metadata.AuthorUsername),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand Down Expand Up @@ -231,7 +231,7 @@ func getCreepyDM(s *discordgo.Session, i *discordgo.InteractionCreate) error {
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Sent you a creepy DM 😈",
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
}
Expand Down
3 changes: 2 additions & 1 deletion kardbot/dalle2.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ func handleDalle2Cmd(s *discordgo.Session, i *discordgo.InteractionCreate) {
return
}

errMsg := fmt.Sprintf("> %s\n\nImage generated using [DALL·E 2](<https://openai.com/dall-e-2/>).", prompt)
_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: fmt.Sprintf("> %s\n\nImage generated using [DALL·E 2](<https://openai.com/dall-e-2/>).", prompt),
Content: &errMsg,
Files: []*discordgo.File{
{
Name: "Dalle-2-Output.png",
Expand Down
22 changes: 11 additions & 11 deletions kardbot/dg_helpers/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/bwmarrin/discordgo"
)

//Embed ...
// Embed ...
type Embed struct {
*discordgo.MessageEmbed
}
Expand All @@ -25,12 +25,12 @@ const (
EmbedLimit = 4000
)

//NewEmbed returns a new embed object
// NewEmbed returns a new embed object
func NewEmbed() *Embed {
return &Embed{&discordgo.MessageEmbed{}}
}

//SetTitle ...
// SetTitle ...
func (e *Embed) SetTitle(name string) *Embed {
e.Title = name
return e
Expand Down Expand Up @@ -61,7 +61,7 @@ func (e *Embed) SetVideo(url string, args ...int) *Embed {
return e
}

//SetDescription [desc]
// SetDescription [desc]
func (e *Embed) SetDescription(description string) *Embed {
if len(description) > 2048 {
description = description[:2048]
Expand All @@ -70,7 +70,7 @@ func (e *Embed) SetDescription(description string) *Embed {
return e
}

//AddField [name] [value]
// AddField [name] [value]
func (e *Embed) AddField(name, value string) *Embed {
if len(value) > 1024 {
value = value[:1024]
Expand All @@ -89,7 +89,7 @@ func (e *Embed) AddField(name, value string) *Embed {

}

//SetFooter [Text] [iconURL]
// SetFooter [Text] [iconURL]
func (e *Embed) SetFooter(args ...string) *Embed {
iconURL := ""
text := ""
Expand Down Expand Up @@ -117,7 +117,7 @@ func (e *Embed) SetFooter(args ...string) *Embed {
return e
}

//SetImage ...
// SetImage ...
func (e *Embed) SetImage(args ...string) *Embed {
var URL string
var proxyURL string
Expand All @@ -138,7 +138,7 @@ func (e *Embed) SetImage(args ...string) *Embed {
return e
}

//SetThumbnail ...
// SetThumbnail ...
func (e *Embed) SetThumbnail(args ...string) *Embed {
var URL string
var proxyURL string
Expand All @@ -159,7 +159,7 @@ func (e *Embed) SetThumbnail(args ...string) *Embed {
return e
}

//SetAuthor ...
// SetAuthor ...
func (e *Embed) SetAuthor(args ...string) *Embed {
var (
name string
Expand Down Expand Up @@ -194,13 +194,13 @@ func (e *Embed) SetAuthor(args ...string) *Embed {
return e
}

//SetURL ...
// SetURL ...
func (e *Embed) SetURL(URL string) *Embed {
e.URL = URL
return e
}

//SetColor ...
// SetColor ...
func (e *Embed) SetColor(clr int) *Embed {
e.Color = clr
return e
Expand Down
4 changes: 2 additions & 2 deletions kardbot/dnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ func handleDnDButtonPress(s *discordgo.Session, i *discordgo.InteractionCreate)
content += fmt.Sprintf("Total: %d", total)
}

flags := uint64(0)
var flags discordgo.MessageFlags = 0
if cfg.Ephemeral {
flags = InteractionResponseFlagEphemeral
flags = discordgo.MessageFlagsEphemeral
}

if cfg.DM {
Expand Down
10 changes: 5 additions & 5 deletions kardbot/interactionErrHandling.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func interactionRespondEphemeralError(s *discordgo.Session, i *discordgo.Interac
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprint(errResp),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
Expand All @@ -138,7 +138,7 @@ func interactionRespondEphemeralError(s *discordgo.Session, i *discordgo.Interac
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Something went wrong while processing your command. 😔",
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
Components: errReportMsgComponents(errUUID),
},
})
Expand Down Expand Up @@ -183,7 +183,7 @@ func interactionFollowUpEphemeralError(s *discordgo.Session, i *discordgo.Intera
if !notifyOwner {
_, err = s.FollowupMessageCreate(i.Interaction, false, &discordgo.WebhookParams{
Content: fmt.Sprint(errResp),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
})
if err != nil {
log.Error(err)
Expand All @@ -202,7 +202,7 @@ func followupWithError(s *discordgo.Session, i *discordgo.InteractionCreate, err
errUUID := uuid.New()
_, err := s.FollowupMessageCreate(i.Interaction, false, &discordgo.WebhookParams{
Content: "Something went wrong while processing your command. 😔",
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
Components: errReportMsgComponents(errUUID),
})
if err != nil {
Expand Down Expand Up @@ -259,7 +259,7 @@ func handleErrorReportSelection(s *discordgo.Session, i *discordgo.InteractionCr
Type: discordgo.InteractionResponseUpdateMessage,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("%s\nThanks for submitting an error report! %s has been notified of the problem.", i.Message.Content, ownerMention),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
AllowedMentions: &discordgo.MessageAllowedMentions{
Users: []string{getOwnerID()},
},
Expand Down
2 changes: 0 additions & 2 deletions kardbot/interactionUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/bwmarrin/discordgo"
)

const InteractionResponseFlagEphemeral = uint64(1 << 6)

func authorIsSelf(s *discordgo.Session, i *discordgo.InteractionCreate) (bool, error) {
if s == nil || i == nil {
return false, fmt.Errorf("interaction or session is nil")
Expand Down
4 changes: 2 additions & 2 deletions kardbot/madlibs.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func handleMadLibCmd(s *discordgo.Session, i *discordgo.InteractionCreate) {
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: fmt.Sprintf("No blanks provided. Provide a prompt string containing at least one of the following mask: `%s`.\nFor example: `The quick brown %s jumps over the lazy %s.`", madlibBlank, madlibBlank, madlibBlank),
Flags: InteractionResponseFlagEphemeral,
Flags: discordgo.MessageFlagsEphemeral,
},
})
return
Expand Down Expand Up @@ -101,7 +101,7 @@ func handleMadLibCmd(s *discordgo.Session, i *discordgo.InteractionCreate) {
}

_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: output,
Content: &output,
})
if err != nil {
log.Error(err)
Expand Down
6 changes: 3 additions & 3 deletions kardbot/memetools.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ func buildMemeCommands() []*discordgo.ApplicationCommand {
}

func buildAMeme(s *discordgo.Session, i *discordgo.InteractionCreate) {
flags := uint64(0)
var flags discordgo.MessageFlags = 0
isPreview := i.ApplicationCommandData().Options[previewOptIdx].BoolValue()
if isPreview {
flags = InteractionResponseFlagEphemeral
flags = discordgo.MessageFlagsEphemeral
}
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
Expand Down Expand Up @@ -302,7 +302,7 @@ func buildAMeme(s *discordgo.Session, i *discordgo.InteractionCreate) {
SetImage(resp.Data.URL)

_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Embeds: []*discordgo.MessageEmbed{embed.MessageEmbed},
Embeds: &[]*discordgo.MessageEmbed{embed.MessageEmbed},
})
if err != nil {
log.Error(err)
Expand Down
Loading

0 comments on commit c4821c2

Please sign in to comment.