Skip to content

Commit

Permalink
rebuild config to have extra url to prevent bootloop
Browse files Browse the repository at this point in the history
  • Loading branch information
1nv8rzim committed Dec 13, 2023
1 parent 081b71f commit 075d2c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 6 additions & 1 deletion commands/slash/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

var (
// VoteURL is the URL for the vote page
VoteURL = config.GetString("vote.url")
)

// Vote is a slash command that creates a vote
func Vote() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) {
return &discordgo.ApplicationCommand{
Expand Down Expand Up @@ -264,7 +269,7 @@ func Vote() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discor
return
}

out := "```\n" + entVoteResults.Plain + "\n```" + "\nResults Graph:\n" + config.Web.Protocol + "://" + config.Web.Hostname + ":" + config.Web.Port + "/vote/" + voteSlug + "\n"
out := "```\n" + entVoteResults.Plain + "\n```" + "\nResults Graph:\n" + VoteURL + "/vote/" + voteSlug + "\n"

_, err = s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
Content: &out,
Expand Down
1 change: 0 additions & 1 deletion config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func web() structs.WebConfig {
return structs.WebConfig{
Port: viper.GetString("web.port"),
Hostname: viper.GetString("web.hostname"),
Protocol: viper.GetString("web.protocol"),
}
}

Expand Down
2 changes: 2 additions & 0 deletions config_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ commands:
prospective_role_id:
staff_role_id:
alumni_role_id:
vote:
url: http(s)://example.com

3 changes: 0 additions & 3 deletions structs/webConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ type WebConfig struct {

// Hostname is the hostname to listen on
Hostname string

// Protocol is the protocol to use
Protocol string
}

0 comments on commit 075d2c2

Please sign in to comment.