Skip to content

Commit

Permalink
Added awardinfo command to display information about an award
Browse files Browse the repository at this point in the history
  • Loading branch information
MythicalCuddles committed Jan 20, 2020
1 parent f1baaa5 commit 072187a
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions DiscordBot/Modules/AwardModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using DiscordBot.Common.Preconditions;
using DiscordBot.Exceptions;
using DiscordBot.Extensions;
using DiscordBot.Handlers;
using DiscordBot.Logging;
using DiscordBot.Objects;

Expand Down Expand Up @@ -298,5 +299,82 @@ public async Task DeleteUserAward(string id = null)
await ReplyAsync("", false, eb.Build());
}
}

[MinPermissions(PermissionLevel.ServerAdmin)]
[Command("awardinfo"), Summary("")]
public async Task GetAwardInfo(string id = null)
{
if (id == null)
{
EmbedBuilder eb = new EmbedBuilder
{
Title = "Invalid Syntax",
Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "awardinfo [id]",
Color = new Color(210, 47, 33)
}
.WithCurrentTimestamp();

await ReplyAsync("", false, eb.Build());
return;
}

if (int.TryParse(id, out var aId))
{
Award award;

try
{
award = Award.GetAward(aId);
}
catch (AwardNotFoundException exception)
{
await ReplyAsync(Context.User.Mention + ", I couldn't find an award with that ID. Please try again.");
await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
return;
}

AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

EmbedBuilder awardEmbed = new EmbedBuilder()
{
Title = "Award #" + award.AwardId,
Color = new Color(211, 214, 77)
}
.AddField("Award Category", award.AwardCategory)
.AddField("Award", award.AwardText)
.WithCurrentTimestamp();

try
{
awardEmbed.AddField("Awarded To", award.UserId.GetUser().Mention);
}
catch (UserNotFoundException exception)
{
awardEmbed.AddField("Awarded To", award.UserId.ToString());
await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
}

awardEmbed
.AddField("Date Awarded", award.DateAwarded.ToLongDateString());

await ReplyAsync("", false, awardEmbed.Build());
}
else
{
EmbedBuilder eb = new EmbedBuilder
{
Title = "Invalid Syntax",
Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "awardinfo [id]",
Color = new Color(210, 47, 33),
Footer = new EmbedFooterBuilder()
{
Text = "You can use the command listawards to find the ID's of the quotes."
}
}
.WithCurrentTimestamp();

await ReplyAsync("", false, eb.Build());
}
}
}
}

0 comments on commit 072187a

Please sign in to comment.