use of io.discloader.discloader.network.json.RoleJSON in project DiscLoader by R3alCl0ud.
the class Mentions method patch.
public void patch(UserJSON[] mentions, RoleJSON[] mention_roles, boolean mention_everyone) {
everyone = mention_everyone;
users.clear();
roles.clear();
for (UserJSON data : mentions) {
IUser user = EntityRegistry.getUserByID(data.id);
if (user == null)
user = EntityRegistry.addUser(data);
users.put(SnowflakeUtil.parse(data.id), user);
}
if (guild != null) {
for (RoleJSON data : mention_roles) {
long id = SnowflakeUtil.parse(data.id);
roles.put(id, guild.getRoles().get(id));
}
}
}
use of io.discloader.discloader.network.json.RoleJSON in project DiscLoader by R3alCl0ud.
the class Guild method setup.
/**
* Sets up a guild with data from the gateway
*
* @param data
* The guild's data
*/
@Override
public void setup(GuildJSON data) {
try {
name = data.name;
icon = data.icon != null ? data.icon : null;
iconURL = icon != null ? Endpoints.guildIcon(getID(), icon) : null;
ownerID = SnowflakeUtil.parse(data.owner_id);
memberCount = data.member_count;
voiceRegion = new VoiceRegion(data.region);
splashHash = data.splash;
if (data.roles.length > 0) {
roles.clear();
for (RoleJSON role : data.roles) {
IRole r = gfac.buildRole(this, role);
roles.put(r.getID(), r);
}
}
if (data.members != null && data.members.length > 0) {
members.clear();
for (MemberJSON member : data.members) {
IGuildMember m = gfac.buildMember(this, member);
members.put(m.getID(), m);
}
}
if (data.channels != null && data.channels.length > 0) {
for (ChannelJSON channelData : data.channels) {
IGuildChannel chan = (IGuildChannel) EntityRegistry.addChannel(channelData, getLoader(), this);
if (chan instanceof IGuildTextChannel)
textChannels.put(chan.getID(), (IGuildTextChannel) chan);
else if (chan instanceof IGuildVoiceChannel)
voiceChannels.put(chan.getID(), (IGuildVoiceChannel) chan);
}
}
if (data.presences != null && data.presences.length > 0) {
presences.clear();
for (PresenceJSON presence : data.presences) {
this.setPresence(presence);
}
}
if (data.emojis != null && data.emojis.length > 0) {
this.guildEmojis.clear();
for (EmojiJSON e : data.emojis) {
this.guildEmojis.put(SnowflakeUtil.parse(e.id), new GuildEmoji(e, this));
}
}
if (data.voice_states != null && data.voice_states.length > 0) {
this.rawStates.clear();
for (VoiceStateJSON v : data.voice_states) {
this.rawStates.put(SnowflakeUtil.parse(v.user_id), new VoiceState(v, this));
}
}
this.available = data.unavailable == true ? false : true;
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations