Skip to content

Commit

Permalink
Merge pull request #5 from marimeireles/master
Browse files Browse the repository at this point in the history
Updating code + error handling
  • Loading branch information
MiranDaniel authored Jan 16, 2022
2 parents a8cc72c + a47558a commit 723c062
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ def recaptcha(token):
def invite():
print("Generating new invite!")
resp = requests.post(
'https://discordapp.com/api/channels/%s/invites' % config["discord"]["welcome_room"],
headers={'Authorization': 'Bot %s' % config["discord"]["private"]},
json={'max_uses': 1, 'unique': True, 'expires': 300}
'https://discordapp.com/api/channels/{}/invites'.format(config["discord"]["welcome_room"]),
headers={'Authorization': 'Bot {}'.format(config["discord"]["private"])},
json={'max_uses': 1, 'unique': True, 'max_age': 300}
)
i = resp.json()
print("Generated new invite!")
# error handling for invite creation
if (i.get('code')):
print("Generated new invite!")
else:
print(i)
return i["code"]

app = Flask(__name__)
Expand Down

0 comments on commit 723c062

Please sign in to comment.