Initial commit, basic proxying working
This commit is contained in:
@@ -9,8 +9,14 @@ using Autofac;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.Entities;
|
||||
|
||||
using Myriad.Extensions;
|
||||
using Myriad.Gateway;
|
||||
using Myriad.Types;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
using Permissions = DSharpPlus.Permissions;
|
||||
|
||||
namespace PluralKit.Bot
|
||||
{
|
||||
public class Context
|
||||
@@ -19,10 +25,17 @@ namespace PluralKit.Bot
|
||||
|
||||
private readonly DiscordRestClient _rest;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordClient _shard;
|
||||
private readonly DiscordMessage _message;
|
||||
private readonly DiscordClient _shard = null;
|
||||
private readonly Shard _shardNew;
|
||||
private readonly Guild? _guild;
|
||||
private readonly Channel _channel;
|
||||
private readonly DiscordMessage _message = null;
|
||||
private readonly Message _messageNew;
|
||||
private readonly Parameters _parameters;
|
||||
private readonly MessageContext _messageContext;
|
||||
private readonly GuildMemberPartial? _botMember;
|
||||
private readonly PermissionSet _botPermissions;
|
||||
private readonly PermissionSet _userPermissions;
|
||||
|
||||
private readonly IDatabase _db;
|
||||
private readonly ModelRepository _repo;
|
||||
@@ -32,31 +45,47 @@ namespace PluralKit.Bot
|
||||
|
||||
private Command _currentCommand;
|
||||
|
||||
public Context(ILifetimeScope provider, DiscordClient shard, DiscordMessage message, int commandParseOffset,
|
||||
PKSystem senderSystem, MessageContext messageContext)
|
||||
public Context(ILifetimeScope provider, Shard shard, Guild? guild, Channel channel, MessageCreateEvent message, int commandParseOffset,
|
||||
PKSystem senderSystem, MessageContext messageContext, GuildMemberPartial? botMember)
|
||||
{
|
||||
_rest = provider.Resolve<DiscordRestClient>();
|
||||
_client = provider.Resolve<DiscordShardedClient>();
|
||||
_message = message;
|
||||
_shard = shard;
|
||||
_messageNew = message;
|
||||
_shardNew = shard;
|
||||
_guild = guild;
|
||||
_channel = channel;
|
||||
_senderSystem = senderSystem;
|
||||
_messageContext = messageContext;
|
||||
_botMember = botMember;
|
||||
_db = provider.Resolve<IDatabase>();
|
||||
_repo = provider.Resolve<ModelRepository>();
|
||||
_metrics = provider.Resolve<IMetrics>();
|
||||
_provider = provider;
|
||||
_commandMessageService = provider.Resolve<CommandMessageService>();
|
||||
_parameters = new Parameters(message.Content.Substring(commandParseOffset));
|
||||
|
||||
_botPermissions = message.GuildId != null
|
||||
? PermissionExtensions.PermissionsFor(guild!, channel, shard.User?.Id ?? default, botMember!.Roles)
|
||||
: PermissionSet.Dm;
|
||||
_userPermissions = message.GuildId != null
|
||||
? PermissionExtensions.PermissionsFor(guild!, channel, message.Author.Id, message.Member!.Roles)
|
||||
: PermissionSet.Dm;
|
||||
}
|
||||
|
||||
public DiscordUser Author => _message.Author;
|
||||
public DiscordChannel Channel => _message.Channel;
|
||||
public Channel ChannelNew => _channel;
|
||||
public DiscordMessage Message => _message;
|
||||
public Message MessageNew => _messageNew;
|
||||
public DiscordGuild Guild => _message.Channel.Guild;
|
||||
public Guild GuildNew => _guild;
|
||||
public DiscordClient Shard => _shard;
|
||||
public DiscordShardedClient Client => _client;
|
||||
public MessageContext MessageContext => _messageContext;
|
||||
|
||||
public PermissionSet BotPermissions => _botPermissions;
|
||||
public PermissionSet UserPermissions => _userPermissions;
|
||||
|
||||
public DiscordRestClient Rest => _rest;
|
||||
|
||||
public PKSystem System => _senderSystem;
|
||||
|
Reference in New Issue
Block a user