Browse Source

Make ShardedCommandContext derive from SocketCommandContext

pull/739/head
Joe4evr 8 years ago
parent
commit
4efe8b42bc
1 changed files with 5 additions and 18 deletions
  1. +5
    -18
      src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs

+ 5
- 18
src/Discord.Net.WebSocket/Commands/ShardedCommandContext.cs View File

@@ -2,30 +2,17 @@

namespace Discord.Commands
{
public class ShardedCommandContext : ICommandContext
public class ShardedCommandContext : SocketCommandContext
{
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;
}

//ICommandContext
IDiscordClient ICommandContext.Client => Client;
IGuild ICommandContext.Guild => Guild;
IMessageChannel ICommandContext.Channel => Channel;
IUser ICommandContext.User => User;
IUserMessage ICommandContext.Message => Message;
private static int GetShardId(DiscordShardedClient client, IGuild guild)
=> guild == null ? 0 : client.GetShardIdFor(guild);
}
}

Loading…
Cancel
Save