1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-23 01:20:11 +00:00

Update discord.go

Hopefully functional, any errors are coming from elsewhere
This commit is contained in:
Violet Scheen 2023-09-30 12:10:38 -04:00 committed by GitHub
parent c43d5cf1b0
commit 27f85f866e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,8 +130,7 @@ func (d *DiscordDaemon) run() {
d.inviteChannelName = invChannel d.inviteChannelName = invChannel
} }
} }
//dg.Activity.Name = "/" + d.app.config.Section("discord").Key("start_command").MustString("start") err = d.bot.UpdateGameStatus(0, "/"+d.app.config.Section("discord").Key("start_command").MustString("start"))
//dg.Activity.Type = dg.ActivityTypeGame
defer d.deregisterCommands() defer d.deregisterCommands()
defer d.bot.Close() defer d.bot.Close()
@ -352,25 +351,25 @@ func (d *DiscordDaemon) registerCommands() {
Name: "user", Name: "user",
Description: "User to Invite", Description: "User to Invite",
Required: true, Required: true,
}, // running with just one option for now to mesh with what we've got, also may have the syntax wrong here
/*{
Type: dg.ApplicationCommandOptionInteger,
Name: "expire after",
Description: "Time in minutes before expiration",
Required: false,
}, },
//{ {
// Type: dg.ApplicationCommandOptionInteger, Type: dg.ApplicationCommandOptionString,
// Name: "expire after", Name: "label",
// Description: "Time in minutes before expiration", Description: "Label to apply to the user created with this invite",
// Required: false, Required: false,
//}, },
//{ {
// Type: dg.ApplicationCommandOptionString, Type: dg.ApplicationCommandOptionString,
// Name: "label", Name: "profile",
// Description: "Label to apply to the user created with this invite", Description: "Profile to apply to the user created with this invite",
// Required: false, Required: false,
//}, }, */
//{
// Type: dg.ApplicationCommandOptionString,
// Name: "profile",
// Description: "Profile to apply to the user created with this invite",
// Required: false,
//},
}, },
}, },
} }
@ -542,6 +541,7 @@ func (d *DiscordDaemon) cmdInvite(s *dg.Session, i *dg.InteractionCreate, lang s
channel, err := s.UserChannelCreate(i.Interaction.Member.User.ID) channel, err := s.UserChannelCreate(i.Interaction.Member.User.ID)
requestor := d.MustGetUser(channel.ID, i.Interaction.Member.User.ID, i.Interaction.Member.User.Discriminator, i.Interaction.Member.User.Username) requestor := d.MustGetUser(channel.ID, i.Interaction.Member.User.ID, i.Interaction.Member.User.Discriminator, i.Interaction.Member.User.Username)
d.users[i.Interaction.Member.User.ID] = requestor d.users[i.Interaction.Member.User.ID] = requestor
d.app.debug.Println("Requested by: %v: %s:", requestor.JellyfinID, d.users[i.Interaction.Member.User.ID].JellyfinID)
invuser := fmt.Sprintf("%v", i.ApplicationCommandData().Options[0].Value) invuser := fmt.Sprintf("%v", i.ApplicationCommandData().Options[0].Value)
d.app.debug.Println(invuser) d.app.debug.Println(invuser)
//label := i.ApplicationCommandData().Options[2].StringValue() //label := i.ApplicationCommandData().Options[2].StringValue()
@ -551,8 +551,8 @@ func (d *DiscordDaemon) cmdInvite(s *dg.Session, i *dg.InteractionCreate, lang s
//if mins > 0 { //if mins > 0 {
// expmin = mins // expmin = mins
//} //}
// Check whether requestor is linked to the admin account* // Need to check whether requestor is linked to the admin account *possibly add Admin bool to DiscordUser struct
// variation of app.GenerateInvite, some parts commented to potentially add back in later // variation of app.GenerateInvite, some parts commented to potentially add back in later with the other options
//d.app.debug.Println("Generating new invite with options: %s: %i: %s: %s", invuser, expmin, profile, label) //d.app.debug.Println("Generating new invite with options: %s: %i: %s: %s", invuser, expmin, profile, label)
currentTime := time.Now() currentTime := time.Now()
validTill := currentTime.Add(time.Minute*time.Duration(expmin)) validTill := currentTime.Add(time.Minute*time.Duration(expmin))