update to discord.gd 2.0.1
This commit is contained in:
parent
c8c4a55a99
commit
b7ada53c1d
3 changed files with 13 additions and 14 deletions
|
|
@ -58,7 +58,7 @@ var MESSAGE_TYPES = {
|
|||
'22': 'GUILD_INVITE_REMINDER'
|
||||
}
|
||||
|
||||
func _init(message: Dictionary):
|
||||
func _init(message: Dictionary, client = null):
|
||||
# Compulsory
|
||||
assert(typeof(message) == TYPE_DICTIONARY, 'Invalid type: message must be a Dictionary')
|
||||
assert(message.id, 'Message must have an id')
|
||||
|
|
@ -81,7 +81,10 @@ func _init(message: Dictionary):
|
|||
pass
|
||||
else:
|
||||
# sent by user
|
||||
assert(message.author is User, 'author attribute of Mesage must be of type User')
|
||||
if not message.author is User:
|
||||
message.author = User.new(client, message.author)
|
||||
else:
|
||||
assert(message.author is User, 'author attribute of Mesage must be of type User')
|
||||
author = message.author
|
||||
|
||||
if message.has('flags'):
|
||||
|
|
|
|||
|
|
@ -785,13 +785,9 @@ func _handle_events(dict: Dictionary) -> void:
|
|||
if d.sticker_items.size() != 0:
|
||||
return
|
||||
|
||||
var coroutine = await _parse_message(d)
|
||||
if coroutine == null:
|
||||
# message might be a thread
|
||||
# TODO: Handle sending messages in threads
|
||||
return
|
||||
await _parse_message(d)
|
||||
|
||||
d = Message.new(d)
|
||||
d = Message.new(d, self)
|
||||
|
||||
var channel = channels.get(str(d.channel_id))
|
||||
message_create.emit(self, d, channel)
|
||||
|
|
@ -1222,6 +1218,10 @@ func _setup_heartbeat_timer(interval: int) -> void:
|
|||
|
||||
|
||||
func _send_dict_wss(d: Dictionary) -> void:
|
||||
if _client.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||
if VERBOSE:
|
||||
print("Failed to send packet as websocket state is not open. Got state: " + str(_client.get_ready_state()))
|
||||
return
|
||||
var payload = JSON.stringify(d)
|
||||
var err = _client.put_packet(payload.to_utf8_buffer())
|
||||
if OK != err:
|
||||
|
|
@ -1294,11 +1294,7 @@ func _parse_message(message):
|
|||
channel = await _get_dm_channel(message.channel_id)
|
||||
_clean_channel(channel)
|
||||
|
||||
if channel and channel.has('type') and channel.type == 'DM':
|
||||
channels[str(message.channel_id)] = channel
|
||||
else:
|
||||
# not a valid channel, it might be a thread
|
||||
return null
|
||||
channels[str(message.channel_id)] = channel
|
||||
|
||||
if message.has('author') and typeof(message.author) == TYPE_DICTIONARY:
|
||||
# get the cached author of the message
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
name="discord.gd"
|
||||
description="A Discord bot API wrapper for Godot."
|
||||
author="Delano Lourenco"
|
||||
version="2.0.0"
|
||||
version="2.0.1"
|
||||
script="plugin.gd"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue