Skip to content

Commit

Permalink
Don't download members if running with user token
Browse files Browse the repository at this point in the history
User tokens have been banned from the members endpoint. It's
still possible to track some member state by using "author"
message fields, but some information (most notably nicknames) will
be lost. Since there are no leave messages, it's not possible to
record when a member leaves either. Some of these issues can be
ameliorated by incorporating data from audit logs (currently not
used at all), but access to audit logs is not always given.
Nicknames could be snatched from the GUILD_MEMBER_LIST_UPDATE
event (currently not used at all, doesn't seem to be implemented
in discordgo either) or GUILD_CREATE. WS events may not always
contain all members, though (or in case of GUILD_CREATE, not be
fired at all), so handling missing entries could be problematic.
It would be simpler if we had distinct values for "unknown/no
value" and "empty", since then "unknown" values could be ignored
when comparing, or updated if the newer entry had more information.
  • Loading branch information
tsudoko committed Jan 6, 2020
1 parent 84d9532 commit d6f3ad6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions logpull/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ func (p *Puller) PullGuild(id string) error {
delete(p.deleted[logentry.Type(e)], e.ID)
}

// user tokens are banned from the GuildMembers endpoint, we check the
// token preemptively instead of trying anyway because triggering the
// ban locks down the account until it's re-verified
// ---
// this limitation means only active members (those who send messages
// between pullcord runs) can be recorded, without nicknames
if !strings.HasPrefix(strings.ToLower(p.d.Token), "bot ") {
log.Printf("[%s] cannot download members with a user token, member data will not be fully accurate", id)
return nil
}

after := "0"
for {
members, err := p.d.GuildMembers(id, after, 1000)
Expand Down

0 comments on commit d6f3ad6

Please sign in to comment.