Compare commits
4 Commits
ImplDiscor
...
8b001e499a
Author | SHA1 | Date | |
---|---|---|---|
8b001e499a
|
|||
62faa6c974
|
|||
2a42301c25
|
|||
7eebc01816 |
@ -3,6 +3,7 @@ token = ""
|
|||||||
appid = ""
|
appid = ""
|
||||||
guildid = ""
|
guildid = ""
|
||||||
category_id = ""
|
category_id = ""
|
||||||
|
admin_roles = [""]
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
host = ""
|
host = ""
|
||||||
@ -11,4 +12,4 @@ name = ""
|
|||||||
username = ""
|
username = ""
|
||||||
password = ""
|
password = ""
|
||||||
|
|
||||||
admin_roles = [""]
|
|
||||||
|
35
main.go
35
main.go
@ -21,16 +21,16 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Discord Discord `toml:"discord"`
|
Discord Discord `toml:"discord"`
|
||||||
Database Database `toml:"database"`
|
Database Database `toml:"database"`
|
||||||
AdminRoles []string `toml:"admin_roles"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Discord struct {
|
type Discord struct {
|
||||||
Token string `toml:"token"`
|
Token string `toml:"token"`
|
||||||
AppID string `toml:"appid"`
|
AppID string `toml:"appid"`
|
||||||
GuildID string `toml:"guildid"`
|
GuildID string `toml:"guildid"`
|
||||||
CategoryID string `toml:"category_id"`
|
CategoryID string `toml:"category_id"`
|
||||||
|
AdminRoles []string `toml:"admin_roles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
@ -108,12 +108,11 @@ func getUsernameFromMember(member *discordgo.Member) string {
|
|||||||
} else if member.User != nil && member.User.Username != "" {
|
} else if member.User != nil && member.User.Username != "" {
|
||||||
userName = member.User.Username
|
userName = member.User.Username
|
||||||
} else {
|
} else {
|
||||||
userName = "UnknownUser"
|
userName = "UnknownUser"
|
||||||
}
|
}
|
||||||
return userName
|
return userName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
commands = []discordgo.ApplicationCommand{
|
commands = []discordgo.ApplicationCommand{
|
||||||
{
|
{
|
||||||
@ -230,9 +229,9 @@ var (
|
|||||||
ParentID: categoryID,
|
ParentID: categoryID,
|
||||||
PermissionOverwrites: []*discordgo.PermissionOverwrite{
|
PermissionOverwrites: []*discordgo.PermissionOverwrite{
|
||||||
{
|
{
|
||||||
ID: guildID,
|
ID: guildID,
|
||||||
Type: discordgo.PermissionOverwriteTypeRole,
|
Type: discordgo.PermissionOverwriteTypeRole,
|
||||||
Deny: discordgo.PermissionViewChannel,
|
Deny: discordgo.PermissionViewChannel,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -241,8 +240,11 @@ var (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, roleID := range config.AdminRoles {
|
for _, roleID := range config.Discord.AdminRoles {
|
||||||
client.ChannelPermissionSet(channel.ID, roleID, discordgo.PermissionOverwriteTypeRole, discordgo.PermissionViewChannel, 0)
|
err := client.ChannelPermissionSet(channel.ID, roleID, discordgo.PermissionOverwriteTypeRole, discordgo.PermissionViewChannel|discordgo.PermissionSendMessages, 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error setting permissions for role %s: %v", roleID, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err = client.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
@ -375,10 +377,10 @@ func canCreateTicket(userName, softwareType string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, channel := range guildChannels {
|
for _, channel := range guildChannels {
|
||||||
if channel.Type == discordgo.ChannelTypeGuildText && channel.ParentID == config.Discord.CategoryID {
|
if channel.Type == discordgo.ChannelTypeGuildText && channel.ParentID == config.Discord.CategoryID {
|
||||||
expectedName := fmt.Sprintf("reset-%s-%s", softwareType, userName)
|
expectedName := fmt.Sprintf("reset-%s-%s", softwareType, userName)
|
||||||
if channel.Name == expectedName {
|
if channel.Name == expectedName {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,4 +443,3 @@ func main() {
|
|||||||
db.Close()
|
db.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user