public async Task PackagAccountsProfile(CommandContext ctx) { if (this.CheckBasics(ctx) == true) { PackageAccount account = this.accountService.FindAccount(ctx.User.Id); DiscordEmbedBuilder accountEmbed = new DiscordEmbedBuilder { Footer = new DiscordEmbedBuilder.EmbedFooter { IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, CommandEmojis.Run).Url, Text = $"Package Account Profile | Account Created: {account.AccountCreated}", }, Color = new DiscordColor(52, 114, 53), Timestamp = DateTime.UtcNow, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = ctx.User.AvatarUrl, }, }; accountEmbed.AddField($"**Discord ID**", $"`{account.DiscordID}`", false); accountEmbed.AddField($"**Steam ID**", $"`{account.SteamID}`", false); accountEmbed.AddField($"**Private Profile**", $"`{account.PrivateProfile}`", false); accountEmbed.AddField($"**Account Permission**", $"`{account.Type}`", false); } else { await ctx.Channel.SendMessageAsync($"This command can only be run within a DM channel or you do not have an account setup."); return; } }
public async Task AddAsync(DiscordUser user, DateTime accountCreated) { // Before adding the user into the database, we want to give that user some base properties. PackageAccount account = new PackageAccount() { DiscordID = user.Id, LastLogin = DateTime.Now, AccountCreated = accountCreated.ToUniversalTime(), Type = Permission.Basic, }; try { using IServiceScope scope = this.scopeFactory.CreateScope(); using AccountsContext db = scope.ServiceProvider.GetRequiredService <AccountsContext>(); db.Accounts.Add(account); await db.SaveChangesAsync(); Log.Debug($"Added new account to Database: {user.Username}#{user.Discriminator} | {user.Id}"); } catch (Exception e) { // Catch if this doesn't happen which should never happen but thats not very good reason to not include this. Log.Error(e, $"Couldn't add new account! {user.Username}#{user.Discriminator} | {user.Id}"); return; } }