Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. # You need to install discord by running "pip install discord.py"
  2. # I'm assuming nothing will break on python 3.5
  3. # But it probably will
  4.  
  5. import discord
  6. import argparse
  7. import sys
  8. import getopt
  9.  
  10. client = discord.Client()
  11.  
  12. parser = argparse.ArgumentParser(description='Change your current game on discord.')
  13.  
  14. parser.add_argument('username',)
  15.  
  16.  
  17.  
  18.  
  19. def main(argv):
  20. username = ''
  21. password = ''
  22. game = ''
  23. try:
  24. opts, args = getopt.getopt(argv, "hu:p:g:", ["username=", "password=", "game="])
  25. except getopt.GetoptError:
  26. print('change_game.py -u <username> -p <password> -g "<game>" [in quotes]')
  27. sys.exit(2)
  28. for opt, arg in opts:
  29. if opt == '-h':
  30. print('change_game.py -u <username> -p <password> -g "<game>" [in quotes]')
  31. sys.exit()
  32. elif opt in ("-u", "--username"):
  33. username = arg
  34. elif opt in ("-p", "--password"):
  35. password = arg
  36. elif opt in ("-g", "--game"):
  37. game = arg.split('"')
  38. print game
  39. game = game[0]
  40.  
  41.  
  42. try:
  43. client.login(username, password)
  44. except:
  45. print('Could not log into discord. Check that the username and password are correct.')
  46. sys.exit(0)
  47.  
  48. cur_game = discord.Game(name=game)
  49. client.change_status(game=cur_game)
  50. print('Game set to {0}'.format(game))
  51.  
  52. if __name__ == "__main__":
  53. main(sys.argv[1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement