add spotify feature

This commit is contained in:
Lee
2024-06-28 03:01:21 +01:00
parent 5c7a067f7a
commit fa10cf2019
70 changed files with 966 additions and 170 deletions

View File

@ -7,6 +7,8 @@ import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
@ -22,16 +24,16 @@ import java.util.Set;
/**
* @author Fascinated (fascinated7)
*/
@Service @Log4j2
@Service
@Log4j2
@DependsOn("discordService")
public class EventService extends ListenerAdapter {
private final GuildService guildService;
private final UserService userService;
/**
* The list of listeners registered
*/
public static final Set<EventListener> LISTENERS = new HashSet<>();
private final GuildService guildService;
private final UserService userService;
@Autowired
public EventService(@NonNull GuildService guildService, @NonNull UserService userService, @NonNull ApplicationContext context) {
@ -103,4 +105,30 @@ public class EventService extends ListenerAdapter {
listener.onStringSelectInteraction(guild, user, event);
}
}
@Override
public void onButtonInteraction(ButtonInteractionEvent event) {
if (event.getUser().isBot()) {
return;
}
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
BatUser user = userService.getUser(event.getUser().getId());
for (EventListener listener : LISTENERS) {
listener.onButtonInteraction(guild, user, event);
}
}
@Override
public void onModalInteraction(ModalInteractionEvent event) {
if (event.getUser().isBot()) {
return;
}
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
BatUser user = userService.getUser(event.getUser().getId());
for (EventListener listener : LISTENERS) {
listener.onModalInteraction(guild, user, event);
}
}
}