use of net.dv8tion.jda.core.events.message.MessageReceivedEvent in project Gary by help-chat.
the class RMSUtils method checkMessage.
private boolean checkMessage(GenericMessageEvent e) {
User author = null;
Message message = null;
if (e instanceof MessageReceivedEvent) {
MessageReceivedEvent ev = (MessageReceivedEvent) e;
author = ev.getAuthor();
message = ev.getMessage();
}
if (e instanceof MessageUpdateEvent) {
MessageUpdateEvent ev = (MessageUpdateEvent) e;
author = ev.getAuthor();
message = ev.getMessage();
}
if (author != null && message != null) {
MessageChannel channel = e.getChannel();
String msg = message.getContentRaw();
List<String> items = new ArrayList<>();
Stream.of("[name]", "[ip]", "[description]").forEach(items::add);
if (mutil.contains(msg, items) || mutil.startsWith(msg, "[REVIEW]")) {
System.out.println(author.getName() + "#" + author.getDiscriminator() + " has successfully created a request.");
return true;
} else {
message.delete().queue();
sendHelp(author, channel, msg);
}
}
return false;
}
use of net.dv8tion.jda.core.events.message.MessageReceivedEvent in project Gary by help-chat.
the class RequestUtils method checkMessage.
public void checkMessage(GenericMessageEvent e) {
User author = null;
Message message = null;
if (e instanceof MessageReceivedEvent) {
MessageReceivedEvent ev = (MessageReceivedEvent) e;
author = ev.getAuthor();
message = ev.getMessage();
}
if (e instanceof MessageUpdateEvent) {
MessageUpdateEvent ev = (MessageUpdateEvent) e;
author = ev.getAuthor();
message = ev.getMessage();
}
if (author != null && message != null) {
MessageChannel channel = e.getChannel();
String msg = message.getContentRaw();
List<String> items = new ArrayList<>();
Stream.of("service:", "what i want:").forEach(items::add);
if (mutil.startsWith(msg, "[paid]")) {
items.add("budget:");
}
if (mutil.contains(msg, items) && mutil.startsWith(msg, "[unpaid]/[paid]")) {
System.out.println(author.getName() + "#" + author.getDiscriminator() + " has successfully created a request.");
} else {
message.delete().queue();
String requirements = "- You must have '[PAID]' or '[UNPAID]' at the top of your request\n" + "- You must have 'Service:' in your request\n" + "- You must have 'What I want:' in your request\n" + "- If paid, you must have 'Budget:' in your request";
String example = "[PAID]/[UNPAID]\n" + "Service: plugin development\n" + "What I want: I need a plugin that spawns llamas all over spawn\n" + "Budget (Only if paid request): $231.95";
User finalAuthor = author;
author.openPrivateChannel().queue(privateChannel -> {
String string = "Your latest request is not following the requirements for <#297996869173379072>.\n\n" + "The requirements are as below:\n```" + requirements + "```\nFor example,\n```" + example + "```\nPlease edit your message below to fit the requirements:\n```" + msg + "```";
privateChannel.sendMessage(string).queue(message1 -> {
}, throwable -> {
String hastebin = wutil.hastebin("Your latest request is not following the requirements for <#297996869173379072>.\n\n" + "The requirements are as below:\n" + requirements + "\n\nFor example,\n\n" + example + "\n\nPlease edit your message below to fit the requirements:\n\n" + msg);
String toSend = !hastebin.equals("fail") ? "**THIS MESSAGE WILL BE REMOVED IN 30 SECONDS!**\n" + finalAuthor.getAsMention() + " Your message does not follow the requirements for <#297996869173379072>, " + "please read this:\n" + hastebin : "**THIS MESSAGE WILL BE REMOVED IN 30 SECONDS!**\n" + finalAuthor.getAsMention() + " Your message does not follow the requirements for <#297996869173379072>, " + "please fix any mistakes.\nhastebin.com is down and you have pm's disabled, " + "I cannot show you your message, you will have to try remember it.";
channel.sendMessage(toSend).queue(message1 -> message1.delete().completeAfter(30, TimeUnit.SECONDS));
});
});
}
}
}
use of net.dv8tion.jda.core.events.message.MessageReceivedEvent in project legendarybot by greatman.
the class LinkWoWCharsCommand method execute.
@Override
public void execute(MessageReceivedEvent event, String[] args) {
String region = plugin.getBot().getGuildSettings(event.getGuild()).getRegionName();
if (region == null) {
event.getChannel().sendMessage("The Region is not configured. Please ask a server admin to configure it with the setup command").queue();
return;
}
OAuth20Service service = new ServiceBuilder(plugin.getProps().getProperty("battlenetoauth.key")).scope("wow.profile").callback("https://legendarybot.greatmancode.com/auth/battlenetcallback").state(region + ":" + event.getAuthor().getId()).build(new OAuthBattleNetApi(region));
event.getAuthor().openPrivateChannel().queue((privateChannel -> privateChannel.sendMessage("Please follow this link to connect your WoW account to this bot: " + service.getAuthorizationUrl()).queue()));
log.info("User " + event.getAuthor().getName() + ":" + event.getAuthor().getId() + " requested to link his characters. Link generated: " + service.getAuthorizationUrl());
}
use of net.dv8tion.jda.core.events.message.MessageReceivedEvent in project legendarybot by greatman.
the class DebugGuildCommand method execute.
@Override
public void execute(MessageReceivedEvent event, String[] args) {
if (args.length == 2) {
List<Guild> userGuilds = new ArrayList<>();
getBot().getJDA().forEach((jda) -> userGuilds.addAll(jda.getUserById(args[1]).getMutualGuilds()));
StringBuilder builder = new StringBuilder();
userGuilds.forEach(guild -> {
builder.append(guild.getName() + ":" + guild.getId());
});
event.getAuthor().openPrivateChannel().queue(new Consumer<PrivateChannel>() {
@Override
public void accept(PrivateChannel privateChannel) {
privateChannel.sendMessage(builder.toString()).queue();
}
});
return;
}
final Guild[] guildEntry = { null };
getBot().getJDA().forEach((jda -> {
if (guildEntry[0] == null) {
guildEntry[0] = jda.getGuildById(args[0]);
}
}));
if (guildEntry[0] != null) {
Guild guild = guildEntry[0];
StringBuilder builder = new StringBuilder();
PrivateChannel channel = event.getAuthor().openPrivateChannel().complete();
builder.append("Guild " + guild.getName() + "\n");
builder.append("Roles:\n");
guild.getRoles().forEach((role -> builder.append(role.getName() + "\n")));
builder.append("Config:\n");
builder.append("Guild Name: " + getBot().getGuildSettings(guild).getGuildName() + "\n");
builder.append("Region Name: " + getBot().getGuildSettings(guild).getRegionName() + "\n");
builder.append("Realm name: " + getBot().getGuildSettings(guild).getWowServerName() + "\n");
builder.append("WoW Rank config:\n");
builder.append("Rank 0: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_0") + "\n");
builder.append("Rank 1: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_1") + "\n");
builder.append("Rank 2: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_2") + "\n");
builder.append("Rank 3: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_3") + "\n");
builder.append("Rank 4: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_4") + "\n");
builder.append("Rank 5: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_5") + "\n");
builder.append("Rank 6: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_6") + "\n");
builder.append("Rank 7: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_7") + "\n");
builder.append("Rank 8: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_8") + "\n");
builder.append("Rank 9: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_9") + "\n");
builder.append("Rank Enabled: " + getBot().getGuildSettings(guild).getSetting("wowlink_rankset") + "\n");
channel.sendMessage(builder.toString()).queue();
}
}
Aggregations