Skip to content

Commit

Permalink
Added AwardingEXPReactionEnabled and AwardingEXPReactPostEnabled to c…
Browse files Browse the repository at this point in the history
…ontrol if reactions award EXP
  • Loading branch information
MythicalCuddles committed Jan 18, 2020
1 parent ddc075d commit 68e0ec5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 131 deletions.
11 changes: 8 additions & 3 deletions DiscordBot/Common/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
137 changes: 9 additions & 128 deletions DiscordBot/Handlers/ReactionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,140 +20,21 @@ public static async Task ReactionAdded(Cacheable<IUserMessage, ulong> 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<IUserMessage, ulong> 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<string> 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<IUserMessage, ulong> 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<string> 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);
// }
// }
}
}

0 comments on commit 68e0ec5

Please sign in to comment.