Giter Site home page Giter Site logo

Comments (9)

diamondburned avatar diamondburned commented on July 30, 2024

How are you getting channel permissions? What's your code?

from arikawa.

Cynosphere avatar Cynosphere commented on July 30, 2024
for _, channel := range guildChannels {
  if channel.Type != discord.GuildText && channel.Type != discord.GuildAnnouncement {
    continue
  }

  private := false

  if channel.ParentID.IsValid() {
    category, err := client.ChannelStore.Channel(channel.ParentID)
    if err == nil {
      perms := discord.CalcOverwrites(*guild, *category, *selfMember)
      private = !perms.Has(discord.PermissionViewChannel)
    }
  }

  if private {
    perms := discord.CalcOverwrites(*guild, channel, *selfMember)
    private = !perms.Has(discord.PermissionViewChannel)
  }

  if private && !withPrivate {
    continue
  }

  // ...
}

from arikawa.

diamondburned avatar diamondburned commented on July 30, 2024

CalcOverwrites will not try to fetch missing permissions from the given channel. You must use client.Permissions to fetch that. Ideally, CalcOverwrites should not even be used at all.

from arikawa.

Cynosphere avatar Cynosphere commented on July 30, 2024

client.Permissions is consistently returning 0 now when it should be returning 401295005309505 for most of the channels.

from arikawa.

diamondburned avatar diamondburned commented on July 30, 2024

What does client.Client.Permissions return? (Make sure that client.Client is specifically of type *api.Client.)

from arikawa.

Cynosphere avatar Cynosphere commented on July 30, 2024

*api.Client does not seem to have a Permissions function

from arikawa.

diamondburned avatar diamondburned commented on July 30, 2024

Sorry, try client.Client.Channel and check its permissions. Also note that these functions don't handle carrying over category permissions.

from arikawa.

Cynosphere avatar Cynosphere commented on July 30, 2024

The permission results seems to be inverted with using !channel.SelfPermissions.Has(discord.PermissionViewChannel), where it thinks the private channels are the ones that the account can see. This is also way too slow for my liking.

I did make my own version of client.Permissions to debug with, and the root cause seems to be guild.Roles being empty.

from arikawa.

diamondburned avatar diamondburned commented on July 30, 2024

Hmm, so https://github.com/diamondburned/arikawa/blob/v3.3.3/state/state.go#L310 should probably error out when Roles == nil then, which makes sense. (Not the function itself, but this particular branch.)

from arikawa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.