Unify ShardedCommandContext with SocketCommandContext (#739)
* Make ShardedCommandContext derive from SocketCommandContext * Explicitly re-implement ICommandContext.Client
This commit is contained in:
@@ -2,30 +2,20 @@
|
||||
|
||||
namespace Discord.Commands
|
||||
{
|
||||
public class ShardedCommandContext : ICommandContext
|
||||
public class ShardedCommandContext : SocketCommandContext, ICommandContext
|
||||
{
|
||||
public DiscordShardedClient Client { get; }
|
||||
public SocketGuild Guild { get; }
|
||||
public ISocketMessageChannel Channel { get; }
|
||||
public SocketUser User { get; }
|
||||
public SocketUserMessage Message { get; }
|
||||
|
||||
public bool IsPrivate => Channel is IPrivateChannel;
|
||||
public new DiscordShardedClient Client { get; }
|
||||
|
||||
public ShardedCommandContext(DiscordShardedClient client, SocketUserMessage msg)
|
||||
: base(client.GetShard(GetShardId(client, (msg.Channel as SocketGuildChannel)?.Guild)), msg)
|
||||
{
|
||||
Client = client;
|
||||
Guild = (msg.Channel as SocketGuildChannel)?.Guild;
|
||||
Channel = msg.Channel;
|
||||
User = msg.Author;
|
||||
Message = msg;
|
||||
}
|
||||
|
||||
private static int GetShardId(DiscordShardedClient client, IGuild guild)
|
||||
=> guild == null ? 0 : client.GetShardIdFor(guild);
|
||||
|
||||
//ICommandContext
|
||||
IDiscordClient ICommandContext.Client => Client;
|
||||
IGuild ICommandContext.Guild => Guild;
|
||||
IMessageChannel ICommandContext.Channel => Channel;
|
||||
IUser ICommandContext.User => User;
|
||||
IUserMessage ICommandContext.Message => Message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user