You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
using Discord.WebSocket;
|
|
|
|
namespace Discord.Commands
|
|
{
|
|
/// <summary> The sharded variant of <see cref="ICommandContext"/>, which may contain the client, user, guild, channel, and message. </summary>
|
|
public class ShardedCommandContext : SocketCommandContext, ICommandContext
|
|
{
|
|
/// <summary> Gets the <see cref="DiscordShardedClient"/> that the command is executed with. </summary>
|
|
public new DiscordShardedClient Client { get; }
|
|
|
|
public ShardedCommandContext(DiscordShardedClient client, SocketUserMessage msg)
|
|
: base(client.GetShard(GetShardId(client, (msg.Channel as SocketGuildChannel)?.Guild)), msg)
|
|
{
|
|
Client = client;
|
|
}
|
|
|
|
/// <summary> Gets the shard ID of the command context. </summary>
|
|
private static int GetShardId(DiscordShardedClient client, IGuild guild)
|
|
=> guild == null ? 0 : client.GetShardIdFor(guild);
|
|
|
|
//ICommandContext
|
|
/// <inheritdoc />
|
|
IDiscordClient ICommandContext.Client => Client;
|
|
}
|
|
}
|