Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing EXP Message to have a toggle-able mention #3

Merged
merged 4 commits into from
Feb 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -126,9 +126,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