use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Blackjack method dispatchRound.
public void dispatchRound(int bet, Hand yourHand, Hand dealerHand, Guild guild, MessageChannel channel, User user, Message message, String[] args) {
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor("Blackjack | " + user.getName(), user.getEffectiveAvatarUrl(), user.getEffectiveAvatarUrl());
builder.setDescription("Type `hit` to get another card, `stay` to stay with your current cards, or `cancel` to cancel the game " + "(you " + "will lose 50% of your original bet)");
builder.addField("Your hand", yourHand.readable(), true);
builder.addField("My hand", dealerHand.readable(), true);
sendEmbed(builder, channel, user);
boolean success = longInteractiveOperation(channel, message, 25, actionMessage -> {
String content = actionMessage.getContent();
if (content.equalsIgnoreCase("hit")) {
yourHand.generate();
if (yourHand.total() > 21) {
showResults(bet, yourHand, dealerHand, guild, channel, user, message, args);
} else
dispatchRound(bet, yourHand, dealerHand, guild, channel, user, message, args);
} else if (content.equalsIgnoreCase("stay")) {
showResults(bet, yourHand, dealerHand, guild, channel, user, message, args);
} else if (content.equalsIgnoreCase("cancel")) {
sendTranslatedMessage("Cancelled game, but you lost 50% of your original bet", channel, user);
sessions.remove(user.getId());
Profile.get(user).removeMoney(bet / 2);
} else {
sendTranslatedMessage("Invalid input! Restarting your round... type `cancel` if you want to cancel this game", channel, user);
dispatchRound(bet, yourHand, dealerHand, guild, channel, user, message, args);
}
});
if (!success)
sessions.remove(user.getId());
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Whois method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] arg) throws Exception {
Shard shard = GuildUtils.getShard(guild);
Member member;
List<User> mentionedUsers = message.getMentionedUsers();
if (mentionedUsers.size() > 0) {
member = guild.getMember(mentionedUsers.get(0));
} else
member = guild.getMember(user);
List<Role> rolesList = member.getRoles();
String nick;
if (member.getNickname() == null)
nick = "None";
else
nick = member.getNickname();
long digTemp = Instant.now().atOffset(ZoneOffset.UTC).toEpochSecond() - member.getJoinDate().toInstant().atOffset(ZoneOffset.UTC).toEpochSecond();
long daysInGuild = Math.round(digTemp / (60 * 60 * 24));
if (daysInGuild == 0)
daysInGuild = 1;
StringBuilder roles = new StringBuilder();
for (int i = 0; i < rolesList.size(); i++) {
if (i == 0)
roles.append(rolesList.get(0).getName());
else
roles.append(", " + rolesList.get(i).getName());
}
EmbedBuilder builder = MessageUtils.getDefaultEmbed(message.getAuthor());
builder.setAuthor("Information About {0}".replace("{0}", member.getUser().getName()), "https://ardentbot.tk/guild", shard.bot.getAvatarUrl());
builder.setThumbnail(member.getUser().getAvatarUrl());
builder.addField("Discord Name", member.getUser().getName(), true);
builder.addField("Nickname", nick, true);
builder.addField("Discriminator", "#" + member.getUser().getDiscriminator(), true);
builder.addField("Server Join Date", member.getJoinDate().toLocalDate().toString(), true);
builder.addField("Days in Server", String.valueOf(daysInGuild), true);
builder.addField("Roles", roles.toString(), true);
builder.addField("Discord Join Date", member.getUser().getCreationTime().toLocalDate().toString(), true);
sendEmbed(builder, channel, user);
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Help method setupSubcommands.
@Override
public void setupSubcommands() {
all = new Subcommand("See the traditional help screen", "all", "all") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
EmbedBuilder helpEmbed = MessageUtils.getDefaultEmbed(user);
helpEmbed.setAuthor("Ardent Help", "https://ardentbot.tk/guild", getShard().bot.getAvatarUrl());
helpEmbed.setThumbnail("https://a.dryicons.com/images/icon_sets/polygon_icons/png/256x256/computer" + ".png");
StringBuilder description = new StringBuilder();
description.append("Command Categories\n");
for (Category category : Category.values()) {
description.append(" > **" + category.name().toLowerCase() + "**\n");
}
description.append("\nType /help [category] to view a specific category\n\nIf you need help, join our support guild: " + "https://ardentbot.tk/guild");
helpEmbed.setDescription(description.toString());
sendEmbed(helpEmbed, channel, user);
}
};
subcommands.add(all);
for (Category category : Category.values()) {
subcommands.add(new Subcommand("how tf did you see this", Category.getName(category), Category.getName(category)) {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(user);
embedBuilder.setAuthor("Commands in Category ".replace("{0}", WordUtils.capitalize(category.name().toLowerCase())), "https://ardentbot.tk/guild", getShard().bot.getAvatarUrl());
ArrayList<BaseCommand> commandsInCategory = Help.this.getCommandsInCategory(category);
StringBuilder description = new StringBuilder();
for (BaseCommand baseCommand : commandsInCategory) {
description.append(" > **" + baseCommand.getName() + "**: " + baseCommand.getDescription() + "\n");
}
embedBuilder.setDescription(description.toString());
sendEmbed(embedBuilder, channel, user);
}
});
}
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Restrict method setupSubcommands.
@Override
public void setupSubcommands() throws Exception {
subcommands.add(new Subcommand("Prevent a user from using Ardent commands", "block @User", "block") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
Member member = guild.getMember(user);
if (member.hasPermission(Permission.MANAGE_SERVER)) {
List<User> mentionedUsers = message.getMentionedUsers();
if (mentionedUsers.size() > 0) {
for (User mentioned : mentionedUsers) {
Member mentionedMember = guild.getMember(mentioned);
if (mentionedMember.hasPermission(member.getPermissions()) || mentionedMember.hasPermission(Permission.MANAGE_SERVER) || mentionedMember.getUser().getId().equalsIgnoreCase(guild.getSelfMember().getUser().getId())) {
sendTranslatedMessage("You cannot modify this user because they have the same or higher permissions than " + "you.", channel, user);
return;
}
EntityGuild entityGuild = EntityGuild.get(guild);
boolean isRestricted = entityGuild.isRestricted(mentioned);
if (isRestricted) {
sendTranslatedMessage("This user has already been blocked from using commands!", channel, user);
} else {
RestrictedUser restrictedUser = new RestrictedUser(mentioned.getId(), user.getId(), guild);
entityGuild.addRestricted(restrictedUser);
r.db("data").table("restricted").insert(r.json(gson.toJson(new RestrictedUserModel(guild.getId(), mentioned.getId(), user.getId())))).run(connection);
sendEditedTranslation("{1} has blocked {0} from sending commands", user, channel, mentioned.getName(), user.getName());
}
}
} else
sendTranslatedMessage("You need to mention one or more users", channel, user);
} else
sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
}
});
subcommands.add(new Subcommand("Allow a blocked user to run Ardent commands again", "unblock @User", "unblock") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (guild.getMember(user).hasPermission(Permission.MANAGE_SERVER)) {
List<User> mentionedUsers = message.getMentionedUsers();
if (mentionedUsers.size() > 0) {
for (User mentioned : mentionedUsers) {
EntityGuild entityGuild = EntityGuild.get(guild);
boolean isRestricted = entityGuild.isRestricted(mentioned);
if (!isRestricted) {
sendEditedTranslation("{0} isn't restricted from sending commands!", user, channel, mentioned.getName());
} else {
entityGuild.removeRestricted(mentioned.getId());
r.db("data").table("restricted").filter(row -> row.g("user_id").eq(mentioned.getId()).and(row.g("guild_id").eq(guild.getId()))).delete().run(connection);
sendEditedTranslation("{0} unrestricted {1}, allowing them to use commands again", user, channel, mentioned.getName(), user.getName());
}
}
} else
sendTranslatedMessage("You need to mention one or more users", channel, user);
} else
sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
}
});
subcommands.add(new Subcommand("View all the users who have been blocked in your server", "view") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
EntityGuild entityGuild = EntityGuild.get(guild);
ArrayList<RestrictedUser> restrictedUsers = entityGuild.getRestrictedUsers();
String title = "Restricted users";
String restrictedBy = "restricted by";
StringBuilder response = new StringBuilder();
response.append("**" + title + "**");
if (restrictedUsers.size() == 0) {
response.append("\nNo one");
} else {
restrictedUsers.forEach(restrictedUser -> response.append("\n - " + guild.getMemberById(restrictedUser.getUserId()).getUser().getName() + ", " + restrictedBy + " " + guild.getMemberById(restrictedUser.getRestrictedById()).getUser().getName()));
}
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor(title, getShard().url, guild.getSelfMember().getUser().getAvatarUrl());
builder.setDescription(response.toString());
sendEmbed(builder, channel, user);
}
});
}
use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.
the class ClearCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(false);
DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().clear();
DiscordBot.getInstance().getDiscord().getAudioPlayer().stopTrack();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
embedBuilder.setTitle("Queue cleared.", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Aggregations