refactor: cache own user ID in IDiscordCache
- remove Cluster.User - remove Cluster.Application (it was only being used as an alternative to Cluster.User for some reason) - move Bot.PermissionsIn to DiscordCacheExtensions
This commit is contained in:
		@@ -87,7 +87,7 @@ namespace PluralKit.Bot
 | 
			
		||||
            var missingEmojiPermissions = false;
 | 
			
		||||
            foreach (var channel in await _rest.GetGuildChannels(guild.Id))
 | 
			
		||||
            {
 | 
			
		||||
                var botPermissions = await _bot.PermissionsIn(channel.Id);
 | 
			
		||||
                var botPermissions = await _cache.PermissionsIn(channel.Id);
 | 
			
		||||
                var webhookPermissions = await _cache.EveryonePermissions(channel);
 | 
			
		||||
                var userPermissions = PermissionExtensions.PermissionsFor(guild, channel, ctx.Author.Id, senderGuildUser);
 | 
			
		||||
 | 
			
		||||
@@ -176,7 +176,7 @@ namespace PluralKit.Bot
 | 
			
		||||
            if (!await ctx.CheckPermissionsInGuildChannel(channel, PermissionSet.ViewChannel))
 | 
			
		||||
                throw new PKError(error);
 | 
			
		||||
 | 
			
		||||
            var botPermissions = await _bot.PermissionsIn(channel.Id);
 | 
			
		||||
            var botPermissions = await _cache.PermissionsIn(channel.Id);
 | 
			
		||||
            var webhookPermissions = await _cache.EveryonePermissions(channel);
 | 
			
		||||
 | 
			
		||||
            // We use a bitfield so we can set individual permission bits
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ namespace PluralKit.Bot
 | 
			
		||||
                p.IncludeLastSwitch = true;
 | 
			
		||||
            if (ctx.MatchFlag("with-last-message", "with-last-proxy", "wlm", "wlp"))
 | 
			
		||||
                throw new PKError("Sorting by last message is temporarily disabled due to database issues, sorry.");
 | 
			
		||||
                // p.IncludeLastMessage = true;
 | 
			
		||||
            // p.IncludeLastMessage = true;
 | 
			
		||||
            if (ctx.MatchFlag("with-message-count", "wmc"))
 | 
			
		||||
                p.IncludeMessageCount = true;
 | 
			
		||||
            if (ctx.MatchFlag("with-created", "wc"))
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ namespace PluralKit.Bot
 | 
			
		||||
 | 
			
		||||
        public async Task Invite(Context ctx)
 | 
			
		||||
        {
 | 
			
		||||
            var clientId = _botConfig.ClientId ?? _cluster.Application?.Id;
 | 
			
		||||
            var clientId = _botConfig.ClientId ?? await _cache.GetOwnUser();
 | 
			
		||||
 | 
			
		||||
            var permissions =
 | 
			
		||||
                PermissionSet.AddReactions |
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ namespace PluralKit.Bot
 | 
			
		||||
            if (channel.Type != Channel.ChannelType.GuildText)
 | 
			
		||||
                throw new PKError("PluralKit cannot log messages to this type of channel.");
 | 
			
		||||
 | 
			
		||||
            var perms = await _bot.PermissionsIn(channel.Id);
 | 
			
		||||
            var perms = await _cache.PermissionsIn(channel.Id);
 | 
			
		||||
            if (!perms.HasFlag(PermissionSet.SendMessages))
 | 
			
		||||
                throw new PKError("PluralKit is missing **Send Messages** permissions in the new log channel.");
 | 
			
		||||
            if (!perms.HasFlag(PermissionSet.EmbedLinks))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user