forked from Fascinated/Bat
edit user feed messages
This commit is contained in:
parent
4c9e45f06b
commit
0eb28e4dbc
@ -6,10 +6,12 @@ import cc.fascinated.bat.service.CommandService;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fascinated (fascinated7)
|
* @author Fascinated (fascinated7)
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class AutoRoleFeature extends Feature {
|
public class AutoRoleFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
|
@ -16,7 +16,8 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author Fascinated (fascinated7)
|
* @author Fascinated (fascinated7)
|
||||||
*/
|
*/
|
||||||
@Component @Log4j2
|
@Component
|
||||||
|
@Log4j2
|
||||||
public class AutoRoleListener implements EventListener {
|
public class AutoRoleListener implements EventListener {
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) {
|
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.features.autorole.profile.AutoRoleProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.DiscordService;
|
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -36,12 +36,12 @@ public class ChannelSubCommand extends BatSubCommand {
|
|||||||
if (option == null) {
|
if (option == null) {
|
||||||
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
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();
|
.build()).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
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();
|
.build()).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public class ChannelSubCommand extends BatSubCommand {
|
|||||||
guildService.saveGuild(guild);
|
guildService.saveGuild(guild);
|
||||||
|
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
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();
|
.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -42,12 +41,10 @@ public class CommandService extends ListenerAdapter {
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService, @NonNull ApplicationContext context) {
|
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) {
|
||||||
this.guildService = guildService;
|
this.guildService = guildService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
DiscordService.JDA.addEventListener(this);
|
DiscordService.JDA.addEventListener(this);
|
||||||
|
|
||||||
context.getBeansOfType(BatCommand.class).values().forEach(this::registerCommand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cc.fascinated.bat.service;
|
package cc.fascinated.bat.service;
|
||||||
|
|
||||||
|
import cc.fascinated.bat.command.BatCommand;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -31,6 +32,12 @@ public class FeatureService {
|
|||||||
features.add(context.getBean(feature.getClass()));
|
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
|
commandService.registerSlashCommands(); // Register all slash commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user