fixed error when no autojoinroles are set
This commit is contained in:
@@ -9,8 +9,6 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fileData []byte
|
|
||||||
|
|
||||||
var cmd_form Command = Command{
|
var cmd_form Command = Command{
|
||||||
Definition: discordgo.ApplicationCommand{
|
Definition: discordgo.ApplicationCommand{
|
||||||
Name: "form",
|
Name: "form",
|
||||||
|
@@ -159,8 +159,11 @@ func messageDelete(s *discordgo.Session, m *discordgo.MessageDelete) { //TODO: a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func guildMemberJoin(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
func guildMemberJoin(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
||||||
err := s.GuildMemberRoleAdd(m.GuildID, m.User.ID, getAutoJoinRole(m.GuildID, m.User.Bot))
|
role := getAutoJoinRole(m.GuildID, m.User.Bot)
|
||||||
|
if role != "" {
|
||||||
|
err := s.GuildMemberRoleAdd(m.GuildID, m.User.ID, role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -319,10 +319,18 @@ func getAutoJoinRole(guildID string, isBot bool) string {
|
|||||||
} else {
|
} else {
|
||||||
isBotString = "user"
|
isBotString = "user"
|
||||||
}
|
}
|
||||||
err := db.QueryRow("SELECT "+isBotString+"_role FROM autojoinroles WHERE guild_id = $1", guildID).Scan(&role)
|
var exists bool
|
||||||
|
err := db.QueryRow("SELECT EXISTS (SELECT 1 FROM autojoinroles WHERE guild_id = $1)", guildID).Scan(&exists)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return role
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
err = db.QueryRow("SELECT "+isBotString+"_role FROM autojoinroles WHERE guild_id = $1", guildID).Scan(&role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err, guildID)
|
logrus.Error(err, guildID)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return role
|
return role
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user