Skip to content

Commit

Permalink
user to guild setting
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed May 21, 2024
1 parent 30d8959 commit bff106e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import link.locutus.discord.commands.manager.v2.binding.Key;
import link.locutus.discord.db.GuildDB;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.Category;
import net.dv8tion.jda.api.entities.IMentionable;

Expand All @@ -11,7 +12,7 @@ public GuildCategorySetting(GuildSettingCategory category) {
}

@Override
public Category validate(GuildDB db, Category value) {
public Category validate(GuildDB db, User user, Category value) {
return validateCategory(db, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import link.locutus.discord.commands.manager.v2.binding.Key;
import link.locutus.discord.db.GuildDB;
import net.dv8tion.jda.api.entities.IMentionable;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;

public abstract class GuildChannelSetting extends GuildSetting<MessageChannel> {
Expand All @@ -11,7 +12,7 @@ public GuildChannelSetting(GuildSettingCategory category) {
}

@Override
public MessageChannel validate(GuildDB db, MessageChannel value) {
public MessageChannel validate(GuildDB db, User user, MessageChannel value) {
return validateChannel(db, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import link.locutus.discord.util.MathMan;
import link.locutus.discord.util.PW;
import link.locutus.discord.util.math.ArrayUtil;
import net.dv8tion.jda.api.entities.User;

import java.nio.charset.StandardCharsets;
import java.util.Map;
Expand All @@ -15,7 +16,7 @@ public GuildResourceSetting(GuildSettingCategory category) {
}

@Override
public Map<ResourceType, Double> validate(GuildDB db, Map<ResourceType, Double> value) {
public Map<ResourceType, Double> validate(GuildDB db, User user, Map<ResourceType, Double> value) {
// ensure amounts are positive
for (Map.Entry<ResourceType, Double> entry : value.entrySet()) {
if (entry.getValue() < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public T allowedAndValidate(GuildDB db, User user, T value) {

public String setAndValidate(GuildDB db, User user, T value) {
value = allowedAndValidate(db, user, value);
return set(db, value);
return set(db, user, value);
}

public GuildSetting<T> requiresAllies() {
Expand Down

0 comments on commit bff106e

Please sign in to comment.