Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

develop #18

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
- name: Build with Maven
run: mvn -B test package --file pom.xml

- if: github.event_name == 'push'
name: Upload via SCP
- name: Upload via SCP
uses: appleboy/[email protected]
with:
host: turniptales.net
Expand All @@ -44,8 +43,7 @@ jobs:
timeout: 120s
strip_components: 1

- if: github.event_name == 'push'
name: Restart TurnipTales API
- name: Restart TurnipTales API
uses: appleboy/[email protected]
with:
host: turniptales.net
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.turniptales.discord.buttons.TicketCloseButton;
import net.turniptales.discord.buttons.TicketCloseConfirmButton;
import net.turniptales.discord.buttons.TicketCreateButton;
import net.turniptales.discord.buttons.TicketVoiceButton;
import net.turniptales.discord.commands.GiveawayCommand;
import net.turniptales.discord.commands.MessageCommand;
import net.turniptales.discord.commands.RolesCommand;
Expand Down Expand Up @@ -85,7 +86,8 @@ private static void startDiscordBot() throws InterruptedException {
new TicketCloseAbortButton(),
new TicketCloseButton(),
new TicketCloseConfirmButton(),
new TicketCreateButton()
new TicketCreateButton(),
new TicketVoiceButton()
)
.build().awaitReady();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public TicketCloseAbortButton() {

@Override
public void onButtonClick(ButtonInteractionEvent event) {
event.getMessage().delete().queue();
String messageId = event.getMessage().getId();
event.getChannel().deleteMessageById(messageId).queue();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package net.turniptales.discord.buttons;

import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;

import java.util.Objects;

import static net.turniptales.discord.TurnipTalesDiscord.discordBotProperties;

public class TicketCloseConfirmButton extends ButtonBase {
Expand All @@ -15,9 +12,9 @@ public TicketCloseConfirmButton() {

@Override
public void onButtonClick(ButtonInteractionEvent event) {
TextChannel textChannel = event.getChannel().asTextChannel();
if (Objects.equals(textChannel.getParentCategory(), discordBotProperties.getTicketCategory()) && textChannel.getName().startsWith("ticket-")) {
textChannel.delete().queue();
}
String userName = event.getChannel().getName().split("-")[1];
discordBotProperties.getTicketCategory().getChannels().stream()
.filter(guildChannel -> guildChannel.getName().startsWith("ticket-") && guildChannel.getName().contains(userName))
.forEach(guildChannel -> guildChannel.delete().queue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static java.util.Objects.requireNonNull;
import static net.dv8tion.jda.api.Permission.VIEW_CHANNEL;
import static net.dv8tion.jda.api.entities.emoji.Emoji.fromUnicode;
import static net.dv8tion.jda.api.interactions.components.buttons.Button.secondary;
import static net.dv8tion.jda.api.interactions.components.buttons.Button.success;
import static net.dv8tion.jda.api.interactions.components.text.TextInputStyle.PARAGRAPH;
import static net.dv8tion.jda.api.interactions.modals.Modal.create;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void onModalInteraction(ModalInteractionEvent event) {
.sendMessage("Hey " + member.getAsMention() + "! Danke dass du ein Ticket erstellt hast. Die " + supporterRole.getAsMention() + " und " + moderatorRole.getAsMention() + " werden Dir schnellstmöglich deine Frage beantworten oder Dir helfen.\n"
+ "Spieler: " + minecraftName + "\n"
+ "Anliegen: " + log)
.addActionRow(success("closeTicket", "Ticket schließen").withEmoji(fromUnicode("U+1F512")))
.addActionRow(success("btn_ticket_close", "Ticket schließen").withEmoji(fromUnicode("U+1F512")), secondary("btn_ticket_voice", "Voice-Channel erstellen").withEmoji(fromUnicode("U+1F50A")))
.queue(message -> event.reply("Du hast ein Ticket erstellt: " + message.getJumpUrl()).setEphemeral(true).queue()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.turniptales.discord.buttons;

import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;

import java.util.EnumSet;
import java.util.Optional;

import static java.util.Objects.requireNonNull;
import static net.dv8tion.jda.api.Permission.VIEW_CHANNEL;
import static net.turniptales.discord.TurnipTalesDiscord.discordBotProperties;
import static net.turniptales.discord.common.services.UtilService.sendSelfDeletingMessage;

public class TicketVoiceButton extends ButtonBase {

public TicketVoiceButton() {
super("btn_ticket_voice");
}

@Override
public void onButtonClick(ButtonInteractionEvent event) {
Member member = event.getMember();

Optional<GuildChannel> optionalGuildChannel = discordBotProperties.getTicketCategory().getChannels().stream()
.filter(guildChannel -> guildChannel instanceof VoiceChannel)
.filter(guildChannel -> guildChannel.getName().equalsIgnoreCase("ticket-" + member.getUser().getName()))
.findFirst();

if (optionalGuildChannel.isPresent()) {
sendSelfDeletingMessage(event, "Für dieses Ticket gibt es bereits einen Voice-Channel!");
return;
}

String userName = requireNonNull(member).getUser().getName();

discordBotProperties.getTicketCategory().createVoiceChannel("ticket-" + userName)
.addPermissionOverride(discordBotProperties.getGuild().getPublicRole(), null, EnumSet.of(VIEW_CHANNEL))
.addPermissionOverride(member, EnumSet.of(VIEW_CHANNEL), null)
.addPermissionOverride(discordBotProperties.getSeniorModeratorRole(), EnumSet.of(VIEW_CHANNEL), null)
.addPermissionOverride(discordBotProperties.getModeratorRole(), EnumSet.of(VIEW_CHANNEL), null)
.addPermissionOverride(discordBotProperties.getSupporterRole(), EnumSet.of(VIEW_CHANNEL), null)
.queue(voiceChannel -> sendSelfDeletingMessage(event, "Voice-Channel erstellt!"));
}
}