Compare commits
2 Commits
9f4be9e986
...
2e4a30ea01
Author | SHA1 | Date | |
---|---|---|---|
2e4a30ea01 | |||
3a7e8ae721 |
61
main.go
61
main.go
@ -147,6 +147,39 @@ var (
|
|||||||
}
|
}
|
||||||
commandsHandlers = map[string]func(client *discordgo.Session, i *discordgo.InteractionCreate){
|
commandsHandlers = map[string]func(client *discordgo.Session, i *discordgo.InteractionCreate){
|
||||||
"setup": func(client *discordgo.Session, i *discordgo.InteractionCreate) {
|
"setup": func(client *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
hasAdminPermission := false
|
||||||
|
for _, roleID := range config.Discord.AdminRoles {
|
||||||
|
member, err := client.GuildMember(i.GuildID, i.Member.User.ID)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error fetching member info:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, role := range member.Roles {
|
||||||
|
if role == roleID {
|
||||||
|
hasAdminPermission = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hasAdminPermission {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasAdminPermission {
|
||||||
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Content: "You do not have permission to run this command.",
|
||||||
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error sending interaction response:", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
channelOption := i.ApplicationCommandData().Options[0].ChannelValue(client)
|
channelOption := i.ApplicationCommandData().Options[0].ChannelValue(client)
|
||||||
_, err := client.ChannelMessageSendComplex(channelOption.ID, &discordgo.MessageSend{
|
_, err := client.ChannelMessageSendComplex(channelOption.ID, &discordgo.MessageSend{
|
||||||
Content: "Click the button below to request a HWID reset:",
|
Content: "Click the button below to request a HWID reset:",
|
||||||
@ -177,6 +210,7 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
componentsHandlers = map[string]func(client *discordgo.Session, i *discordgo.InteractionCreate){
|
componentsHandlers = map[string]func(client *discordgo.Session, i *discordgo.InteractionCreate){
|
||||||
"create_ticket": func(client *discordgo.Session, i *discordgo.InteractionCreate) {
|
"create_ticket": func(client *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err := client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
@ -494,33 +528,6 @@ func resetHWID(tableName string, uids []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIdentifiers(tableName string, uid int) {
|
|
||||||
query := fmt.Sprintf(`SELECT "StorageIdentifier", "BootIdentifier"
|
|
||||||
FROM public.%q
|
|
||||||
WHERE "UID" = $1`, tableName)
|
|
||||||
|
|
||||||
var storageIdentifier, bootIdentifier sql.NullString
|
|
||||||
err := db.QueryRow(query, uid).Scan(&storageIdentifier, &bootIdentifier)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
fmt.Println("HWID not set")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Error querying the database:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !storageIdentifier.Valid {
|
|
||||||
storageIdentifier = sql.NullString{String: "NULL", Valid: false}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !bootIdentifier.Valid {
|
|
||||||
bootIdentifier = sql.NullString{String: "NULL", Valid: false}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("UID: %d, S: %s, B: %s\n", uid, storageIdentifier.String, bootIdentifier.String)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resetAndVerify(tableName string, uid int) (bool, error) {
|
func resetAndVerify(tableName string, uid int) (bool, error) {
|
||||||
var beforeHash string
|
var beforeHash string
|
||||||
err := db.QueryRow(
|
err := db.QueryRow(
|
||||||
|
Loading…
Reference in New Issue
Block a user