Skip to content

Commit 723c062

Browse files
authored
Merge pull request #5 from marimeireles/master
Updating code + error handling
2 parents a8cc72c + a47558a commit 723c062

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,16 @@ def recaptcha(token):
6464
def invite():
6565
print("Generating new invite!")
6666
resp = requests.post(
67-
'https://discordapp.com/api/channels/%s/invites' % config["discord"]["welcome_room"],
68-
headers={'Authorization': 'Bot %s' % config["discord"]["private"]},
69-
json={'max_uses': 1, 'unique': True, 'expires': 300}
67+
'https://discordapp.com/api/channels/{}/invites'.format(config["discord"]["welcome_room"]),
68+
headers={'Authorization': 'Bot {}'.format(config["discord"]["private"])},
69+
json={'max_uses': 1, 'unique': True, 'max_age': 300}
7070
)
7171
i = resp.json()
72-
print("Generated new invite!")
72+
# error handling for invite creation
73+
if (i.get('code')):
74+
print("Generated new invite!")
75+
else:
76+
print(i)
7377
return i["code"]
7478

7579
app = Flask(__name__)

0 commit comments

Comments
 (0)