Intents not working on discordgo, how do i fix it

Issue

    dg.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAll)
    err = dg.Open()
    if err != nil {
        panic(err)
    }

it doesnt work, i want to pull members in the guild which one i created with using guild id, like this (mee.dg is a discord session)

func (mee *Meeee) CheckCurrentUserList() {
    guild, err := mee.dg.Guild(config.Manager.MeeeeCredentials.Guild.Id)
    if err != nil {
        panic(err)
    }
    log.Printf("%v", guild.Name)
    log.Printf("%v", guild.Channels)
    for _, member := range guild.Members {
        log.Printf("user - name: %v, id: %v", member.User.Username, member.User.ID)
    }
}

Solution

actually the problem i faced had nothing to do with intents. The fact that the guild struct in Discordgo structs has a member field misled me. Another http request is being made to reach the Guild Members, so I had to use the "GuildMembers(parameters)" function.

func (mee *Meeee) CheckCurrentUserList() {
    members, err := mee.dg.GuildMembers(config.Manager.MeeeeCredentials.Guild.Id, "", 100)
    if err != nil {
        panic(err)
    }
    for _, member := range members {
        log.Printf("user - name: %v, id: %v", member.User.Username, member.User.ID)
    }
}

Answered By – Ahmet Berke Tuncel

Answer Checked By – Marie Seifert (GoLangFix Admin)

Leave a Reply

Your email address will not be published.