public async Task Save(CommandContext ctx, string name) { var stat = BotFunctionality.GetCharacterSheet(name); BotFunctionality.SaveCharacterSheet(stat, ctx); await ctx.Channel.SendMessageAsync("File saved").ConfigureAwait(false); }
public async Task PlayAs(CommandContext ctx, string name) { var character = BotFunctionality.GetCharacterSheet(name); if (character == null) { await CommandFailed(ctx); } else { if (!playerRoles.ContainsKey(ctx.Member.Username)) { playerRoles.Add(ctx.Member.Username, character); } else { await ctx.Channel.SendMessageAsync(ctx.User.Mention + ": You are no longer playing as " + playerRoles[ctx.Member.Username].Name).ConfigureAwait(false); playerRoles[ctx.Member.Username] = character; } await ctx.Channel.SendMessageAsync(ctx.User.Mention + ": You are now playing as " + character.Name).ConfigureAwait(false); } }
public async Task Export(CommandContext ctx, string name) { StatSheet stat = BotFunctionality.GetCharacterSheet(name); FileInfo fi = new FileInfo(@stat.Path); if (fi.Exists) { await ctx.Channel.SendMessageAsync(ctx.User.Mention + ": Here is your file"); await ctx.RespondWithFileAsync(@stat.Path).ConfigureAwait(false); } else { await ctx.Channel.SendMessageAsync(ctx.User.Mention + ": Hmmm, I don't see " + name + " in my database."); } }
public async Task Print(CommandContext ctx, string name) { StatSheet stat = BotFunctionality.GetCharacterSheet(name); if (stat == null) { await ctx.Channel.SendMessageAsync(ctx.User.Mention + ": a character by the name of " + name + " does not exist.").ConfigureAwait(false); } else { Console.WriteLine("Retreieved"); await ctx.Channel.SendMessageAsync(BotFunctionality.ConvertStatToString(stat)).ConfigureAwait(false); Console.WriteLine("Test" + stat.debug); } }
public async Task Add(CommandContext ctx, string field, string character) { var commandInit = ctx.User.Username; var interactivity = ctx.Client.GetInteractivity(); var stat = BotFunctionality.GetCharacterSheet(character); if (field == "focus") { focuses: await ctx.Channel.SendMessageAsync("What focuses would you like to add? (please format like this)" + System.Environment.NewLine + "focusName:1" + System.Environment.NewLine + "focusName:1" + System.Environment.NewLine + "focusName:1"); var input3 = await interactivity.WaitForMessageAsync(x => x.Channel == ctx.Channel && x.Author.Username == commandInit); var focuses = input3.Result.Content.Split("\n"); try { BotFunctionality.AddFocus(focuses, stat); } catch { await ctx.Channel.SendMessageAsync("Unable to read focuses"); goto focuses; } } if (field == "ability") { abilities: await ctx.Channel.SendMessageAsync("What abilities would you like to add? (please format like this)" + System.Environment.NewLine + "abilityName1" + System.Environment.NewLine + "abilityName2" + System.Environment.NewLine + "abilityName3"); var input4 = await interactivity.WaitForMessageAsync(x => x.Channel == ctx.Channel && x.Author.Username == commandInit); var abilities = input4.Result.Content.Split("\n"); try { BotFunctionality.AddAbility(abilities, stat); } catch { await ctx.Channel.SendMessageAsync("Unable to read abilities"); goto abilities; } } if (field == "item") { items: await ctx.Channel.SendMessageAsync("What items would you like to add? (please format like this)" + System.Environment.NewLine + "itemName:1" + System.Environment.NewLine + "itemName:1" + System.Environment.NewLine + "itemName:1"); var input3 = await interactivity.WaitForMessageAsync(x => x.Channel == ctx.Channel && x.Author.Username == commandInit); var items = input3.Result.Content.Split("\n"); try { BotFunctionality.AddItem(items, stat); } catch { await ctx.Channel.SendMessageAsync("Unable to read items"); goto items; } } BotFunctionality.SaveCharacterSheet(stat, ctx); }