diff --git a/events/interaction.go b/events/interaction.go index c28b8a1..1edde0f 100644 --- a/events/interaction.go +++ b/events/interaction.go @@ -5,6 +5,7 @@ import ( "corn-util/bot/toolbox" "encoding/json" "fmt" + "os" "runtime" "strings" "time" @@ -20,7 +21,7 @@ import ( ) var ( - mainEmbedColor = 0xff69b4 //0xf9c62c - main embed color for the bot (saffron / yellow) + mainEmbedColor = 0xf9c62c // main embed color for the bot (saffron / yellow) noPermText = "You need to have a role with `Manage Server` permission to use this command." attemptFailText = "There was an attempt..." noConfigValText = "Unconfigured" @@ -110,6 +111,13 @@ func ListenForCommand(e *events.ApplicationCommandInteractionCreate) { jsonDataBytes, _ := json.Marshal(readData) json.Unmarshal(jsonDataBytes, &jsonData) + type googleServiceAccStruct struct { + ClientEmail string `json:"client_email"` + } + readGCPJSON, _ := os.ReadFile("GCP_SERVICE.json") + googleServiceAcc := googleServiceAccStruct{} + json.Unmarshal(readGCPJSON, &googleServiceAcc) + banRecordsCh, _ := e.SlashCommandInteractionData().OptChannel("ban-records") googleSpreadsheet_Id, _ := e.SlashCommandInteractionData().OptString("google-spreadsheet-id") @@ -159,8 +167,9 @@ func ListenForCommand(e *events.ApplicationCommandInteractionCreate) { if _, err := e.Client().Rest().CreateMessage(banRecordsCh.ID, discord.MessageCreate{ Embeds: []discord.Embed{ { - Description: "Ban records on Google Sheets will now be sent in this channel.", - Color: mainEmbedColor, + Description: "Ban records on Google Sheets will now be sent in this channel.\n" + + fmt.Sprintf("*Add the bot's service account to the spreadsheet for this to work:*\n`%v`", googleServiceAcc.ClientEmail), + Color: mainEmbedColor, }, }, }); err != nil { diff --git a/main.go b/main.go index cd2d654..e07284f 100644 --- a/main.go +++ b/main.go @@ -47,13 +47,11 @@ func main() { log.Infof("Client ready!") log.Infof("Running Disgo %v & Go %v", disgo.Version, strings.TrimPrefix(runtime.Version(), "go")) - client.Rest().CreateWebhookMessage(snowflake.MustParse(loaders.TokenLoader("hookId")), loaders.TokenLoader("hookToken"), discord.WebhookMessageCreate{ - Content: "Container has been reloaded.", - }, true, 0) + client.Rest().CreateWebhookMessage(snowflake.MustParse(loaders.TokenLoader("hookId")), loaders.TokenLoader("hookToken"), discord.WebhookMessageCreate{Content: "Container has been reloaded."}, true, 0) - ticker := time.NewTicker(30 * time.Second) - defer ticker.Stop() go func() { + ticker := time.NewTicker(30 * time.Second) + defer ticker.Stop() for { select { case <-ticker.C: