Add config for register URL and check for dupes

Signed-off-by: Etzelia <etzelia@hotmail.com>
pull/12/head
Etzelia 2021-07-09 15:17:17 -05:00
parent 4fb7cc2928
commit 06e5003d78
No known key found for this signature in database
GPG Key ID: 708511AE7ABC5314
3 changed files with 41 additions and 21 deletions

View File

@ -13,12 +13,6 @@ mc_path = "/home/minecraft/server/"
# fired_role is to check how many time Carolyn has been fired # fired_role is to check how many time Carolyn has been fired
fired_role = "0" fired_role = "0"
# register_role is the role to assign to a user after registering
register_role = "0"
# registered_channel is the channel to message to welcome the newly registered user
registered_channel = "0"
# leave_channel is the channel to post leave messages to # leave_channel is the channel to post leave messages to
leave_channel = "0" leave_channel = "0"
@ -31,6 +25,16 @@ meme_rate = "0"
# Imgur Client ID # Imgur Client ID
imgur_client_id = "" imgur_client_id = ""
# welcome_channel is the channel to message to welcome the newly registered user
welcome_channel = "0"
[register]
# role is the role to assign to a user after registering
role = "0"
# url is the URL to show to new users
url = "https://google.com"
# ServerAPI options # ServerAPI options
[serverapi] [serverapi]
# API endpoint # API endpoint

View File

@ -35,17 +35,19 @@ type Config struct {
AccessToken string `toml:"access_token"` AccessToken string `toml:"access_token"`
AccessSecret string `toml:"access_secret"` AccessSecret string `toml:"access_secret"`
} `toml:"twitter"` } `toml:"twitter"`
StaffRoles []string `toml:"staff_roles"`
StaffRoles []string `toml:"staff_roles"` Echoes []Echo `toml:"echoes"`
Echoes []Echo `toml:"echoes"` Albums []Album `toml:"albums"`
Albums []Album `toml:"albums"` MessageRoles []MessageRole `toml:"message_roles"`
MessageRoles []MessageRole `toml:"message_roles"` Register struct {
RegisterRole string `toml:"register_role"` URL string `toml:"url"`
RegisteredChannel string `toml:"registered_channel"` Role string `toml:"role"`
LeaveChannel string `toml:"leave_channel"` } `toml:"register"`
FiredRole string `toml:"fired_role"` WelcomeChannel string `toml:"welcome_channel"`
MemeRate string `toml:"meme_rate"` LeaveChannel string `toml:"leave_channel"`
Insult struct { FiredRole string `toml:"fired_role"`
MemeRate string `toml:"meme_rate"`
Insult struct {
Targets []string `toml:"targets"` Targets []string `toml:"targets"`
Comparisons []string `toml:"comparisons"` Comparisons []string `toml:"comparisons"`
Adjectives []string `toml:"adjectives"` Adjectives []string `toml:"adjectives"`

View File

@ -69,7 +69,7 @@ func init() {
} }
} else if len(apps) > 0 { } else if len(apps) > 0 {
if apps[0].Accepted != nil && *apps[0].Accepted { if apps[0].Accepted != nil && *apps[0].Accepted {
return "Please join the server and then re-try this command", nil return fmt.Sprintf("Please join the server at `%s` and then re-try this command", cmd.config.Register.URL), nil
} }
} else { } else {
return "No player or applications found for that username", nil return "No player or applications found for that username", nil
@ -82,16 +82,30 @@ func init() {
return "Your application was denied, good luck finding a new server", nil return "Your application was denied, good luck finding a new server", nil
} }
// Accepted // Accepted, check for dupe user
guild, err := cmd.session.State.Guild(cmd.message.GuildID)
if err != nil {
return "", err
}
for _, member := range guild.Members {
nick := member.Nick
if nick == "" {
}
nick = member.User.Username
if strings.EqualFold(nickname, nick) {
return "A member with that name already exists in this Discord. Please contact staff.", nil
}
}
if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil { if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil {
return "", err return "", err
} }
if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.RegisterRole); err != nil { if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil {
return "", err return "", err
} }
// Don't return feedback because this goes in a different channel // Don't return feedback because this goes in a different channel
sendMessage(cmd.session, cmd.config.RegisteredChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false) sendMessage(cmd.session, cmd.config.WelcomeChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false)
return "", nil return "", nil
}, },
help: "Register yourself with the Discord", help: "Register yourself with the Discord",