-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of Inline Replies; discord/discord-api-docs#2118
[ci skip]
- Loading branch information
Showing
11 changed files
with
112 additions
and
29 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
part of nyxx; | ||
|
||
/// Message wrapper that other message replies to. | ||
/// [message] field can be null of two reasons: backend error or message was deleted. | ||
/// In first case [isBackendFetchError] will be true and [isDeleted] in second case. | ||
class ReferencedMessage { | ||
/// Message object of reply | ||
late final Message? message; | ||
|
||
/// If true the backend couldn't fetch the message | ||
late final bool isBackendFetchError; | ||
|
||
/// If true message was delted | ||
late final bool isDeleted; | ||
|
||
ReferencedMessage._new(Nyxx client, Map<String, dynamic> raw) { | ||
if (!raw.containsKey(raw["referencedMessage"])) { | ||
this.message = null; | ||
this.isBackendFetchError = true; | ||
this.isDeleted = false; | ||
return; | ||
} | ||
|
||
if (raw["referencedMessage"] == null) { | ||
this.message = null; | ||
this.isBackendFetchError = false; | ||
this.isDeleted = true; | ||
return; | ||
} | ||
|
||
this.message = Message._deserialize(client, raw); | ||
this.isBackendFetchError = false; | ||
this.isDeleted = false; | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
part of nyxx; | ||
|
||
/// Builder for replying to message | ||
class ReplyBuilder implements Builder { | ||
/// Id of message you reply to | ||
final Snowflake messageId; | ||
|
||
/// Id of channel of message which you reply to | ||
final Snowflake channelId; | ||
|
||
/// Constructs reply builder for given message in channel | ||
ReplyBuilder(this.messageId, this.channelId); | ||
|
||
/// Constructs message reply from given message | ||
factory ReplyBuilder.froMessage(Message message) => | ||
ReplyBuilder(message.id, message.channel.id); | ||
|
||
/// Constructs message reply from cacheable of message and channel | ||
factory ReplyBuilder.fromCacheable(Cacheable<Snowflake, Message> messageCacheable, Cacheable<Snowflake, TextChannel> channelCacheable) => | ||
ReplyBuilder(messageCacheable.id, channelCacheable.id); | ||
|
||
@override | ||
Map<String, dynamic> _build() => { | ||
"message_id": this.messageId.id, | ||
"channel_id": this.channelId.id | ||
}; | ||
} |
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