Discord trick or treat bot

Alright, so my daughter got hooked on to this Trick or Treat craziness on Discord, and honestly I also found it amusing.

Not to cheat, I wanted to see if I could write a script in python to quickly help me type and get ahead of anyone.

It worked ! 10 Minutes of Scripting and it can get you endless cheating. I did collect 5 goodies , and then killed the script. What’s the fun in cheating, but this was enough to show my daughter the power of python.

Here is the script. Offcourse you would need the selenium chromedriver and python to run this .

import selenium ; from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import keyboard

# in this window,login to Discourse

def cheat(my_key):
    input_field = dr.find_element_by_xpath('//*[@id="app-mount"]/div[2]/div/div[2]/div/div/div/div/div[2]/div/main/form/div/div/div/div/div[3]/div[2]')

def t():
    latest= (dr.find_elements_by_class_name("username-1A8OIy")[-1]).get_attribute('innerHTML')
    if latest == "Trick'cord Treat" :        
        msg = (dr.find_elements_by_class_name("container-1ov-mD")[-1]).get_attribute('innerHTML')
        if "h!trick" in msg :
        if "h!treat" in msg :

while True:
    #press b to break the loop 
    if keyboard.is_pressed('b'):break