This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PermissionGacha/modules/gacha/rewards.go

51 lines
1.2 KiB
Go

package gacha
import (
"github.com/bwmarrin/discordgo"
"PermissionGacha/modules/config"
)
type reward struct {
FriendlyName string
Reward func(s *discordgo.Session, member *discordgo.Member) (bool, error)
}
var gachaRewards = []reward{
reward{
FriendlyName: "View Audit Log",
Reward: generateRoleReward("645856347258093568"),
},
reward{
FriendlyName: "Manage Webhook",
Reward: generateRoleReward("645856081750523914"),
},
reward{
FriendlyName: "Change Nickname",
Reward: generateRoleReward("645977231281356800"),
},
reward{
FriendlyName: "Use Voice Activity",
Reward: generateRoleReward("645880647474479115"),
},
reward{
FriendlyName: "Embed Link",
Reward: generateRoleReward("645977361254318080"),
},
}
func generateRoleReward(roleID string) func(s *discordgo.Session, member *discordgo.Member) (bool, error) {
return func(s *discordgo.Session, member *discordgo.Member) (bool, error) {
for _, v := range member.Roles {
if v == roleID {
return false, nil
}
}
err := s.GuildMemberRoleAdd(config.GuildID, member.User.ID, roleID)
if err != nil {
return false, err
}
return true, nil
}
}