refactor: everthing discord command
made it private and made it deffer the message instead of executing after
This commit is contained in:
parent
0c2ab10297
commit
0a735aaf8a
|
@ -134,33 +134,6 @@ func banHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GiveFLHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
||||||
looker := person.FindByDiscord(i.Member.User.ID)
|
|
||||||
if looker == nil {
|
|
||||||
s.InteractionRespond(i.Interaction, &ErrorNoPermission)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !looker.HasPermission(person.PermissionBan) {
|
|
||||||
s.InteractionRespond(i.Interaction, &ErrorNoPermission)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
player := getPersonFromOptions(i.ApplicationCommandData(), s)
|
|
||||||
if player == nil {
|
|
||||||
s.InteractionRespond(i.Interaction, &ErrorInvalidDisplayOrDiscord)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: player.DisplayName + " has been granted everything.",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
fortnite.GiveEverything(player)
|
|
||||||
}
|
|
||||||
|
|
||||||
func unbanHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func unbanHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
looker := person.FindByDiscord(i.Member.User.ID)
|
looker := person.FindByDiscord(i.Member.User.ID)
|
||||||
if looker == nil {
|
if looker == nil {
|
||||||
|
@ -320,3 +293,37 @@ func takeItemHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func giveEverythingHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
looker := person.FindByDiscord(i.Member.User.ID)
|
||||||
|
if looker == nil {
|
||||||
|
s.InteractionRespond(i.Interaction, &ErrorNoPermission)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !looker.HasPermission(person.PermissionGiveItem) {
|
||||||
|
s.InteractionRespond(i.Interaction, &ErrorNoPermission)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
player := getPersonFromOptions(i.ApplicationCommandData(), s)
|
||||||
|
if player == nil {
|
||||||
|
s.InteractionRespond(i.Interaction, &ErrorInvalidDisplayOrDiscord)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !player.HasPermission(person.PermissionFullLocker) {
|
||||||
|
s.InteractionRespond(i.Interaction, &ErrorNoPermission)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s.InteractionResponseEdit(i.Interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseDefferedChannelMessageWithSource,
|
||||||
|
})
|
||||||
|
|
||||||
|
fortnite.GiveEverything(player)
|
||||||
|
|
||||||
|
s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{
|
||||||
|
Content: player.DisplayName + " has been granted everything.",
|
||||||
|
})
|
||||||
|
}
|
|
@ -110,29 +110,6 @@ func addCommands() {
|
||||||
AdminOnly: true,
|
AdminOnly: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
addCommand(&DiscordCommand{
|
|
||||||
Command: &discordgo.ApplicationCommand{
|
|
||||||
Name: "give-everything",
|
|
||||||
Description: "Give a player full locker",
|
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
|
||||||
{
|
|
||||||
Type: discordgo.ApplicationCommandOptionUser,
|
|
||||||
Name: "discord",
|
|
||||||
Description: "The discord account of the player.",
|
|
||||||
Required: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: discordgo.ApplicationCommandOptionString,
|
|
||||||
Name: "display",
|
|
||||||
Description: "The display name of the player.",
|
|
||||||
Required: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Handler: GiveFLHandler,
|
|
||||||
AdminOnly: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
addCommand(&DiscordCommand{
|
addCommand(&DiscordCommand{
|
||||||
Command: &discordgo.ApplicationCommand{
|
Command: &discordgo.ApplicationCommand{
|
||||||
Name: "unban",
|
Name: "unban",
|
||||||
|
@ -237,6 +214,29 @@ func addCommands() {
|
||||||
Handler: takeItemHandler,
|
Handler: takeItemHandler,
|
||||||
AdminOnly: true,
|
AdminOnly: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addCommand(&DiscordCommand{
|
||||||
|
Command: &discordgo.ApplicationCommand{
|
||||||
|
Name: "everything",
|
||||||
|
Description: "Give a player full locker",
|
||||||
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
|
{
|
||||||
|
Type: discordgo.ApplicationCommandOptionUser,
|
||||||
|
Name: "discord",
|
||||||
|
Description: "The discord account of the player.",
|
||||||
|
Required: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: discordgo.ApplicationCommandOptionString,
|
||||||
|
Name: "display",
|
||||||
|
Description: "The display name of the player.",
|
||||||
|
Required: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Handler: giveEverythingHandler,
|
||||||
|
AdminOnly: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPersonFromOptions(data discordgo.ApplicationCommandInteractionData, s *discordgo.Session) *person.Person {
|
func getPersonFromOptions(data discordgo.ApplicationCommandInteractionData, s *discordgo.Session) *person.Person {
|
||||||
|
|
|
@ -10,6 +10,7 @@ const (
|
||||||
PermissionGiveItem Permission = "give_item"
|
PermissionGiveItem Permission = "give_item"
|
||||||
PermissionTakeItem Permission = "take_item"
|
PermissionTakeItem Permission = "take_item"
|
||||||
PermissionReset Permission = "reset"
|
PermissionReset Permission = "reset"
|
||||||
|
PermissionFullLocker Permission = "full_locker"
|
||||||
|
|
||||||
PermissionAll Permission = "all"
|
PermissionAll Permission = "all"
|
||||||
)
|
)
|
Loading…
Reference in New Issue
Block a user