diff --git a/DiscordBot/Common/Configuration.cs b/DiscordBot/Common/Configuration.cs index 6bb16d7..28adb51 100644 --- a/DiscordBot/Common/Configuration.cs +++ b/DiscordBot/Common/Configuration.cs @@ -36,8 +36,10 @@ public class Configuration public string AwardsIconUrl { get; set; } = "https://i.imgur.com/Fancl1L.png"; public bool UnknownCommandEnabled { get; set; } = true; - public bool AwardingEXPEnabled { get; set; } = true; - public bool AwardingEXPMentionUser { get; set; } = true; + public bool AwardingEXPEnabled { get; set; } = true; // If the EXP System is enabled + public bool AwardingEXPReactionEnabled { get; set; } = false; // If the user should gain EXP when they react to a message + public bool AwardingEXPReactPostEnabled { get; set; } = false; // If the user should gain EXP when they have a message reacted to + public bool AwardingEXPMentionUser { get; set; } = true; // If the user should be mentioned when they level up public int LeaderboardAmount { get; set; } = 5; public int QuoteLevelRequirement { get; set; } = 10; @@ -95,7 +97,8 @@ private string ToJson() internal static void UpdateConfiguration(string botToken = null, ulong? developer = null, string activityName = null, int? activityType = null, string activityStream = null, bool? firstTimeRun = null, string databaseHost = null, int? databasePort = null, string databaseUser = null, string databasePassword = null, string databaseName = null, bool? showAllAwards = null, string awardsIconUrl = null, - UserStatus? status = null, bool? unknownCommandEnabled = null, bool? awardingEXPEnabled = null, bool? awardingEXPMentionUser = null, + UserStatus? status = null, bool? unknownCommandEnabled = null, + bool? awardingEXPEnabled = null, bool? awardingEXPReactionEnabled = null, bool? awardingEXPReactPostEnabled = 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) @@ -123,6 +126,8 @@ internal static void UpdateConfiguration(string botToken = null, ulong? develope UnknownCommandEnabled = unknownCommandEnabled ?? Load().UnknownCommandEnabled, AwardingEXPEnabled = awardingEXPEnabled ?? Load().AwardingEXPEnabled, + AwardingEXPReactionEnabled = awardingEXPReactionEnabled ?? Load().AwardingEXPReactionEnabled, + AwardingEXPReactPostEnabled = awardingEXPReactPostEnabled ?? Load().AwardingEXPReactPostEnabled, AwardingEXPMentionUser = awardingEXPMentionUser ?? Load().AwardingEXPMentionUser, LeaderboardAmount = leaderboardAmount ?? Load().LeaderboardAmount, diff --git a/DiscordBot/Handlers/ReactionHandler.cs b/DiscordBot/Handlers/ReactionHandler.cs index 44bbcb6..1e6e586 100644 --- a/DiscordBot/Handlers/ReactionHandler.cs +++ b/DiscordBot/Handlers/ReactionHandler.cs @@ -20,140 +20,21 @@ public static async Task ReactionAdded(Cacheable message, I return; } -// if (QuoteHandler.QuoteMessages.Contains(message.Id)) -// { -// await HandleQuoteReactions(message, reaction).ConfigureAwait(false); -// return; -// } -// -// if (QuoteHandler.RequestQuoteMessages.Contains(message.Id)) -// { -// await HandleRequestQuoteReactions(message, channel, reaction).ConfigureAwait(false); -// return; -// } - if(Configuration.Load().AwardingEXPEnabled) { - message.Value.Author.AwardEXPToUser(channel.GetGuild()); - reaction.User.Value.AwardEXPToUser(channel.GetGuild()); + if (Configuration.Load().AwardingEXPReactionEnabled) + { + reaction.User.Value.AwardEXPToUser(channel.GetGuild()); + } + + if (Configuration.Load().AwardingEXPReactPostEnabled) + { + message.Value.Author.AwardEXPToUser(channel.GetGuild()); + } } await new LogMessage(LogSeverity.Info, "ReactionAdded", "[" + channel.GetGuild() + "/#" + channel.Name + "] " + "[@ " + reaction.User.Value.Username + "] : " + reaction.Emote.Name).PrintToConsole(); } - -// private static async Task HandleQuoteReactions(Cacheable message, SocketReaction reaction) -// { -// if (reaction.User.Value.IsBot) -// { -// return; -// } -// -// // Check to see if the next page or previous page was clicked. -// if (reaction.Emote.Name == Extensions.Extensions.ArrowLeft.Name) -// { -// if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1) -// { -// return; -// } -// -// QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]--; -// } -// else if (reaction.Emote.Name == Extensions.Extensions.ArrowRight.Name) -// { -// if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength) -// { -// return; -// } -// -// QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]++; -// } -// -// StringBuilder sb = new StringBuilder() -// .Append("**Quote List** : *Page " + QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] + "*\n```"); -// -// List quotes = QuoteHandler.GetQuotes(QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]); -// -// for (int i = 0; i < quotes.Count; i++) -// { -// sb.Append(((i + 1) + ((QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] - 1) * 10)) + ": " + quotes[i] + "\n"); -// } -// -// sb.Append("```"); -// -// await message.Value.ModifyAsync(msg => msg.Content = sb.ToString()); -// await message.Value.RemoveAllReactionsAsync(); -// -// if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1) -// { -// await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); -// } -// else if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength) -// { -// await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); -// } -// else -// { -// await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); -// await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); -// } -// } - -// private static async Task HandleRequestQuoteReactions(Cacheable message, ISocketMessageChannel channel, SocketReaction reaction) - // { - // if (reaction.User.Value.IsBot) - // { - // return; - // } - // - // // Check to see if the next page or previous page was clicked. - // if (reaction.Emote.Name == Extensions.Extensions.ArrowLeft.Name) - // { - // if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == 1) - // { - // return; - // } - // - // QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]--; - // } - // else if (reaction.Emote.Name == Extensions.Extensions.ArrowRight.Name) - // { - // if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetRequestQuotesListLength) - // { - // return; - // } - // - // QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]++; - // } - // - // StringBuilder sb = new StringBuilder() - // .Append("**Request Quote List** : *Page " + QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] + "*\nTo accept a quote, type **" + Guild.Load(channel.GetGuild().Id).Prefix + "acceptquote[id]**.\nTo reject a quote, type **" + Guild.Load(channel.GetGuild().Id).Prefix + "denyquote[id]**.\n```"); - // - // List requestQuotes = QuoteHandler.GetRequestQuotes(QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]); - // - // for (int i = 0; i < requestQuotes.Count; i++) - // { - // sb.Append(((i + 1) + ((QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] - 1) * 10)) + ": " + requestQuotes[i] + "\n"); - // } - // - // sb.Append("```"); - // - // await message.Value.ModifyAsync(msg => msg.Content = sb.ToString()); - // await message.Value.RemoveAllReactionsAsync(); - // - // if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == 1) - // { - // await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); - // } - // else if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetRequestQuotesListLength) - // { - // await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); - // } - // else - // { - // await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); - // await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); - // } - // } } }