forked from Fascinated/Bat
default disable all features and add bot join guild message
This commit is contained in:
parent
4e866895a0
commit
0b09b8ba5f
@ -128,4 +128,19 @@ public abstract class BatCommand {
|
|||||||
protected final void addOptions(OptionData... options) {
|
protected final void addOptions(OptionData... options) {
|
||||||
commandData.addOptions(options);
|
commandData.addOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sub command by its class.
|
||||||
|
*
|
||||||
|
* @param clazz the class of the sub command
|
||||||
|
* @return the sub command
|
||||||
|
*/
|
||||||
|
public BatCommand getSubCommand(Class<? extends BatCommand> clazz) {
|
||||||
|
for (Map.Entry<String, BatCommand> entry : subCommands.entrySet()) {
|
||||||
|
if (entry.getValue().getClass().equals(clazz)) {
|
||||||
|
return entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,6 +19,11 @@ public abstract class Feature {
|
|||||||
*/
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default state of the feature
|
||||||
|
*/
|
||||||
|
private final FeatureProfile.FeatureState defaultState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of the feature
|
* The description of the feature
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cc.fascinated.bat.features.base.profile;
|
package cc.fascinated.bat.features;
|
||||||
|
|
||||||
import cc.fascinated.bat.common.Serializable;
|
import cc.fascinated.bat.common.Serializable;
|
||||||
import cc.fascinated.bat.features.Feature;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -16,8 +15,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class FeatureProfile extends Serializable {
|
public class FeatureProfile extends Serializable {
|
||||||
private static final FeatureState DEFAULT_STATE = FeatureState.ENABLED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The feature states
|
* The feature states
|
||||||
*/
|
*/
|
||||||
@ -30,11 +27,11 @@ public class FeatureProfile extends Serializable {
|
|||||||
*/
|
*/
|
||||||
public FeatureState getFeatureState(Feature feature) {
|
public FeatureState getFeatureState(Feature feature) {
|
||||||
if (feature == null) {
|
if (feature == null) {
|
||||||
return DEFAULT_STATE;
|
return FeatureProfile.FeatureState.DISABLED;
|
||||||
}
|
}
|
||||||
String featureName = feature.getName().toUpperCase();
|
String featureName = feature.getName().toUpperCase();
|
||||||
if (!this.featureStates.containsKey(featureName)) {
|
if (!this.featureStates.containsKey(featureName)) {
|
||||||
this.featureStates.put(featureName, DEFAULT_STATE);
|
this.featureStates.put(featureName, feature.getDefaultState());
|
||||||
}
|
}
|
||||||
return this.featureStates.get(featureName);
|
return this.featureStates.get(featureName);
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.afk;
|
package cc.fascinated.bat.features.afk;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.afk.command.AfkCommand;
|
import cc.fascinated.bat.features.afk.command.AfkCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -13,7 +14,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class AfkFeature extends Feature {
|
public class AfkFeature extends Feature {
|
||||||
public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("AFK", true);
|
super("AFK", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
registerCommand(commandService, context.getBean(AfkCommand.class));
|
registerCommand(commandService, context.getBean(AfkCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.autorole;
|
package cc.fascinated.bat.features.autorole;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.autorole.command.AutoRoleCommand;
|
import cc.fascinated.bat.features.autorole.command.AutoRoleCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.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) {
|
||||||
super("Auto Role",true);
|
super("Auto Role", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
registerCommand(commandService, context.getBean(AutoRoleCommand.class));
|
registerCommand(commandService, context.getBean(AutoRoleCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.base;
|
package cc.fascinated.bat.features.base;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand;
|
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand;
|
||||||
import cc.fascinated.bat.features.base.commands.fun.EightBallCommand;
|
import cc.fascinated.bat.features.base.commands.fun.EightBallCommand;
|
||||||
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
|
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
|
||||||
@ -24,7 +25,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class BaseFeature extends Feature {
|
public class BaseFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Base", false);
|
super("Base", FeatureProfile.FeatureState.DISABLED, false);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(PremiumCommand.class));
|
super.registerCommand(commandService, context.getBean(PremiumCommand.class));
|
||||||
super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class));
|
super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class));
|
||||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatCommand;
|
|||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
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.FeatureService;
|
import cc.fascinated.bat.service.FeatureService;
|
||||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatCommand;
|
|||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
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.FeatureService;
|
import cc.fascinated.bat.service.FeatureService;
|
||||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatCommand;
|
|||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
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.FeatureService;
|
import cc.fascinated.bat.service.FeatureService;
|
||||||
|
@ -2,6 +2,7 @@ package cc.fascinated.bat.features.birthday;
|
|||||||
|
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.birthday.command.BirthdayCommand;
|
import cc.fascinated.bat.features.birthday.command.BirthdayCommand;
|
||||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
@ -22,7 +23,7 @@ public class BirthdayFeature extends Feature implements EventListener {
|
|||||||
private final GuildService guildService;
|
private final GuildService guildService;
|
||||||
|
|
||||||
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
||||||
super("Birthday", true);
|
super("Birthday", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
this.guildService = guildService;
|
this.guildService = guildService;
|
||||||
|
|
||||||
registerCommand(commandService, context.getBean(BirthdayCommand.class));
|
registerCommand(commandService, context.getBean(BirthdayCommand.class));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.counter;
|
package cc.fascinated.bat.features.counter;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.counter.command.CounterCommand;
|
import cc.fascinated.bat.features.counter.command.CounterCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class CounterFeature extends Feature {
|
public class CounterFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public CounterFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public CounterFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Counter", true);
|
super("Counter", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(CounterCommand.class));
|
super.registerCommand(commandService, context.getBean(CounterCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.counter;
|
package cc.fascinated.bat.features.counter;
|
||||||
|
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
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 lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.drag;
|
package cc.fascinated.bat.features.drag;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.drag.command.DragCommand;
|
import cc.fascinated.bat.features.drag.command.DragCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class DragFeature extends Feature {
|
public class DragFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public DragFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public DragFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Drag", true);
|
super("Drag", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(DragCommand.class));
|
super.registerCommand(commandService, context.getBean(DragCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package cc.fascinated.bat.features.logging;
|
|||||||
|
|
||||||
import cc.fascinated.bat.common.PasteUtils;
|
import cc.fascinated.bat.common.PasteUtils;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.logging.command.LogsCommand;
|
import cc.fascinated.bat.features.logging.command.LogsCommand;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class LogFeature extends Feature {
|
public class LogFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public LogFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public LogFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Logging", true);
|
super("Logging", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(LogsCommand.class));
|
super.registerCommand(commandService, context.getBean(LogsCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cc.fascinated.bat.features.messagesnipe;
|
|||||||
|
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.messagesnipe.command.MessageSnipeCommand;
|
import cc.fascinated.bat.features.messagesnipe.command.MessageSnipeCommand;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -29,7 +30,7 @@ public class MessageSnipeFeature extends Feature implements EventListener {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Message Snipe", false);
|
super("Message Snipe", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(MessageSnipeCommand.class));
|
super.registerCommand(commandService, context.getBean(MessageSnipeCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.moderation;
|
package cc.fascinated.bat.features.moderation;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.moderation.command.PurgeCommand;
|
import cc.fascinated.bat.features.moderation.command.PurgeCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class ModerationFeature extends Feature {
|
public class ModerationFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public ModerationFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public ModerationFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Moderation", true);
|
super("Moderation", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(PurgeCommand.class));
|
super.registerCommand(commandService, context.getBean(PurgeCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.namehistory;
|
package cc.fascinated.bat.features.namehistory;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.namehistory.command.NameHistoryCommand;
|
import cc.fascinated.bat.features.namehistory.command.NameHistoryCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -17,7 +18,7 @@ public class NameHistoryFeature extends Feature {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Name History", true);
|
super("Name History", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(NameHistoryCommand.class));
|
super.registerCommand(commandService, context.getBean(NameHistoryCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.reminder;
|
package cc.fascinated.bat.features.reminder;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.reminder.command.ReminderCommand;
|
import cc.fascinated.bat.features.reminder.command.ReminderCommand;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
@ -36,7 +37,7 @@ public class ReminderFeature extends Feature {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReminderFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
public ReminderFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
||||||
super("Reminder", true);
|
super("Reminder", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
this.guildService = guildService;
|
this.guildService = guildService;
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(ReminderCommand.class));
|
super.registerCommand(commandService, context.getBean(ReminderCommand.class));
|
||||||
|
@ -5,6 +5,7 @@ import cc.fascinated.bat.common.EmbedUtils;
|
|||||||
import cc.fascinated.bat.common.NumberFormatter;
|
import cc.fascinated.bat.common.NumberFormatter;
|
||||||
import cc.fascinated.bat.common.ScoreSaberUtils;
|
import cc.fascinated.bat.common.ScoreSaberUtils;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
|
import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
|
||||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
|
import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
|
||||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
|
import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
|
||||||
@ -25,7 +26,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class ScoreSaberFeature extends Feature {
|
public class ScoreSaberFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("ScoreSaber", true);
|
super("ScoreSaber", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
registerCommand(commandService, context.getBean(ScoreSaberCommand.class));
|
registerCommand(commandService, context.getBean(ScoreSaberCommand.class));
|
||||||
registerCommand(commandService, context.getBean(UserFeedCommand.class));
|
registerCommand(commandService, context.getBean(UserFeedCommand.class));
|
||||||
|
@ -5,6 +5,7 @@ import cc.fascinated.bat.common.EmbedUtils;
|
|||||||
import cc.fascinated.bat.common.SpotifyUtils;
|
import cc.fascinated.bat.common.SpotifyUtils;
|
||||||
import cc.fascinated.bat.exception.BatException;
|
import cc.fascinated.bat.exception.BatException;
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.spotify.command.SpotifyCommand;
|
import cc.fascinated.bat.features.spotify.command.SpotifyCommand;
|
||||||
import cc.fascinated.bat.features.spotify.profile.SpotifyProfile;
|
import cc.fascinated.bat.features.spotify.profile.SpotifyProfile;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -28,7 +29,7 @@ import se.michaelthelin.spotify.model_objects.specification.Track;
|
|||||||
public class SpotifyFeature extends Feature {
|
public class SpotifyFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public SpotifyFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public SpotifyFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Spotify", true);
|
super("Spotify", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(SpotifyCommand.class));
|
super.registerCommand(commandService, context.getBean(SpotifyCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.welcomer;
|
package cc.fascinated.bat.features.welcomer;
|
||||||
|
|
||||||
import cc.fascinated.bat.features.Feature;
|
import cc.fascinated.bat.features.Feature;
|
||||||
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.welcomer.command.WelcomerCommand;
|
import cc.fascinated.bat.features.welcomer.command.WelcomerCommand;
|
||||||
import cc.fascinated.bat.service.CommandService;
|
import cc.fascinated.bat.service.CommandService;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class WelcomerFeature extends Feature {
|
public class WelcomerFeature extends Feature {
|
||||||
@Autowired
|
@Autowired
|
||||||
public WelcomerFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
public WelcomerFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||||
super("Welcomer", true);
|
super("Welcomer", FeatureProfile.FeatureState.DISABLED, true);
|
||||||
|
|
||||||
super.registerCommand(commandService, context.getBean(WelcomerCommand.class));
|
super.registerCommand(commandService, context.getBean(WelcomerCommand.class));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package cc.fascinated.bat.model;
|
|||||||
import cc.fascinated.bat.BatApplication;
|
import cc.fascinated.bat.BatApplication;
|
||||||
import cc.fascinated.bat.common.ProfileHolder;
|
import cc.fascinated.bat.common.ProfileHolder;
|
||||||
import cc.fascinated.bat.common.Serializable;
|
import cc.fascinated.bat.common.Serializable;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||||
import cc.fascinated.bat.features.counter.CounterProfile;
|
import cc.fascinated.bat.features.counter.CounterProfile;
|
||||||
import cc.fascinated.bat.features.logging.LogProfile;
|
import cc.fascinated.bat.features.logging.LogProfile;
|
||||||
|
@ -5,7 +5,7 @@ import cc.fascinated.bat.command.BatCommand;
|
|||||||
import cc.fascinated.bat.command.Category;
|
import cc.fascinated.bat.command.Category;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.config.Config;
|
import cc.fascinated.bat.config.Config;
|
||||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
import cc.fascinated.bat.features.FeatureProfile;
|
||||||
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 lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -36,6 +36,8 @@ import java.util.stream.Collectors;
|
|||||||
@Getter
|
@Getter
|
||||||
@DependsOn("discordService")
|
@DependsOn("discordService")
|
||||||
public class CommandService extends ListenerAdapter {
|
public class CommandService extends ListenerAdapter {
|
||||||
|
public static CommandService INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The registered commands
|
* The registered commands
|
||||||
*/
|
*/
|
||||||
@ -53,6 +55,7 @@ public class CommandService extends ListenerAdapter {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) {
|
public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) {
|
||||||
|
INSTANCE = this;
|
||||||
this.guildService = guildService;
|
this.guildService = guildService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
DiscordService.JDA.addEventListener(this);
|
DiscordService.JDA.addEventListener(this);
|
||||||
@ -137,6 +140,21 @@ public class CommandService extends ListenerAdapter {
|
|||||||
return commands.values().stream().filter(command -> command.getInfo().getCategory() == category).toList();
|
return commands.values().stream().filter(command -> command.getInfo().getCategory() == category).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a command by its class
|
||||||
|
*
|
||||||
|
* @param clazz The class of the command
|
||||||
|
* @return The command
|
||||||
|
*/
|
||||||
|
public BatCommand getCommand(Class<? extends BatCommand> clazz) {
|
||||||
|
for (Map.Entry<String, BatCommand> entry : this.commands.entrySet()) {
|
||||||
|
if (entry.getValue().getClass().equals(clazz)) {
|
||||||
|
return entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||||
if (event.getUser().isBot()) {
|
if (event.getUser().isBot()) {
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package cc.fascinated.bat.service;
|
package cc.fascinated.bat.service;
|
||||||
|
|
||||||
|
import cc.fascinated.bat.command.BatCommand;
|
||||||
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.common.TimerUtils;
|
import cc.fascinated.bat.common.TimerUtils;
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
|
import cc.fascinated.bat.features.base.commands.general.HelpCommand;
|
||||||
|
import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand;
|
||||||
|
import cc.fascinated.bat.features.base.commands.server.feature.ListSubCommand;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.premium.PremiumProfile;
|
import cc.fascinated.bat.premium.PremiumProfile;
|
||||||
import com.mongodb.client.model.Filters;
|
import com.mongodb.client.model.Filters;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.unions.DefaultGuildChannelUnion;
|
||||||
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
|
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
@ -103,6 +110,29 @@ public class GuildService extends ListenerAdapter implements EventListener {
|
|||||||
public final void onGuildJoin(GuildJoinEvent event) {
|
public final void onGuildJoin(GuildJoinEvent event) {
|
||||||
BatGuild guild = getGuild(event.getGuild().getId());
|
BatGuild guild = getGuild(event.getGuild().getId());
|
||||||
log.info("Joined guild \"{}\"", guild.getName());
|
log.info("Joined guild \"{}\"", guild.getName());
|
||||||
|
|
||||||
|
// Send a welcome message to the guild
|
||||||
|
DefaultGuildChannelUnion defaultChannel = event.getGuild().getDefaultChannel();
|
||||||
|
if (defaultChannel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TextChannel channel = defaultChannel.asTextChannel();
|
||||||
|
BatCommand featureCommand = CommandService.INSTANCE.getCommand(FeatureCommand.class);
|
||||||
|
BatCommand listSubCommand = featureCommand.getSubCommand(ListSubCommand.class);
|
||||||
|
channel.sendMessageEmbeds(EmbedUtils.genericEmbed()
|
||||||
|
.setDescription("""
|
||||||
|
Hello! I'm %s, thank you for inviting me to your server!
|
||||||
|
To get started, use the </%s> command to see all the commands I have to offer!
|
||||||
|
|
||||||
|
Most of my features are disabled by default, view my features with </%s %s:%s>
|
||||||
|
""".formatted(
|
||||||
|
DiscordService.JDA.getSelfUser().getAsMention(),
|
||||||
|
CommandService.INSTANCE.getCommand(HelpCommand.class).getSnowflake(),
|
||||||
|
featureCommand.getSnowflake(),
|
||||||
|
listSubCommand.getInfo().getName(),
|
||||||
|
listSubCommand.getSnowflake()
|
||||||
|
))
|
||||||
|
.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user