Skip to content

Commit

Permalink
Add medals command to show users their current trade progress achieve…
Browse files Browse the repository at this point in the history
…ments.
  • Loading branch information
bdawg1989 committed Nov 16, 2024
1 parent a90db7c commit 7215d9b
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions SysBot.Pokemon.Discord/Commands/Bots/TradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,4 +1697,74 @@ private async Task DeleteMessagesAfterDelayAsync(IMessage? sentMessage, IMessage
LogUtil.LogSafe(ex, nameof(TradeModule<T>));
}
}

[Command("medals")]
[Alias("ml")]
[Summary("Shows your current trade count and medal status")]
public async Task ShowMedalsCommand()
{
var tradeCodeStorage = new TradeCodeStorage();
int totalTrades = tradeCodeStorage.GetTradeCount(Context.User.Id);

if (totalTrades == 0)
{
await ReplyAsync($"{Context.User.Username}, you haven't made any trades yet. Start trading to earn your first medal!");
return;
}

int currentMilestone = GetCurrentMilestone(totalTrades);

var embed = CreateMedalsEmbed(Context.User, currentMilestone, totalTrades);
await Context.Channel.SendMessageAsync(embed: embed).ConfigureAwait(false);
}

private static int GetCurrentMilestone(int totalTrades)
{
int[] milestones = { 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50, 1 };
return milestones.FirstOrDefault(m => totalTrades >= m, 0);
}

private static Embed CreateMedalsEmbed(SocketUser user, int milestone, int totalTrades)
{
string status = milestone switch
{
1 => "Newbie Trainer",
50 => "Novice Trainer",
100 => "Pokémon Professor",
150 => "Pokémon Specialist",
200 => "Pokémon Champion",
250 => "Pokémon Hero",
300 => "Pokémon Elite",
350 => "Pokémon Trader",
400 => "Pokémon Sage",
450 => "Pokémon Legend",
500 => "Region Master",
550 => "Trade Master",
600 => "World Famous",
650 => "Pokémon Master",
700 => "Pokémon God",
_ => "New Trainer"
};

string description = $"Total Trades: **{totalTrades}**\n**Current Status:** {status}";

if (milestone > 0)
{
string imageUrl = $"https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/{milestone:D3}.png";
return new EmbedBuilder()
.WithTitle($"{user.Username}'s Trading Status")
.WithColor(new Color(255, 215, 0)) // Gold
.WithDescription(description)
.WithThumbnailUrl(imageUrl)
.Build();
}
else
{
return new EmbedBuilder()
.WithTitle($"{user.Username}'s Trading Status")
.WithColor(new Color(255, 215, 0))
.WithDescription(description)
.Build();
}
}
}

0 comments on commit 7215d9b

Please sign in to comment.