Skip to content

Commit

Permalink
fixed avatar bug
Browse files Browse the repository at this point in the history
  • Loading branch information
3ddelano committed Aug 5, 2021
1 parent ababa74 commit 220388e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
This is a high-level changelog for each released versions of the plugin.
For a more detailed list of past and incoming changes, see the commit history.

Master
- Fixed bug where bot crashes if no avatar is set
- If bot gets ratelimited, it now waits until the message is sent

1.0.1
------
- Bot will try to reconnect every 5s if initially there is no internet
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Discord.gd
=========================================
###### (Godot Plugin - Coming Soon on the Asset Library)
###### (Get it from Godot Asset Library - https://godotengine.org/asset-library/asset/1010)


### A Godot plugin to interact with the Discord Bot API. Make Discord Bots in Godot!

> 100% GDScript
<br>
<img alt="Godot3" src="https://img.shields.io/badge/-Godot 3.x-478CBF?style=for-the-badge&logo=godotengine&logoWidth=20&logoColor=white" />
<img alt="Godot3" src="https://img.shields.io/badge/-Godot 3.3.x-478CBF?style=for-the-badge&logo=godotengine&logoWidth=20&logoColor=white" />

Features
--------------
Expand Down Expand Up @@ -41,7 +41,7 @@ Getting Started
1. After activating the plugin. There will be a new DiscordBot node added to Godot.
Click on any node in the scene tree of your scene for example `MyBot`:Node2D and add the DiscordBot as a child.

2. Connect the various signals (`bot_ready`, `guild_create`, `message_create`, `message_delete`, etc) of the DiscordBot to the parent node
2. Connect the various signals (`bot_ready`, `guild_create`, `message_create`, `message_delete`, etc) of the DiscordBot to the parent node, either through the GUI or in the script using the connect() function.

3. Attach a script to the parent node.
Example script on `MyBot` node
Expand All @@ -56,15 +56,13 @@ func _ready():
func _on_DiscordBot_bot_ready(bot: DiscordBot):
print('Logged in as ' + bot.user.username + '#' + bot.user.discriminator)
print('Listening on ' + bot.channels.size() + ' channels and ' + bot.guilds.size() ' guilds.')
print('Listening on ' + str(bot.channels.size()) + ' channels and ' + str(bot.guilds.size()) ' guilds.')
```

Documentation
[Documentation](https://github.com/3ddelano/discord.gd/wiki)
----------

Check the [Wiki](https://github.com/3ddelano/discord.gd/wiki) Tab


Contributing
-----------
Expand All @@ -82,4 +80,4 @@ Thanks for your support :)
<a href="https://www.buymeacoffee.com/3ddelano" target="_blank"><img height="41" width="174" src="https://cdn.buymeacoffee.com/buttons/v2/default-red.png" alt="Buy Me A Coffee" width="150" ></a>

### Support Server
Join the Discord Server: [3ddelano Cafe](https://discord.gg/FZY9TqW)
For doubts / help / bugs / problems / suggestions do join: [3ddelano Cafe](https://discord.gg/FZY9TqW)
14 changes: 6 additions & 8 deletions addons/discord_gd/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Discord.gd
=========================================
###### (Godot Plugin - Coming Soon on the Asset Library)
###### (Get it from Godot Asset Library - https://godotengine.org/asset-library/asset/1010)


### A Godot plugin to interact with the Discord Bot API. Make Discord Bots in Godot!

> 100% GDScript
<br>
<img alt="Godot3" src="https://img.shields.io/badge/-Godot 3.x-478CBF?style=for-the-badge&logo=godotengine&logoWidth=20&logoColor=white" />
<img alt="Godot3" src="https://img.shields.io/badge/-Godot 3.3.x-478CBF?style=for-the-badge&logo=godotengine&logoWidth=20&logoColor=white" />

Features
--------------
Expand Down Expand Up @@ -41,7 +41,7 @@ Getting Started
1. After activating the plugin. There will be a new DiscordBot node added to Godot.
Click on any node in the scene tree of your scene for example `MyBot`:Node2D and add the DiscordBot as a child.

2. Connect the various signals (`bot_ready`, `guild_create`, `message_create`, `message_delete`, etc) of the DiscordBot to the parent node
2. Connect the various signals (`bot_ready`, `guild_create`, `message_create`, `message_delete`, etc) of the DiscordBot to the parent node, either through the GUI or in the script using the connect() function.

3. Attach a script to the parent node.
Example script on `MyBot` node
Expand All @@ -56,15 +56,13 @@ func _ready():
func _on_DiscordBot_bot_ready(bot: DiscordBot):
print('Logged in as ' + bot.user.username + '#' + bot.user.discriminator)
print('Listening on ' + bot.channels.size() + ' channels and ' + bot.guilds.size() ' guilds.')
print('Listening on ' + str(bot.channels.size()) + ' channels and ' + str(bot.guilds.size()) ' guilds.')
```

Documentation
[Documentation](https://github.com/3ddelano/discord.gd/wiki)
----------

Check the [Wiki](https://github.com/3ddelano/discord.gd/wiki) Tab


Contributing
-----------
Expand All @@ -82,4 +80,4 @@ Thanks for your support :)
<a href="https://www.buymeacoffee.com/3ddelano" target="_blank"><img height="41" width="174" src="https://cdn.buymeacoffee.com/buttons/v2/default-red.png" alt="Buy Me A Coffee" width="150" ></a>

### Support Server
Join the Discord Server: [3ddelano Cafe](https://discord.gg/FZY9TqW)
For doubts / help / bugs / problems / suggestions do join: [3ddelano Cafe](https://discord.gg/FZY9TqW)
5 changes: 3 additions & 2 deletions addons/discord_gd/classes/user.gd
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ func _init(_client, user):
assert(user.has('id'), 'User must have an id')
assert(user.has('username'), 'User must have a username')
assert(user.has('discriminator'), 'User must have a discriminator')
assert(user.has('avatar'), 'User must have a avatar')


id = user.id
username = user.username
discriminator = user.discriminator
avatar = user.avatar
if user.avatar:
avatar = user.avatar

# Optional

Expand Down
11 changes: 11 additions & 0 deletions addons/discord_gd/discord.gd
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ func _send_raw_request(slug: String, payload: Dictionary, method = HTTPClient.ME

assert(not response.has('code'), 'Error sending request. See output window')


if response.has('retry_after'):
# We got ratelimited
yield(get_tree().create_timer(int(response.retry_after)), 'timeout')
response = yield(_send_raw_request(slug, payload, method), 'completed')

return response
else:
assert(false, 'Unable to upload file. Got empty response from server')
Expand Down Expand Up @@ -501,6 +507,11 @@ func _send_request(slug: String, payload: Dictionary, method = HTTPClient.METHOD
if method != HTTPClient.METHOD_DELETE:
assert(not response.has('code'), 'Error sending request. See output window')

if response.has('retry_after'):
# We got ratelimited
yield(get_tree().create_timer(int(response.retry_after)), 'timeout')
response = yield(_send_request(slug, payload, method), 'completed')

return response

func _get_dm_channel(channel_id: String) -> Dictionary:
Expand Down

0 comments on commit 220388e

Please sign in to comment.