Skip to content

Instantly share code, notes, and snippets.

@Tustin
Created January 5, 2018 01:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tustin/d10e31f4ae5097addfaca51d01ac0976 to your computer and use it in GitHub Desktop.
Save Tustin/d10e31f4ae5097addfaca51d01ac0976 to your computer and use it in GitHub Desktop.
import discord
import asyncio
import requests
import json
client = discord.Client()
def check_psn(psn):
response = requests.post('https://accounts.api.playstation.com/api/v1/accounts/onlineIds', json={"onlineId": psn, "reserveIfAvailable": False})
return response.status_code != 401 and response.status_code != 400
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!check'):
splits = message.content.split()
if len(splits) != 2:
return
psn = splits[1]
if check_psn(psn):
await client.send_message(message.channel, '{0} is available'.format(psn))
else:
await client.send_message(message.channel, '{0} is taken'.format(psn))
client.run('token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment