use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.
the class StaffEmbedModule method receive.
@SubscribeEvent
public void receive(GuildMessageReceivedEvent e) {
if (e.getMember() == null)
return;
if (e.getAuthor().isBot())
return;
if (!e.getMember().getRoles().contains(STAFF_ROLE.query().first()))
return;
String message = e.getMessage().getContentRaw();
if (message.startsWith("^^ ") && message.endsWith(" ^^")) {
e.getMessage().delete().queue();
String text = message.substring(3, message.length() - 3);
e.getChannel().sendMessage(text).queue();
return;
}
if (message.startsWith("^ ")) {
e.getMessage().delete().queue();
String text = message.substring(2);
String[] arguments = text.split("\\^");
if (arguments.length != 2 && arguments.length != 3) {
new TechEmbedBuilder("Invalid Arguments").text("Usage: ^ Title ^ Message ^ (Optional) Thumbnail ^").error().sendTemporary(e.getChannel(), 5);
return;
}
if (arguments.length == 3) {
if (arguments[2].trim().startsWith("#")) {
new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).color(Color.decode(arguments[2].trim())).queue(e.getChannel());
} else {
new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).thumbnail(arguments[2]).queue(e.getChannel());
}
} else {
new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).queue(e.getChannel());
}
}
}
use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.
the class SupportWrongChannelModule method triggerMessage.
public void triggerMessage(Message sentMessage, Member member) {
if (messages.containsValue(member.getId()))
return;
TextChannel verificationChannel = bot.getChannel("907349490556616745");
TechEmbedBuilder teb = new TechEmbedBuilder().text("Hello, " + member.getAsMention() + "! I've detected that you might be trying to get help in this channel! To verify your purchase, we ask you to fill out this [form](https://forms.gle/PBX7z5LaXqdYh7wF6) in order to get help, thanks!\n\n*If you are not trying to get help, you can delete this message by reacting to it!*").error();
// TextChannel verificationChannel = bot.getChannel("907349490556616745");
// TechEmbedBuilder teb = new TechEmbedBuilder()
// .text("Hello, " + member.getAsMention() + "! I've detected that you might be trying to get help in this channel! Please verify in " + verificationChannel.getAsMention() + " in order to get help, thanks!\n\n*If you are not trying to get help, you can delete this message by reacting to it!*")
// .error();
Message message;
Verification verification = TechDiscordBot.getStorage().retrieveVerificationWithDiscord(member);
if (verification != null) {
List<Plugin> pc = Arrays.stream(Plugin.values()).filter(p -> member.getRoles().stream().anyMatch(r -> r.getName().equals(p.getRoleName()))).collect(Collectors.toList());
if (pc.size() > 0) {
StringBuilder sb = new StringBuilder();
String plugins = Plugin.getEmotesByList(pc.stream().map(Plugin::getRoleName).collect(Collectors.toList()));
sb.append("Hello, ").append(member.getAsMention()).append("!\n\n It looks like you have bought ").append(pc.size() == 1 ? "this plugin" : "these plugins").append(" already: ").append(plugins).append("\nHere are the corresponding channels:\n\n");
StringBuilder channels = new StringBuilder();
pc.forEach(p -> channels.append("- ").append(TechDiscordBot.getJDA().getTextChannelById(p.getChannelId()).getAsMention()).append("\n"));
sb.append(channels.toString());
sb.append("\nPlease use the corresponding plugin channel above to get support.\nThis channel is **not** a support channel.\n\n*If you are not trying to get help, you can delete this message by reacting to it!*");
message = new TechEmbedBuilder().text(sb.toString()).error().reply(sentMessage);
} else {
message = teb.reply(sentMessage);
}
} else {
message = teb.reply(sentMessage);
}
if (message != null) {
message.addReaction("\u274C").queue();
messages.put(message.getId(), member.getId());
}
}
use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.
the class TicketModule method createTicket.
public void createTicket(Member member, Plugin plugin, String issue) {
String name = "ticket-" + member.getEffectiveName().replaceAll("[^a-zA-Z\\d\\s_-]", "").toLowerCase();
if (name.equals("ticket-"))
// Make sure the ticket has an actual name. In case the regex result is empty.
name = "ticket-" + member.getUser().getId();
TextChannel ticketChannel = TechDiscordBot.getGuild().createTextChannel(name).setParent(getTicketCategory()).setTopic(member.getAsMention() + "'s Ticket | Problem Solved? Please execute /ticket close.").complete();
ticketChannel.getManager().clearOverridesAdded().complete();
ticketChannel.getManager().clearOverridesRemoved().complete();
List<Permission> permissionsAllow = new ArrayList<>(Arrays.asList(Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY));
ticketChannel.getManager().putPermissionOverride(STAFF_ROLE.query().first(), permissionsAllow, Collections.singletonList(Permission.MESSAGE_TTS)).putPermissionOverride(member, permissionsAllow, Collections.singletonList(Permission.MESSAGE_TTS)).putPermissionOverride(TechDiscordBot.getGuild().getPublicRole(), new ArrayList<>(), Arrays.asList(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)).queue();
String plugins = Plugin.getMembersPluginsinEmojis(member);
new TechEmbedBuilder(member.getEffectiveName() + " - " + member.getUser().getId()).field("Plugin", plugin.getEmoji().getAsMention(), true).field("Owned Plugins", plugins, true).field("Issue", issue, false).queue(ticketChannel);
if (TechDiscordBot.getStorage().isSubVerifiedUser(member.getId())) {
new TechEmbedBuilder("Sub Verified User Support").text("Original Plugin-holder: " + TechDiscordBot.getGuild().getMemberById(TechDiscordBot.getStorage().getVerifiedIdFromSubVerifiedId(member.getId())).getAsMention()).color(Color.ORANGE).queue(ticketChannel);
}
TicketLogs.log(new TechEmbedBuilder("New Ticket").text(member.getAsMention() + " created a new ticket (" + ticketChannel.getAsMention() + ")"));
reset();
}
use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.
the class TicketModule method sendPriorityInstructions.
public void sendPriorityInstructions(Member member) {
if (isSelection)
return;
selectionStep = 1;
Emote lowPriority = PRIORITY_EMOTES.query().get(0);
if (lastInstructions != null)
lastInstructions.delete().queue();
TechEmbedBuilder priority = new TechEmbedBuilder("Ticket Creation" + (member != null ? " (" + member.getEffectiveName() + ")" : "")).text("Please react below to create a ticket!");
priority.queue(channel, message -> setLastInstructions(message, msg -> {
try {
msg.addReaction(lowPriority).queue();
} catch (Exception ignored) {
}
}));
}
use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.
the class TicketModule method sendPluginInstructions.
public void sendPluginInstructions(Member member) {
if (selectionStep != 1)
return;
selectionUserId = member.getId();
isSelection = true;
selectionStep = 2;
String sb = PLUGIN_EMOTES.query().all().stream().map(emote -> emote.getAsMention() + " - " + Plugin.byEmote(emote).getRoleName()).collect(Collectors.joining("\n"));
if (lastInstructions != null)
lastInstructions.delete().queue();
TechEmbedBuilder plugin = new TechEmbedBuilder("Ticket Creation (" + member.getEffectiveName() + ")").text("Please select which plugin the issue corresponds with below:", "", sb, "", ERROR_EMOTE.query().first().getAsMention() + " - Cancel", "");
plugin.queue(channel, message -> setLastInstructions(message, msg -> {
PLUGIN_EMOTES.query().all().stream().filter(emote -> msg != null).forEach(emote -> msg.addReaction(emote).queue((msg2) -> {
try {
msg.addReaction(ERROR_EMOTE.query().first()).queue();
} catch (Exception ignored) {
}
}));
}));
}
Aggregations