public override void RunCommand([NotNull] ITwitchMessage twitchMessage) { var worker = ArgWorker.CreateInstance(CommandFilter.Parse(twitchMessage.Message).Skip(1)); if (!worker.TryGetNextAsViewer(out Viewer viewer) || !worker.TryGetNextAsInt(out int amount)) { return; } viewer.GiveViewerCoins(amount); Store_Logger.LogGiveCoins(twitchMessage.Username, viewer.username, amount); twitchMessage.Reply("TKUtils.GiveCoins.Done".LocalizeKeyed(amount.ToString("N0"), viewer.username, viewer.GetViewerCoins().ToString("N0"))); }
public override void RunCommand(TwitchIRCMessage message) { try { string[] command = message.Message.Split(' '); if (command.Length < 3) { return; } string receiver = command[1].Replace("@", ""); if (message.User.ToLower() != ToolkitSettings.Channel.ToLower() && receiver.ToLower() == message.User.ToLower()) { Toolkit.client.SendMessage($"@{message.User} " + "TwitchToolkitModCannotGiveCoins".Translate()); return; } int amount; bool isNumeric = int.TryParse(command[2], out amount); if (isNumeric) { Viewer giftee = ViewerModel.GetViewerByTypeAndUsername(receiver, message.Viewer.ViewerType); Helper.Log($"Giving viewer {giftee.Username} {amount} coins"); giftee.GiveCoins(amount); Toolkit.client.SendMessage($"@{message.User} " + Helper.ReplacePlaceholder("TwitchToolkitGivingCoins".Translate(), viewer: giftee.Username, amount: amount.ToString(), newbalance: giftee.Coins.ToString()), CommandsHandler.SendToChatroom(message)); Store_Logger.LogGiveCoins(message.User, giftee.Username, amount); } } catch (InvalidCastException e) { Helper.Log("Invalid Give Viewer Coins Command " + e.Message); } }
public override void RunCommand(ITwitchMessage twitchMessage) { try { string[] command = twitchMessage.Message.Split(' '); if (command.Length < 3) { return; } string receiver = command[1].Replace("@", ""); if (twitchMessage.Username.ToLower() != ToolkitSettings.Channel.ToLower() && receiver.ToLower() == twitchMessage.Username.ToLower()) { TwitchWrapper.SendChatMessage($"@{twitchMessage.Username} " + "TwitchToolkitModCannotGiveCoins".Translate()); return; } int amount; bool isNumeric = int.TryParse(command[2], out amount); if (isNumeric) { Viewer giftee = Viewers.GetViewer(receiver); Helper.Log($"Giving viewer {giftee.username} {amount} coins"); giftee.GiveViewerCoins(amount); TwitchWrapper.SendChatMessage($"@{twitchMessage.Username} " + Helper.ReplacePlaceholder("TwitchToolkitGivingCoins".Translate(), viewer: giftee.username, amount: amount.ToString(), newbalance: giftee.coins.ToString())); Store_Logger.LogGiveCoins(twitchMessage.Username, giftee.username, amount); } } catch (InvalidCastException e) { Helper.Log("Invalid Give Viewer Coins Command " + e.Message); } }