More context

keep-around/23b8b9e8830874d5f04b57600c3660bddce1287b
Pingex aka Raphaël 9 years ago
parent 17185123e4
commit 9d6ccc3344

@ -1,7 +1,9 @@
package net.pingex.dcf.commands; package net.pingex.dcf.commands;
import sx.blah.discord.api.IDiscordClient; import sx.blah.discord.api.IDiscordClient;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IMessage; import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IUser;
import java.util.List; import java.util.List;
/** /**
@ -19,6 +21,16 @@ public class Context
*/ */
private List<String> arguments; private List<String> arguments;
/**
* User to audit against
*/
private IUser user;
/**
* Channel to audit against
*/
private IChannel channel;
/** /**
* The originating reference message * The originating reference message
*/ */
@ -29,10 +41,38 @@ public class Context
*/ */
private IDiscordClient client; private IDiscordClient client;
/**
* Construct a context using the provided message. user and channel will be derived from the message.
* @param command Command being executed.
* @param arguments Its arguments.
* @param originatingMessage The messaged used to invoke the command.
* @param client Discord client.
*/
public Context(Command command, List<String> arguments, IMessage originatingMessage, IDiscordClient client) public Context(Command command, List<String> arguments, IMessage originatingMessage, IDiscordClient client)
{ {
this.command = command; this.command = command;
this.arguments = arguments; this.arguments = arguments;
this.user = originatingMessage.getAuthor();
this.channel = originatingMessage.getChannel();
this.originatingMessage = originatingMessage;
this.client = client;
}
/**
* Construct a context using explicit user and channel. The provided message is here for reference.
* @param command Command being executed.
* @param arguments Its arguments.
* @param user User invoking the command.
* @param channel Channel used to invoke the command.
* @param originatingMessage The messaged used to invoke the command.
* @param client Discord client.
*/
public Context(Command command, List<String> arguments, IUser user, IChannel channel, IMessage originatingMessage, IDiscordClient client)
{
this.command = command;
this.arguments = arguments;
this.user = user;
this.channel = channel;
this.originatingMessage = originatingMessage; this.originatingMessage = originatingMessage;
this.client = client; this.client = client;
} }
@ -47,6 +87,16 @@ public class Context
return arguments; return arguments;
} }
public IUser getUser()
{
return user;
}
public IChannel getChannel()
{
return channel;
}
public IMessage getOriginatingMessage() public IMessage getOriginatingMessage()
{ {
return originatingMessage; return originatingMessage;