use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class Commands method handleCommand.
public void handleCommand(PrivateMessageReceivedEvent e) {
MessageContext<PrivateMessageReceivedEvent> context = new MessageContext<PrivateMessageReceivedEvent>(e);
String message = e.getMessage().getContentRaw();
try {
DiscordUser sender = DiscordUser.getDiscordUser(ConsoleContext.INSTANCE, e.getAuthor().getIdLong());
if (!sender.isBanned()) {
if (!sender.isBanned()) {
CommandAudit.addCommandAudit(context, message);
this.dispatcher.execute(message, context);
}
}
} catch (CommandSyntaxException ex) {
context.sendMessage(ex.getMessage());
} catch (Throwable t) {
context.sendMessage(StacktraceUtil.getStackTrace(t));
if (!context.isConsoleMessage()) {
t.printStackTrace();
}
if (t instanceof Error) {
throw t;
}
}
}
use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class RegisterCommand method requestRegistration.
@SuppressWarnings("rawtypes")
private static void requestRegistration(MessageContext context, String player) {
HashSet<Player> players = new HashSet<Player>();
DiscordUser discordUser = context.getDiscordAuthor();
if (context.isConsoleMessage()) {
context.sendMessage("This command must be executed from discord.");
return;
}
if (discordUser.requestingRegistration()) {
context.sendMessage("You are already trying to register a profile! Please wait until registration is complete or the registration code expires.");
return;
}
try {
int pid = Integer.parseInt(player);
players.add(Player.getPlayerByID(ConsoleContext.INSTANCE, pid));
} catch (NumberFormatException e) {
for (Player p : Player.getPlayersByName(ConsoleContext.INSTANCE, player)) {
players.add(p);
}
}
switch(players.size()) {
case 0:
context.sendMessage("Could not find a player with name or PID of " + player);
break;
case 1:
Player desiredProfile = players.toArray(new Player[] {})[0];
if (desiredProfile.isBanned()) {
context.sendMessage("You cannot register a banned profile.");
return;
}
String securityCode = discordUser.requestRegistration(desiredProfile);
sendInfo(context, discordUser, desiredProfile, securityCode);
break;
default:
String ambiguities = "";
for (Player p : players) {
ambiguities += p.toFullString() + "\n";
}
context.sendMessage(player + " is ambiguous as there is more than one profile known with that name. Please supply your account's PID instead of it's name." + "\n\nAmbiguities:\n\n" + ambiguities);
break;
}
}
Aggregations