> For the complete documentation index, see [llms.txt](https://mtgmodders.gitbook.io/etg-modding-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mtgmodders.gitbook.io/etg-modding-guide/example-of-simple-mod-that-uses-polls.md).

# Example of simple mod that uses polls

```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TwitchAPI;
using TwitchAPI.Polls;
using UnityEngine;

namespace Mod
{
    //this is added to a component to the game manager instance
    internal class OccasioanlPollSubmitter :MonoBehaviour
    {
        void Start()
        {
            //subscribe to notification to handle turning off polls
            TwitchAPI.TwitchAPI.GlobalToggleStatusNotification += tapiToggleHandler;
            //creates a random vote option pool
            options.Add(new VoteOption("Give glass guon stone",GivePlayerGlass));
            options.Add(new VoteOption("for each vote, heal once",HealPlayer));
            options.Add(new VoteOption("5 damage",DamagePlayer));
            options.Add(new VoteOption("Do nothing",DoNothing));
            options.Add(new VoteOption("spawn ammo",SpawnAmmo));
            options.Add(new VoteOption("spawn enemey",SpawnBulletKin));
            options.Add(new VoteOption("for each vote, give 1 casing",GivePlayerCoin));
 
        }
        void SubmitPoll()
        {
            if (GameManager.Instance.PrimaryPlayer && !GameManager.Instance.IsFoyer)
            {
                List<VoteOption> optionLoterry = new List<VoteOption>();
                for (int i = 0; i < 4; i++)
                {
                    optionLoterry.Add(options[UnityEngine.Random.Range(0, options.Count)]);
                }
                Poll poll = new Poll(30, optionLoterry, "an example poll", PollExampleCallBack, resolvePollOptions.randomIfTie);
                MainPollController.instance.SubmitPoll(poll);   
            }
        }
        //main callback. Can be used to handle generic poll conclusion, or edge cases
        void PollExampleCallBack(Poll poll) 
        {
            //gets winning votes from a poll. Can be used to handle conlusions any way we want
            List<VoteOption> winners = MainPollController.FindWinningVotes(poll);
            //since we just use the automatic random winner, we will ignore it and just spawn some particles
            
            Vector2 pos = GameManager.Instance.PrimaryPlayer.CenterPosition;
            GlobalSparksDoer.DoRadialParticleBurst(30, pos, pos, 1, 1, 1, null, null, null, GlobalSparksDoer.SparksType.FLOATY_CHAFF);

        }
        List<VoteOption> options = new List<VoteOption>();
        void tapiToggleHandler(bool toggleState)
        {
            //submits a poll every 60 seconds. Stops the submitions when tapi is toggled off
            if (toggleState)
                InvokeRepeating("SubmitPoll", 10f, 60f);
            else
                CancelInvoke("SubmitPoll");
        }
        //various small effects
        void GivePlayerGlass(VoteOption vote) {
            Vector2 position = GameManager.Instance.PrimaryPlayer.CenterPosition;
            LootEngine.SpawnItem(PickupObjectDatabase.GetById(565).gameObject, position, Vector2.zero, 0f);
        }
        void HealPlayer(VoteOption vote) 
        { GameManager.Instance.PrimaryPlayer.healthHaver.ApplyHealing((float)vote.votes); }
       
         void DamagePlayer(VoteOption vote) 
        { GameManager.Instance.PrimaryPlayer.healthHaver.ApplyDamage(2f, Vector2.zero, "poll"); }
        
        void GivePlayerCoin(VoteOption vote) {
            Vector2 position = GameManager.Instance.PrimaryPlayer.CenterPosition;
            for (int i = 0; i < vote.votes; i++)
                LootEngine.SpawnCurrency(position + UnityEngine.Random.insideUnitCircle.normalized, 1);
        }
        void GivePlayerArmor(VoteOption vote) {
            GameManager.Instance.PrimaryPlayer.healthHaver.Armor += 3;
        }
        void SpawnAmmo(VoteOption vote) {
            Vector2 position = GameManager.Instance.PrimaryPlayer.CenterPosition;
            LootEngine.SpawnItem(PickupObjectDatabase.GetById(78).gameObject, position, Vector2.zero,0f);
        }
        void SpawnBulletKin(VoteOption vote) {
            string[] a = { "bullet_kin" };
            ETGModConsole.Spawn(a);
        }

    }
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mtgmodders.gitbook.io/etg-modding-guide/example-of-simple-mod-that-uses-polls.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
