public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { if (rawTerms.Length < 2) { bot.SendMessageInChannel("Error: This command requires 2 terms. (Amount and chip code)", channel); } else { int chipAmount = Utils.GetNumberFromInputs(terms); string chipCode = rawTerms[1]; if (chipAmount > 0 && !string.IsNullOrEmpty(chipCode)) { bot.ChipsCoupons.Add(new ChipsCoupon() { ChipsAmount = chipAmount, Code = chipCode }); commandController.SaveCouponsToDisk(); bot.SendMessageInChannel("Added code " + chipCode + " for " + chipAmount + " chips.", channel); } else { bot.SendMessageInChannel("Error on inputs for chips code.", channel); } } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { if (thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin) { bot.SendMessageInChannel("Redeemchips is only functional in channels that have [b]restricted[/b] chips pools. Please try using '!addchips' instead.", channel); } else { string messageString = ""; if (rawTerms.Count() < 1) { messageString = "Error: This command requires a chips code."; } else { string chipsCode = rawTerms[0]; //find chips coupon ChipsCoupon coupon = bot.ChipsCoupons.FirstOrDefault(a => a.Code == chipsCode); if (coupon == null) { messageString = "chips code not found (" + chipsCode + ")"; } else if (coupon.Redeemed) { messageString = "This chips code (" + chipsCode + ") has already been redeemed."; } else { //mark redeemed and add chips to the redeeming character coupon.Redeemed = true; coupon.RedeemedBy = characterName; messageString = "Chips code redeemed.\n" + bot.DiceBot.AddChips(characterName, channel, coupon.ChipsAmount, false) + "\n[sub]Thank you for purchasing Dice Bot chips![/sub]"; commandController.SaveChipsToDisk(); commandController.SaveCouponsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }