Added support for custom ModuleBase command contexts. Added SocketCommandContext/RpcCommandContext.
This commit is contained in:
31
src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs
Normal file
31
src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Discord.Commands
|
||||
{
|
||||
public class SocketCommandContext : ICommandContext
|
||||
{
|
||||
public DiscordSocketClient 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 SocketCommandContext(DiscordSocketClient client, SocketUserMessage 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user