2020-08-02 21:00:05 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
|
|
|
deleteInvocation: true,
|
|
|
|
name: "welcome",
|
2020-08-02 21:00:05 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles)
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
orphans := make([]*discordgo.Member, 0)
|
|
|
|
|
|
|
|
members, err := cmd.session.GuildMembers(cmd.message.GuildID, "", 1000)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
for _, member := range members {
|
|
|
|
if len(member.Roles) == 0 {
|
|
|
|
orphans = append(orphans, member)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resp := "There are no members without roles!"
|
|
|
|
if len(orphans) > 0 {
|
|
|
|
resp = "```\n"
|
|
|
|
for _, orphan := range orphans {
|
|
|
|
resp += fmt.Sprintf("<@%s>\n", orphan.User.ID)
|
|
|
|
}
|
|
|
|
resp += "```"
|
|
|
|
}
|
|
|
|
|
|
|
|
channel, err := cmd.session.UserChannelCreate(cmd.message.Author.ID)
|
|
|
|
if err != nil {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := cmd.session.ChannelMessageSend(channel.ID, resp); err != nil {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", nil
|
|
|
|
},
|
|
|
|
help: "Get a list of people with no roles",
|
2021-02-23 05:53:55 +00:00
|
|
|
})
|
2020-08-02 21:00:05 +00:00
|
|
|
}
|