Skip to content

Conversation

@Misha-133
Copy link
Member

Docs PR

This PR adds some newly documented features for Edit Current Application endpoint.

Changes

  • Add new editable properties
  • Add some missing xmldocs
  • Make the constructor of ApplicationInstallParams public, so it can be used to modify the app
  • ApplicationInstallParams.Permission is not nullable

Copy link
Contributor

@Panthr75 Panthr75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a builder type for building the scopes that you can pass into ApplicationInstallParams so that you can get the benefit of knowing the scopes you can use and the option of specifying new scopes that they release indirectly?

Example mock class:

class ApplicationScopesBuilder
{
    private readonly List<string> _scopes = new();
    
    public bool ReadActivities
    {
        get => HasScope("activities.read");
        set => SetScope("activities.read", value);
    }

    public bool WriteActivities
    {
        get => HasScope("activities.write");
        set => SetScope("activities.write", value);
    }

    public bool ReadApplicationBuilds
    {
        get => HasScope("applications.builds.read");
        set => SetScope("applications.builds.read", value);
    }

    public bool UploadApplicationBuilds
    {
        get => HasScope("applications.builds.upload");
        set => SetScope("applications.builds.upload", value);
    }

    public bool ApplicationCommands
    {
        get => HasScope("applications.commands");
        set => SetScope("applications.commands", value);
    }

    public bool UpdateApplicationCommands
    {
        get => HasScope("applications.commands.update");
        set => SetScope("applications.commands.update", value);
    }

    public bool UpdateApplicationCommandPermissions
    {
        get => HasScope("applications.commands.permissions.update");
        set => SetScope("applications.commands.permissions.update", value);
    }

    public bool ApplicationEntitlements
    {
        get => HasScope("applications.entitlements");
        set => SetScope("applications.entitlements", value);
    }

    public bool UpdateApplicationStore
    {
        get => HasScope("applications.store.update");
        set => SetScope("applications.store.update", value);
    }

    public bool Bot
    {
        get => HasScope("bot");
        set => SetScope("bot", value);
    }

    public bool Connections
    {
        get => HasScope("connections");
        set => SetScope("connections", value);
    }

    public bool ReadDmChannels
    {
        get => HasScope("dm_channels.read");
        set => SetScope("dm_channels.read", value);
    }

    public bool Email
    {
        get => HasScope("email");
        set => SetScope("email", value);
    }

    public bool JoinGdm
    {
        get => HasScope("gdm.join");
        set => SetScope("gdm.join", value);
    }

    public bool Guilds
    {
        get => HasScope("guilds");
        set => SetScope("guilds", value);
    }

    public bool JoinGuilds
    {
        get => HasScope("guilds.join");
        set => SetScope("guilds.join", value);
    }

    public bool ReadGuildsMembers
    {
        get => HasScope("guilds.members.read");
        set => SetScope("guilds.members.read", value);
    }

    public bool Identify
    {
        get => HasScope("identify");
        set => SetScope("identify", value);
    }

    public bool ReadMessages
    {
        get => HasScope("messages.read");
        set => SetScope("messages.read", value);
    }

    public bool ReadRelationships
    {
        get => HasScope("relationships.read");
        set => SetScope("relationships.read", value);
    }

    public bool WriteRoleConnections
    {
        get => HasScope("role_connections.write");
        set => SetScope("role_connections.write", value);
    }

    public bool Rpc
    {
        get => HasScope("rpc");
        set => SetScope("rpc", value);
    }

    public bool RpcWriteActivities
    {
        get => HasScope("rpc.activities.write");
        set => SetScope("rpc.activities.write", value);
    }

    public bool RpcReadNotifications
    {
        get => HasScope("rpc.notifications.read");
        set => SetScope("rpc.notifications.read", value);
    }

    public bool RpcReadVoice
    {
        get => HasScope("rpc.voice.read");
        set => SetScope("rpc.voice.read", value);
    }

    public bool RpcWriteVoice
    {
        get => HasScope("rpc.voice.write");
        set => SetScope("rpc.voice.write", value);
    }

    public bool Voice
    {
        get => HasScope("voice");
        set => SetScope("voice", value);
    }

    public bool IncomingWebhook
    {
        get => HasScope("webhook.incoming");
        set => SetScope("webhook.incoming", value);
    }
    
    public void SetScope(string scopeName, bool value)
    {
        if (value) AddScope(scopeName);
        else RemoveScope(scopeName);
    }

    public void RemoveScope(string scopeName)
    {
        if (scopeName is null) return;
        _scopes.Remove(scopeName.ToLower());
    }
    
    public void AddScope(string scopeName)
    {
        if (scopeName is null) return;
        scopeName = scopeName.ToLower();
        
        if (!_scopes.Contains(scopeName)) _scopes.Add(scopeName);
    }
    
    public bool HasScope(string scopeName)
    {
        return scopeName is null ? false : _scopes.Contains(scopeName);
    }
}

@Misha-133 Misha-133 enabled auto-merge (squash) August 10, 2023 13:16
@Misha-133 Misha-133 merged commit 166d40f into discord-net:dev Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants