oops! actually save the AFK status
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 45s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 45s
This commit is contained in:
parent
e05e08c291
commit
f0cc859585
@ -4,8 +4,10 @@ import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.GuildService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -13,6 +15,13 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class AfkReturnListener implements EventListener {
|
||||
private final GuildService guildService;
|
||||
|
||||
@Autowired
|
||||
public AfkReturnListener(@NonNull GuildService guildService) {
|
||||
this.guildService = guildService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildMessageReceive(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull MessageReceivedEvent event) {
|
||||
AfkProfile profile = guild.getProfile(AfkProfile.class);
|
||||
@ -20,6 +29,7 @@ public class AfkReturnListener implements EventListener {
|
||||
return;
|
||||
}
|
||||
profile.removeAfkUser(guild, user.getId());
|
||||
guildService.saveGuild(guild);
|
||||
event.getMessage().reply("Welcome back, %s! You are no longer AFK.".formatted(user.getDiscordUser().getAsMention())).queue();
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import cc.fascinated.bat.common.MemberUtils;
|
||||
import cc.fascinated.bat.features.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.GuildService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -20,7 +22,11 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@CommandInfo(name = "afk", description = "Sets your AFK status")
|
||||
public class AfkCommand extends BatCommand {
|
||||
public AfkCommand() {
|
||||
private final GuildService guildService;
|
||||
|
||||
@Autowired
|
||||
public AfkCommand(@NonNull GuildService guildService) {
|
||||
this.guildService = guildService;
|
||||
super.addOption(OptionType.STRING, "reason", "The reason for being AFK", false);
|
||||
}
|
||||
|
||||
@ -34,6 +40,7 @@ public class AfkCommand extends BatCommand {
|
||||
}
|
||||
|
||||
profile.addAfkUser(guild, member.getId(), reason);
|
||||
guildService.saveGuild(guild);
|
||||
interaction.reply("You are now AFK: %s%s".formatted(
|
||||
profile.getAfkReason(member.getId()),
|
||||
MemberUtils.hasPermissionToEdit(guild, user) ? "" :
|
||||
|
Loading…
Reference in New Issue
Block a user