private async Task Grantgold(CommandContext ctx, int GoldNum, ulong memberId) { Profile profile = await _profileService.GetOrCreateProfileAsync(memberId, ctx.Guild.Id); DiscordMember member = ctx.Guild.Members[profile.DiscordId]; await _goldService.GrantGoldAsync(memberId, ctx.Guild.Id, GoldNum).ConfigureAwait(false); }
public async Task AddGold(CommandContext ctx, [Description("Mention or use member Id.")] DiscordMember member, [Description("amount of gold to add or take away (negative to take).")] int goldNum) { await _goldService.GrantGoldAsync(member.Id, ctx.Guild.Id, goldNum); if (goldNum < 0) { await ctx.Channel.SendMessageAsync($"Through the power of dadmin abooz {member.Username} lost {- goldNum} gold.").ConfigureAwait(false); } else { await ctx.Channel.SendMessageAsync($"Through the power of dadmin abooz {member.Username} gained {goldNum} gold.").ConfigureAwait(false); } }
public async Task earnxp(CommandContext ctx) { int XpNum = 1; DiscordMember member = ctx.Member; Profile profile = await _profileService.GetOrCreateProfileAsync(ctx.Member.Id, ctx.Guild.Id); GrantXpViewModel viewModel = await _experienceService.GrantXpAsync(member.Id, ctx.Guild.Id, XpNum).ConfigureAwait(false); Console.WriteLine($"{ctx.Member.Username} earned {XpNum} Xp."); if (!viewModel.LevelledUp) { return; } var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = sr.ReadToEnd(); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); int goldperlevelup = configJson.goldperlevelup; await _goldService.GrantGoldAsync(ctx.Member.Id, ctx.Guild.Id, goldperlevelup); if (profile.QuietMode == true) { return; } var levelUpEmbed = new DiscordEmbedBuilder { Title = $"{ctx.Member.DisplayName} Is Now Level {viewModel.Profile.Level}", Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = ctx.Member.AvatarUrl }, Color = ctx.Member.Color }; if (goldperlevelup > 0) { levelUpEmbed.WithDescription($"+ {goldperlevelup} :moneybag:"); } levelUpEmbed.WithFooter("`w!profile togglenotifications` to hide In future."); await ctx.Channel.SendMessageAsync(embed : levelUpEmbed).ConfigureAwait(false); }