Improve the wording in the placeholder embed and optimize the timer
All checks were successful
Build and push container image / build (push) Successful in 39s
All checks were successful
Build and push container image / build (push) Successful in 39s
This commit is contained in:
parent
c5d38e7e32
commit
e41be91a4c
@ -5,6 +5,7 @@ import (
|
|||||||
"corn-util/bot/toolbox"
|
"corn-util/bot/toolbox"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -20,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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."
|
noPermText = "You need to have a role with `Manage Server` permission to use this command."
|
||||||
attemptFailText = "There was an attempt..."
|
attemptFailText = "There was an attempt..."
|
||||||
noConfigValText = "Unconfigured"
|
noConfigValText = "Unconfigured"
|
||||||
@ -110,6 +111,13 @@ func ListenForCommand(e *events.ApplicationCommandInteractionCreate) {
|
|||||||
jsonDataBytes, _ := json.Marshal(readData)
|
jsonDataBytes, _ := json.Marshal(readData)
|
||||||
json.Unmarshal(jsonDataBytes, &jsonData)
|
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")
|
banRecordsCh, _ := e.SlashCommandInteractionData().OptChannel("ban-records")
|
||||||
googleSpreadsheet_Id, _ := e.SlashCommandInteractionData().OptString("google-spreadsheet-id")
|
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{
|
if _, err := e.Client().Rest().CreateMessage(banRecordsCh.ID, discord.MessageCreate{
|
||||||
Embeds: []discord.Embed{
|
Embeds: []discord.Embed{
|
||||||
{
|
{
|
||||||
Description: "Ban records on Google Sheets will now be sent in this channel.",
|
Description: "Ban records on Google Sheets will now be sent in this channel.\n" +
|
||||||
Color: mainEmbedColor,
|
fmt.Sprintf("*Add the bot's service account to the spreadsheet for this to work:*\n`%v`", googleServiceAcc.ClientEmail),
|
||||||
|
Color: mainEmbedColor,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
8
main.go
8
main.go
@ -47,13 +47,11 @@ func main() {
|
|||||||
|
|
||||||
log.Infof("Client ready!")
|
log.Infof("Client ready!")
|
||||||
log.Infof("Running Disgo %v & Go %v", disgo.Version, strings.TrimPrefix(runtime.Version(), "go"))
|
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{
|
client.Rest().CreateWebhookMessage(snowflake.MustParse(loaders.TokenLoader("hookId")), loaders.TokenLoader("hookToken"), discord.WebhookMessageCreate{Content: "Container has been reloaded."}, true, 0)
|
||||||
Content: "Container has been reloaded.",
|
|
||||||
}, true, 0)
|
|
||||||
|
|
||||||
ticker := time.NewTicker(30 * time.Second)
|
|
||||||
defer ticker.Stop()
|
|
||||||
go func() {
|
go func() {
|
||||||
|
ticker := time.NewTicker(30 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
Reference in New Issue
Block a user