adding to guild
This commit is contained in:
parent
efbba335a7
commit
2d0183f797
2 changed files with 55 additions and 32 deletions
|
@ -27,11 +27,10 @@ int calculateIntents(List<int> intents) {
|
|||
class Client extends EventEmitter {
|
||||
String? token;
|
||||
int intents;
|
||||
dynamic ws;
|
||||
late WebSocket ws;
|
||||
String resumeGatewayURL = "";
|
||||
String sessionID = "";
|
||||
dynamic guilds;
|
||||
dynamic ready;
|
||||
late GuildManager guilds;
|
||||
|
||||
/// Create a new Client.
|
||||
/// [intents] Intents to enable for this connection, it's a multiple of two.
|
||||
|
|
|
@ -88,20 +88,35 @@ class Collection {
|
|||
|
||||
/// Represents a guild (aka server) on Discord.
|
||||
class Guild {
|
||||
String id = '';
|
||||
String name = '';
|
||||
String? owner;
|
||||
String? description;
|
||||
late ChannelManager channels;
|
||||
late MemberManager members;
|
||||
late RoleManager roles;
|
||||
final Sender _sender;
|
||||
ChannelManager? channels;
|
||||
MemberManager? members;
|
||||
RoleManager? roles;
|
||||
String id = '';
|
||||
String? name = '';
|
||||
String? ownerId;
|
||||
String? description;
|
||||
String? joinedAt;
|
||||
bool? large;
|
||||
bool? unavailable;
|
||||
int? memberCount;
|
||||
|
||||
Guild(this._sender, Map data) {
|
||||
id = data["id"];
|
||||
if (data["unavailable"] != null && data["unavailable"] == false) {
|
||||
unavailable = data["unavailable"];
|
||||
name = data["name"];
|
||||
description = data["description"];
|
||||
owner = data["owner_id"];
|
||||
ownerId = data["owner_id"];
|
||||
if (data["joined_at"] != null) {
|
||||
joinedAt = data["joined_at"];
|
||||
}
|
||||
if (data["large"] != null) {
|
||||
large = data["large"];
|
||||
}
|
||||
if (data["member_count"] != null) {
|
||||
memberCount = data["member_count"];
|
||||
}
|
||||
|
||||
if(data["channels"] != null && data["members"] != null && data["roles"] != null) {
|
||||
List<Channel> cc = [];
|
||||
|
@ -126,6 +141,9 @@ class Guild {
|
|||
members = MemberManager([], id);
|
||||
roles = RoleManager([]);
|
||||
}
|
||||
} else {
|
||||
unavailable = data["unavailable"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,6 +160,11 @@ class GuildManager {
|
|||
Future<Guild> fetch(String id) async {
|
||||
var res = await _sender.fetchGuild(id);
|
||||
final guild = Guild(_sender, res);
|
||||
final oldGuild = cache.get(guild.id);
|
||||
guild.joinedAt = oldGuild.joinedAt;
|
||||
guild.large = oldGuild.large;
|
||||
guild.unavailable = oldGuild.unavailable;
|
||||
guild.memberCount = oldGuild.memberCount;
|
||||
cache.set(guild.id, guild);
|
||||
return guild;
|
||||
}
|
||||
|
@ -283,6 +306,7 @@ class Message {
|
|||
String? content;
|
||||
Message({ this.content });
|
||||
|
||||
/// Returns an object rapresentation of the message
|
||||
exportable() {
|
||||
return {
|
||||
"content": content,
|
||||
|
|
Reference in a new issue