TomerGamerTV

Untitled

Nov 18th, 2021
1,936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.08 KB | None | 0 0
  1.  
  2. # CONFIG
  3. # -----------------------------------------------------
  4. token = "" # INSERT BOT TOKEN HERE
  5. counting_channel = "" # INSERT CHANNEL ID HERE
  6. delay = [0.5, 0.6] # DELAY BETWEEN COUNTING
  7. selfbot = True # Change this if using BOT ACCOUNT
  8. last_number = "" # Optional, it starts counting from this number
  9.  
  10. mode = "BINARY" # CHOOSE MODE OF COUNTING
  11. # You can choose from: INCREMENTAL or BINARY
  12. # -----------------------------------------------------
  13.  
  14. try:
  15.     import discord, time, random, sys
  16. except ImportError as e:
  17.     print(e)
  18.     exit()
  19.    
  20. from discord.ext import commands
  21.  
  22. if sys.version_info[0] < 3:
  23.     print("Python 3 or a more recent version is required.")
  24.     exit()
  25.  
  26. if token == "Your token here" or counting_channel == "Your channel id here":
  27.     print("Please fill out the config!")
  28.     exit()
  29.  
  30. bot = commands.Bot(command_prefix='!', self_bot=selfbot)
  31. bot.remove_command("help")
  32.  
  33. print("Logging in...")
  34. @bot.event
  35. async def on_ready():
  36.     print('Logged in as {0.user}, time to start counting!'.format(bot))
  37.    
  38. @bot.event
  39. async def on_message(message):
  40.     global last_number
  41.     if bot.user.id != message.author.id and message.channel.id == int(counting_channel):
  42.         channel = bot.get_channel(int(counting_channel))
  43.         try:
  44.             if last_number == "" and mode == "INCREMENTAL":
  45.                 last_number = int(message.content)
  46.             elif last_number == "" and mode == "BINARY":
  47.                 last_number = int(message.content, 2)
  48.         except:
  49.             pass
  50.         else:            
  51.             if mode == "INCREMENTAL" and int(message.content) < last_number:
  52.                 print("Lower number posted, doing nothing!")
  53.             elif mode == "INCREMENTAL" and int(message.content) > (last_number + 1):
  54.                 print("too high number, doing nothing!")
  55.             elif mode == "BINARY" and int(message.content, 2) < last_number:
  56.                 print("Lower number posted, doing nothing!")
  57.             elif mode == "BINARY" and int(message.content, 2) > (last_number + 1):
  58.                 print("too high number, doing nothing!")
  59.             else:
  60.                 time.sleep(random.uniform(delay[0], delay[1]))
  61.                 last_number += 2
  62.                 if mode == "INCREMENTAL":
  63.                     num = int(message.content)
  64.                     bigger_num = num + 1
  65.                    
  66.                     await channel.send(bigger_num)
  67.                     print("SENDING: " + str(bigger_num))
  68.                     print("NEXT NUMBER: " + str(last_number))
  69.                    
  70.                 elif mode == "BINARY":
  71.                     num = int(message.content, 2)
  72.                     bigger_num = "{0:b}".format(num + 1)
  73.                    
  74.                     await channel.send(bigger_num)
  75.                     print("SENDING: " + str(bigger_num))
  76.                     print("NEXT NUMBER: " + str("{0:b}".format(last_number)))
  77.            
  78.  
  79. try:
  80.     bot.run(token, bot=(not selfbot))
  81.     print("\nExiting, have a nice day!")
  82. except discord.errors.LoginFailure as e:
  83.     print("Error: " + str(e))
  84.  
  85.  
Advertisement
Add Comment
Please, Sign In to add comment