Add config for register URL and check for dupes
Signed-off-by: Etzelia <etzelia@hotmail.com>pull/12/head
parent
4fb7cc2928
commit
06e5003d78
|
@ -13,12 +13,6 @@ mc_path = "/home/minecraft/server/"
|
|||
# fired_role is to check how many time Carolyn has been fired
|
||||
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 = "0"
|
||||
|
||||
|
@ -31,6 +25,16 @@ meme_rate = "0"
|
|||
# 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]
|
||||
# API endpoint
|
||||
|
|
|
@ -35,17 +35,19 @@ type Config struct {
|
|||
AccessToken string `toml:"access_token"`
|
||||
AccessSecret string `toml:"access_secret"`
|
||||
} `toml:"twitter"`
|
||||
|
||||
StaffRoles []string `toml:"staff_roles"`
|
||||
Echoes []Echo `toml:"echoes"`
|
||||
Albums []Album `toml:"albums"`
|
||||
MessageRoles []MessageRole `toml:"message_roles"`
|
||||
RegisterRole string `toml:"register_role"`
|
||||
RegisteredChannel string `toml:"registered_channel"`
|
||||
LeaveChannel string `toml:"leave_channel"`
|
||||
FiredRole string `toml:"fired_role"`
|
||||
MemeRate string `toml:"meme_rate"`
|
||||
Insult struct {
|
||||
StaffRoles []string `toml:"staff_roles"`
|
||||
Echoes []Echo `toml:"echoes"`
|
||||
Albums []Album `toml:"albums"`
|
||||
MessageRoles []MessageRole `toml:"message_roles"`
|
||||
Register struct {
|
||||
URL string `toml:"url"`
|
||||
Role string `toml:"role"`
|
||||
} `toml:"register"`
|
||||
WelcomeChannel string `toml:"welcome_channel"`
|
||||
LeaveChannel string `toml:"leave_channel"`
|
||||
FiredRole string `toml:"fired_role"`
|
||||
MemeRate string `toml:"meme_rate"`
|
||||
Insult struct {
|
||||
Targets []string `toml:"targets"`
|
||||
Comparisons []string `toml:"comparisons"`
|
||||
Adjectives []string `toml:"adjectives"`
|
||||
|
|
|
@ -69,7 +69,7 @@ func init() {
|
|||
}
|
||||
} else if len(apps) > 0 {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
},
|
||||
help: "Register yourself with the Discord",
|
||||
|
|
Loading…
Reference in New Issue