Ejemplo n.º 1
0
        public async Task Grant_Schem(IUser user, [Remainder] string name)
        {
            if (await IsGMLevel(3))
            {
                string schemName = StringM.UpperAt(name);
                Item   item      = Item.LoadItem(schemName);
                if (item.type != Item.IType.notfound)
                {
                    if (item.schematic.exists)
                    {
                        Player player = Player.Load(user.Id, Player.IgnoreException.All);
                        if (player.schematics == null)
                        {
                            player.schematics = new List <Schematic>();
                        }
                        if (player.schematics.FindIndex(Schematic.FindWithName(item.schematic.name)) == -1)
                        {
                            player.schematics.Add(item.schematic);
                            player.SaveFileMongo();
                            IUserMessage reply = await ReplyAsync(user.Mention + " received a " + schemName + " schematic");

                            player.ui = new UI(reply, new List <string> {
                                EUI.xp, EUI.inv, EUI.stats, EUI.schem
                            });
                            player.SaveFileMongo();
                            await DUtils.DeleteContextMessageAsync(Context);
                        }
                        else
                        {
                            await DUtils.Replydb(Context, "Player already has this schematic");
                        }
                    }
                    else
                    {
                        await DUtils.Replydb(Context, "Item does not have a schematic");
                    }
                }
                else
                {
                    await DUtils.Replydb(Context, "Item not found");
                }
            }
        }