use of net.dv8tion.jda.api.entities.PrivateChannel in project Vinny by kikkia.
the class MemeKickCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "Memekick")
protected void executeCommand(CommandEvent commandEvent) {
if (commandEvent.getMessage().getMentionedUsers().size() == 0) {
commandEvent.replyWarning("You must specify at least one user to memekick");
}
for (Member member : commandEvent.getMessage().getMentionedMembers()) {
if (member.getUser().isBot()) {
commandEvent.replyWarning("I will not memekick bots");
continue;
}
Invite invite = commandEvent.getTextChannel().createInvite().setMaxUses(1).complete();
try {
PrivateChannel channel = member.getUser().openPrivateChannel().complete();
channel.sendMessage(invite.getUrl()).queue();
} catch (Exception e) {
commandEvent.replyWarning("Will not meme kick user: " + member.getEffectiveName() + " because I cannot send " + "them an invite to get back");
continue;
}
List<Role> roles = member.getRoles();
try {
member.kick().queue();
} catch (Exception e) {
commandEvent.replyWarning("Failed to kick " + member.getEffectiveName() + " make sure the Vinny role is higher on the role hierarchy");
continue;
}
waiter.waitForEvent(GuildMemberJoinEvent.class, e -> e.getUser().getId().equals(member.getUser().getId()), new ReRoleConsumer(roles, commandEvent.getTextChannel()), 1, TimeUnit.DAYS, () -> {
});
}
commandEvent.reactSuccess();
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project Nexus by ProjectEdenGG.
the class DiscordCaptchaListener method onMessageReactionAdd.
@Override
public void onMessageReactionAdd(@Nonnull MessageReactionAddEvent event) {
Tasks.async(() -> {
if (event.getChannelType() != ChannelType.PRIVATE)
return;
if (event.getUser() == null) {
Nexus.log("[Captcha] Received reaction from null user");
return;
}
final String id = event.getUser().getId();
DiscordCaptchaService captchaService = new DiscordCaptchaService();
DiscordCaptcha captcha = captchaService.get0();
CaptchaResult result = captcha.check(id);
if (result == CaptchaResult.UNCONFIRMED) {
captcha.confirm(id);
Member member = Discord.getGuild().retrieveMemberById(id).complete();
PrivateChannel complete = event.getUser().openPrivateChannel().complete();
if (member == null) {
Message message = complete.getHistory().getMessageById(event.getMessageId());
if (message == null)
Nexus.warn("[Captcha] Could not find original message");
else
message.editMessage("Account confirmed. You may now join the server again: " + EdenSocialMediaSite.DISCORD.getUrl()).queue();
} else
complete.sendMessage("Account confirmed, thank you!").queue();
captchaService.save(captcha);
}
});
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project dDiscordBot by DenizenScript.
the class DiscordMessageReceivedScriptEvent method getContext.
@Override
public ObjectTag getContext(String name) {
switch(name) {
case "channel":
return new DiscordChannelTag(botID, getEvent().getChannel());
case "group":
if (getEvent().isFromGuild()) {
return new DiscordGroupTag(botID, getEvent().getGuild());
}
break;
case "new_message":
return new DiscordMessageTag(botID, getEvent().getMessage());
case "message":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new ElementTag(getEvent().getMessage().getContentRaw());
case "message_id":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new ElementTag(getEvent().getMessage().getId());
case "no_mention_message":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new ElementTag(DiscordMessageTag.stripMentions(getEvent().getMessage().getContentRaw()));
case "formatted_message":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new ElementTag(getEvent().getMessage().getContentDisplay());
case "author":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new DiscordUserTag(botID, getEvent().getMessage().getAuthor());
case "mentions":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
ListTag list = new ListTag();
for (User user : getEvent().getMessage().getMentionedUsers()) {
list.addObject(new DiscordUserTag(botID, user));
}
return list;
case "is_direct":
DenizenDiscordBot.oldMessageContexts.warn((TagContext) null);
return new ElementTag(getEvent().getChannel() instanceof PrivateChannel);
}
return super.getContext(name);
}
Aggregations