-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Issue with discord webhooks because of empty response
- Loading branch information
1 parent
1786bf4
commit 7d9ee0d
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,9 +114,14 @@ def perform(self, paste, analyzer_name=None): | |
url = 'https://discordapp.com/api/channels/{0}/messages'.format(self.channel_id) | ||
r.headers = {'Authorization': 'Bot {}'.format(self.token)} | ||
|
||
res = json.loads(r.post(url, {"content": text})) | ||
res = r.post(url, {"content": text}) | ||
if res == "": | ||
# If the response is empty, skip further execution | ||
return | ||
|
||
if res.get('code') == 40001 and self.webhook is None and not self.identified: | ||
res = json.loads(res) | ||
|
||
if res.get('code') == 40001 and self.bot_available and self.webhook is None and not self.identified: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
d-Rickyy-b
Author
Owner
|
||
# Unauthorized access, bot token hasn't been identified to Discord Gateway | ||
self.logger.info('Accessing Discord Gateway to initialize token') | ||
self.initialize_gateway() | ||
|
If
self.bot_available
is False andself.webhook
is None,__init__
will fail to execute as you indicated in 1786bf4:raise NotImplementedError
Therefore
self.bot_availabe and self.webhook is None
is redundant, however I don't know if your policy goes towards being as cautious as possible or writing conditions of minimal complexity. Just thought I'd point that out :)