Skip to content

Commit

Permalink
Merge pull request #3 from MythicalCuddles/3.0.0.0-exp-changes
Browse files Browse the repository at this point in the history
Changing EXP Message to have a toggle-able mention
  • Loading branch information
MythicalCuddles authored Feb 17, 2019
2 parents db02c0f + bce0ba1 commit 7e29e1f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 3 additions & 1 deletion DiscordBot/Common/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class Configuration

public bool UnknownCommandEnabled { get; set; } = true;
public bool AwardingEXPEnabled { get; set; } = true;
public bool AwardingEXPMentionUser { get; set; } = true;

public int LeaderboardAmount { get; set; } = 5;
public int QuoteLevelRequirement { get; set; } = 10;
Expand Down Expand Up @@ -118,7 +119,7 @@ public string ToJson()
public static void UpdateConfiguration(string botToken = null, ulong? developer = null, string statusText = null, string statusLink = null,
string databaseHost = null, int? databasePort = null, string databaseUser = null, string databasePassword = null, string databaseName = null,
bool? showAllAwards = null, string awardsIconUrl = null,
int? statusActivity = null, UserStatus? status = null, bool? unknownCommandEnabled = null, bool? awardingEXPEnabled = null,
int? statusActivity = null, UserStatus? status = null, bool? unknownCommandEnabled = null, bool? awardingEXPEnabled = null, bool? awardingEXPMentionUser = null,
int? leaderboardAmount = null, string leaderboardTrophyUrl = null, uint? leaderboardEmbedColor = null,
int? quoteLevelRequirement = null, int? prefixLevelRequirement = null, int? senpaiChanceRate = null, int? rgbLevelRequirement = null,
ulong? logChannelId = null, int? respects = null, int? minLengthForEXP = null, int? maxRuleXGamble = null)
Expand All @@ -144,6 +145,7 @@ public static void UpdateConfiguration(string botToken = null, ulong? developer

UnknownCommandEnabled = unknownCommandEnabled ?? Load().UnknownCommandEnabled,
AwardingEXPEnabled = awardingEXPEnabled ?? Load().AwardingEXPEnabled,
AwardingEXPMentionUser = awardingEXPMentionUser ?? Load().AwardingEXPMentionUser,

LeaderboardAmount = leaderboardAmount ?? Load().LeaderboardAmount,
LeaderboardTrophyUrl = leaderboardTrophyUrl ?? Load().LeaderboardTrophyUrl,
Expand Down
18 changes: 16 additions & 2 deletions DiscordBot/Extensions/UserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,23 @@ public static async void AttemptLevelUp(this IUser user, SocketGuild guild)
EmbedBuilder eb = new EmbedBuilder()
{
Title = "Level Up!",
Color = user.GetCustomRGB(),
Description = "Well done " + user.Mention + "! You levelled up to level " + user.GetLevel() + "! Gain " + (Math.Round(EXPToLevelUp(user)) - user.GetEXP()) + " more EXP to level up again!",
Color = user.GetCustomRGB()
}.WithCurrentTimestamp();

if (Configuration.Load().AwardingEXPMentionUser)
{
eb.WithDescription("Well done " + user.Mention + "! You levelled up to level " +
user.GetLevel() + "! Gain " +
(Math.Round(EXPToLevelUp(user)) - user.GetEXP()) +
" more EXP to level up again!");
}
else
{
eb.WithDescription("Well done " + user.Username + "! You levelled up to level " +
user.GetLevel() + "! Gain " +
(Math.Round(EXPToLevelUp(user)) - user.GetEXP()) +
" more EXP to level up again!");
}

var msg = await botChannel.SendMessageAsync("", false, eb.Build());
//msg.DeleteAfter(300); // todo: updated from 120 to don't delete, maybe make configurable?
Expand Down
8 changes: 8 additions & 0 deletions DiscordBot/Modules/Owner/ConfigModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ await ReplyAsync("**Syntax:** " +
"[14] toggleexpawarding\n" +
"[15] toggleshowallawards\n" +
"[16] awardsiconurl [link]\n" +
"[17] toggleawardingexpmention\n" +
"```");
}

Expand Down Expand Up @@ -224,6 +225,13 @@ public async Task SetAwardsIconUrl(string link)
Configuration.UpdateConfiguration(awardsIconUrl: link);
await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync(Context.User.Mention + " has updated the Awards Icon URL to: " + link + " (was: " + oldValue + ")");
}

[Command("toggleawardingexpmention"), Summary("Toggles if users get mentioned when they level up.")]
public async Task ToggleAwardingEXPMention()
{
Configuration.UpdateConfiguration(awardingEXPMentionUser: !Configuration.Load().AwardingEXPMentionUser);
await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("AwardingEXPMentionUser has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().AwardingEXPMentionUser.ToYesNo() + ")");
}
}

[Group("editdatabase")]
Expand Down

0 comments on commit 7e29e1f

Please sign in to comment.