Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
🐛 unregistered config
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnih-1 committed Feb 11, 2023
1 parent 3aae7b1 commit c1d4ef5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public class ServerCreatedSuccessEmbedValue implements ConfigurationInjectable {
@ConfigField("fields") private ConfigurationSection section;

@SneakyThrows
public MessageEmbed toEmbed(ApplicationServer server, Plan plan) {
public MessageEmbed toEmbed(Plan plan) {
val yamlFile = new YamlFile("configuration/embed.yml");
yamlFile.load();
val embed = new EmbedBuilder();

embed.setColor(Color.GREEN);
embed.setTitle(title);
embed.setFooter(footer);
Expand All @@ -57,7 +58,7 @@ public MessageEmbed toEmbed(ApplicationServer server, Plan plan) {

case "value":
value.append(section.getString(field)
.replace("%servidor", server.getName())
.replace("%servidor", plan.getPrePlan().getTitle())
.replace("%id", plan.getId()));
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void register() {
ServerCreatedFailureEmbedValue.instance(),
ServerCreatedSuccessEmbedValue.instance(),
UserCreatedFailureEmbedValue.instance(),
UserCreatedFailureEmbedValue.instance(),
UserCreatedSuccessEmbedValue.instance(),
SupportTicketEmbedValue.instance(),
UpgradeTicketEmbedValue.instance(),
FeedbackTicketEmbedValue.instance(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.val;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import project.kazumy.realhosting.configuration.embed.FeedbackTicketEmbedValue;
import project.kazumy.realhosting.configuration.menu.FeedbackMenuValue;
Expand All @@ -28,7 +29,7 @@ public void execute(ButtonInteractionEvent event) {
return;
}

if (!ticket.getOwner().equals(event.getUser().getId())) {
if (!ticket.getOwner().equals(event.getUser().getId()) && !event.getMember().hasPermission(Permission.ADMINISTRATOR)) {
event.deferReply(true).addEmbeds(new EmbedBuilder()
.setColor(Color.GRAY)
.setTitle(":warning: | Você não pode fechar este ticket!")
Expand All @@ -47,7 +48,8 @@ public void execute(ButtonInteractionEvent event) {
.setFooter("Todas as informações serão guardadas")
.build()).queue();

event.getUser().openPrivateChannel().queue(channel -> {
event.getGuild().getMemberById(ticket.getOwner())
.getUser().openPrivateChannel().queue(channel -> {
channel.sendMessageEmbeds(FeedbackTicketEmbedValue.instance().toEmbed(success))
.addActionRow(FeedbackMenuValue.get(FeedbackMenuValue::toMenu))
.queue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.utils.FileUpload;
import project.kazumy.realhosting.configuration.basic.GuildValue;
import project.kazumy.realhosting.configuration.embed.ServerCreatedFailureEmbedValue;
import project.kazumy.realhosting.configuration.embed.ServerCreatedSuccessEmbedValue;
import project.kazumy.realhosting.configuration.embed.UserCreatedFailureEmbedValue;
Expand All @@ -16,6 +17,7 @@
import project.kazumy.realhosting.model.payment.utils.PaymentUtils;

import java.awt.*;
import java.util.logging.Logger;
import java.util.regex.Pattern;

public class PurchasePlanModalInteraction extends InteractionService<ModalInteractionEvent> {
Expand Down Expand Up @@ -46,6 +48,7 @@ public void execute(ModalInteractionEvent event) {
val planId = event.getMessage().getEmbeds().get(0).getFields().get(1).getValue();
val client = discordMain.getClientManager().getClientById(event.getMember().getId());
val panelUsers = client.getPanel().usersExistsByUsername(event.getValue("username").getAsString());
val guild = discordMain.getJda().getGuildById(GuildValue.get(GuildValue::id));

if (!panelUsers.isEmpty()) {
val panelUser = panelUsers.get(0);
Expand Down Expand Up @@ -75,17 +78,25 @@ public void execute(ModalInteractionEvent event) {
plan.setStageType(StageType.ACTIVED);
discordMain.getPlanManager().savePlan(plan);

val member = guild.getMemberById(plan.getOwner());
val role = guild.getRoles().stream()
.filter(roles -> roles.getId().equals("855625716078870538")).findFirst().get();

guild.addRoleToMember(member, role).queue(unused -> {
Logger.getGlobal().info("A tag Cliente foi cedida ao usuário " + plan.getOwner());
});

client.getPanel().syncUserByEmail(client.getEmail(), user -> {
client.getPanel().createServer(plan, server -> {
event.getChannel().sendMessageEmbeds(ServerCreatedSuccessEmbedValue.instance().toEmbed(server, plan)).queue();
event.getChannel().sendMessageEmbeds(ServerCreatedSuccessEmbedValue.instance().toEmbed(plan)).queue();
}, error -> {
event.getChannel().sendMessageEmbeds(ServerCreatedFailureEmbedValue.instance().toEmbed(plan)).queue();
});
}, failure -> failure.createUser(client.getName(), client.getLastname(), client.getUsername(), client.getEmail(), user -> {
client.getPanel().createServer(plan, server -> {
event.getChannel().sendMessageEmbeds(
UserCreatedSuccessEmbedValue.instance().toEmbed(client.getEmail(), client.getPanel().getPassword()),
ServerCreatedSuccessEmbedValue.instance().toEmbed(server, plan)).queue();
ServerCreatedSuccessEmbedValue.instance().toEmbed(plan)).queue();
}, error -> {
event.getChannel().sendMessageEmbeds(ServerCreatedFailureEmbedValue.instance().toEmbed(plan)).queue();
});
Expand Down

0 comments on commit c1d4ef5

Please sign in to comment.