Closed fklingenberg closed 1 year ago
I'm not sure how this related to GuildMember
, since the code seems to fail at handler.go:26
.
Can you provide a code snippet from that location?
I'm not sure how this related to
GuildMember
, since the code seems to fail athandler.go:26
. Can you provide a code snippet from that location?
Sure, this is the part where I'm calling my RoleApi
role := api.NewRoleApi(rr.ctx)
if role.HasRole(userId, roleId) { // This is line 26
err := s.GuildMemberRoleRemove(serverId, userId, roleId)
if err != nil {
logrus.Error(err)
}
} else {
err := s.GuildMemberRoleAdd(serverId, userId, roleId)
if err != nil {
logrus.Error(err)
}
}
Where are userId
and roleId
defined? Also, are you sure that this is line 26? The stack trace says the error isn't coming from within the function
userId and roleId are variables which are hardcoded a few lines above. Yes, this is line 26.
I have already tried to call discord.GuildMember(api.cfg.Server.ServerId, userId)
directly, without the RoleApi. It always gives the same error as soon as the GuildMember method is used.
Therefore, I suspect that it may be a bug in DiscordGo.
I'm trying to get a Guild Member. This is the code im using:
Whenever I'm trying to call the function i got this crash:
After calling discordgo.New im doing this:
In the discord developer portal i enabled the SERVER MEMBERS INTENT
Anyone maybe got the same problem who can tell me how to fix it? Thanks