Skip to content
Open
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
3 changes: 3 additions & 0 deletions config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ baseChannel: 0
# Channel ID for logging closed tickets and transcripts (0 = disabled)
logChannel: 0

# Channel ID for posting supporter reminders (0 = uses logChannel)
supporterReminderChannel: 0

# Channel ID for posting daily stats (0 = disabled)
ratingStatsChannel: 0

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/eu/greev/dcbot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public static void main(String[] args) throws InterruptedException, IOException
.addOption(OptionType.STRING, "type", "Report type: daily, weekly, monthly", true))
.addSubcommands(new SubcommandData("set-privacy", "Toggle ob deine XP/Ratings öffentlich angezeigt werden")
.addOption(OptionType.STRING, "mode", "visible oder hidden", true))
.addSubcommands(new SubcommandData("list-claimed", "List your claimed tickets"))
).queue(s -> s.get(0).getSubcommands().forEach(c -> {
if (c.getName().equals("get-tickets")) {
getTicketCommandId = c.getId();
Expand Down Expand Up @@ -212,6 +213,8 @@ public static void main(String[] args) throws InterruptedException, IOException
registerInteraction("debug-stats", new DebugStats(config, ticketService, missingPerm, jda));
registerInteraction("set-privacy", new SetPrivacy(config, ticketService, missingPerm, jda, supporterSettingsData));

registerInteraction("list-claimed", new ListClaimedTickets(config, ticketService, missingPerm, jda));

log.info("Started: {}", OffsetDateTime.now(ZoneId.systemDefault()));

}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/eu/greev/dcbot/scheduler/DailyScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ private void run() {

embedBuilder.setDescription(description.toString());

var logChannel = jda.getTextChannelById(config.getLogChannel());
if (logChannel != null) {
logChannel.sendMessage(mentions.toString())
var channel = jda.getTextChannelById(config.getSupporterReminderChannel() == 0 ? config.getLogChannel() : config.getSupporterReminderChannel());
if (channel != null) {
channel.sendMessage(mentions.toString())
.addEmbeds(embedBuilder.build())
.queue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package eu.greev.dcbot.ticketsystem.interactions.commands;

import eu.greev.dcbot.ticketsystem.service.TicketService;
import eu.greev.dcbot.utils.Config;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.Event;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;

import java.awt.*;

public class ListClaimedTickets extends AbstractCommand {
public ListClaimedTickets(Config config, TicketService ticketService, EmbedBuilder missingPerm, JDA jda) {
super(config, ticketService, missingPerm, jda);
}

@Override
public void execute(Event evt) {
SlashCommandInteractionEvent event = (SlashCommandInteractionEvent) evt;
Member member = event.getMember();
if (!hasStaffPermission(member)) {
event.replyEmbeds(missingPerm.setFooter(config.getServerName(), config.getServerLogo()).build()).setEphemeral(true).queue();
return;
}

StringBuilder stringBuilder = new StringBuilder();
ticketService.getTicketData().getOpenTicketsChannelIdsBySupporter(member.getId()).forEach(id -> stringBuilder.append("- <#").append(id).append(">\n"));

event.replyEmbeds(new EmbedBuilder()
.setColor(Color.decode(config.getColor()))
.setTitle("Your claimed tickets")
.setDescription(stringBuilder.isEmpty() ? "You don't have any open tickets." : stringBuilder.toString())
.setAuthor(member.getEffectiveName(), null, member.getEffectiveAvatarUrl())
.setFooter(config.getServerName(), config.getServerLogo())
.build()).setEphemeral(true).queue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ public Map<String, Integer> countClosedTicketsPerSupporterAllTime() {
}));
}

public List<String> getOpenTicketsChannelIdsBySupporter(String supporterId) {
return jdbi.withHandle(handle -> handle.createQuery(
"SELECT channelID FROM tickets WHERE isOpen = true AND supporter = ? ORDER BY ticketID ASC")
.bind(0, supporterId)
.mapTo(String.class)
.list()
);
}

/**
* Marks a stale ticket as closed in the database.
* Used when the ticket's Discord channel no longer exists.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/eu/greev/dcbot/utils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Config {
private long unclaimedCategory;
private long baseChannel;
private long logChannel = 0;
private long supporterReminderChannel = 0;
private long ratingStatsChannel = 0;
private long specialStatsChannel = 0;
private boolean devMode = false;
Expand Down