@JSGetter public DelegateStream<HostObjectChannel> channels() { return new DelegateStream<>( Discord.getInstance() .getChannels() .stream() .map(c -> HostObjectChannel.impl(c, ScriptableObject.getTopLevelScope(this)))); }
@JSGetter public DelegateStream<HostObjectUser> users() { return new DelegateStream<>( Discord.getInstance() .getUsers() .stream() .map(u -> HostObjectUser.impl(u, ScriptableObject.getTopLevelScope(this)))); }
@JSGetter public DelegateStream<HostObjectGuild> guilds() { return new DelegateStream<>( Discord.getInstance() .getGuilds() .stream() .map(g -> HostObjectGuild.impl(g, ScriptableObject.getTopLevelScope(this)))); }
@JSFunction public HostObjectChannel getChannel(String id) { IChannel channel = Discord.getInstance().getChannelById(id); if (channel == null) return null; return HostObjectChannel.impl(channel, ScriptableObject.getTopLevelScope(this)); }
@JSFunction public HostObjectUser getUser(String id) { IUser user = Discord.getInstance().getUserById(id); if (user == null) return null; return HostObjectUser.impl(user, ScriptableObject.getTopLevelScope(this)); }
@JSFunction public HostObjectGuild getGuild(String id) { IGuild guild = Discord.getInstance().getGuildById(id); if (guild == null) return null; return HostObjectGuild.impl(guild, ScriptableObject.getTopLevelScope(this)); }