edit user feed messages
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 45s

This commit is contained in:
Lee 2024-06-25 17:20:19 +01:00
parent 4c9e45f06b
commit 0eb28e4dbc
7 changed files with 16 additions and 10 deletions

@ -6,10 +6,12 @@ import cc.fascinated.bat.service.CommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
@Component
public class AutoRoleFeature extends Feature {
@Autowired
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {

@ -16,7 +16,8 @@ import java.util.List;
/**
* @author Fascinated (fascinated7)
*/
@Component @Log4j2
@Component
@Log4j2
public class AutoRoleListener implements EventListener {
@Override
public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) {

@ -6,7 +6,6 @@ import cc.fascinated.bat.common.RoleUtils;
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.DiscordService;
import cc.fascinated.bat.service.GuildService;
import lombok.NonNull;
import net.dv8tion.jda.api.entities.Member;

@ -30,7 +30,7 @@ public class NumberOneFeedCommand extends BatCommand {
.addOptions(new OptionData(OptionType.CHANNEL, "channel", "The channel scores are sent in", false))
).setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
.addSubcommands(new SubcommandData("reset", "Resets the feed settings to default"))
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
);
}
}

@ -36,12 +36,12 @@ public class ChannelSubCommand extends BatSubCommand {
if (option == null) {
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Please provide a channel to set the ScoreSaber feed channel to")
.setDescription("Please provide a channel to set the feed channel to")
.build()).queue();
return;
}
interaction.replyEmbeds(EmbedUtils.genericEmbed()
.setDescription("The current ScoreSaber feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId())))
.setDescription("The current feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId())))
.build()).queue();
return;
}
@ -58,7 +58,7 @@ public class ChannelSubCommand extends BatSubCommand {
guildService.saveGuild(guild);
interaction.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("Successfully set the ScoreSaber feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention()))
.setDescription("Successfully set the feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention()))
.build()).queue();
}
}

@ -13,7 +13,6 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service;
@ -42,12 +41,10 @@ public class CommandService extends ListenerAdapter {
private final UserService userService;
@Autowired
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService, @NonNull ApplicationContext context) {
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) {
this.guildService = guildService;
this.userService = userService;
DiscordService.JDA.addEventListener(this);
context.getBeansOfType(BatCommand.class).values().forEach(this::registerCommand);
}
/**

@ -1,5 +1,6 @@
package cc.fascinated.bat.service;
import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.features.Feature;
import lombok.Getter;
import lombok.NonNull;
@ -31,6 +32,12 @@ public class FeatureService {
features.add(context.getBean(feature.getClass()));
});
context.getBeansOfType(BatCommand.class)
.values()
.forEach((command) -> {
commandService.registerCommand(context.getBean(command.getClass()));
});
commandService.registerSlashCommands(); // Register all slash commands
}
}