Skip to content

Commit

Permalink
Added check to ensure experience and overrides are not null
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Mar 4, 2024
1 parent 8bc3dc5 commit fd4e9ca
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions backend/Levels/Models/GuildLevelConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,6 @@ public class GuildLevelConfig

public GuildLevelConfig()
{
Experience = new ExperienceConfig()
{
MaximumTextXpGiven = 15,
MaximumVoiceXpGiven = 15,
MinimumTextXpGiven = 25,
MinimumVoiceXpGiven = 10
};

Coefficients = [0f, 75.83333f, 22.5f, 1.66667f];
XpInterval = 60;
LevelUpTemplate = "{USER} leveled up to level {LEVEL}!";

DisabledXpChannels = [];

HandleRoles = false;
SendVoiceLevelUps = true;
SendTextLevelUps = true;
VoiceXpCountMutedMembers = true;
VoiceXpRequiredMembers = 3;

Levels = [];
LevelUpMessageOverrides = [];
ExperienceOverrides = [];
}

public GuildLevelConfig(ulong guildId) {
Expand Down Expand Up @@ -88,6 +65,18 @@ public GuildLevelConfig(ulong guildId) {
ExperienceOverrides = [];
}

public ExperienceConfig GetExperienceConfig(IChannel channel) =>
ExperienceOverrides.TryGetValue(channel.Id, out var channelOverride) ? channelOverride : Experience;
public ExperienceConfig GetExperienceConfig(IChannel channel)
{
Experience ??= new ExperienceConfig()
{
MaximumTextXpGiven = 0,
MaximumVoiceXpGiven = 0,
MinimumTextXpGiven = 0,
MinimumVoiceXpGiven = 0
};

ExperienceOverrides ??= [];

return ExperienceOverrides.TryGetValue(channel.Id, out var channelOverride) ? channelOverride : Experience;
}
}

0 comments on commit fd4e9ca

Please sign in to comment.