https://github.com/benjaminurquhart/cio
Input/Output stream wrapper for JDA Channel objects
https://github.com/benjaminurquhart/cio
cio cis cos discord java java-8 java-io jda jda-extension jda-utilities
Last synced: about 2 months ago
JSON representation
Input/Output stream wrapper for JDA Channel objects
- Host: GitHub
- URL: https://github.com/benjaminurquhart/cio
- Owner: BenjaminUrquhart
- Created: 2018-10-10T05:12:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T18:02:39.000Z (over 6 years ago)
- Last Synced: 2025-03-29T10:32:22.834Z (about 1 year ago)
- Topics: cio, cis, cos, discord, java, java-8, java-io, jda, jda-extension, jda-utilities
- Language: Java
- Homepage:
- Size: 111 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CIO
Input/Output Stream wrapper for JDA Channel objects
Fair warning: for some reason this does not work with the `java.util.Scanner` class.
InputStream:
- TextChannel: Working
- MessageChannel: Support Dropped
- PrivateChannel: Support Dropped
- VoiceChannel: NOT Working. Not sure if it's Discord audio being funky again.
OutputStream:
- TextChannel: Working
- MessageChannel: Working
- PrivateChannel: Support Dropped
- VoiceChannel: Untested
I should probably have read the [InputStream docs](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html) first before making this :^)
# Example usage:
```java
//Let's say you have a TextChannel from an onGuildMessageReceivedEvent.
ChannelInputStream input = new ChannelInputStream(event.getChannel(), true); //The boolean toggles ignoring bots.
ChannelOutputStream output = new ChannelOutputStream(event.getChannel());
//Let's write something to the stream
output.write("Hello there!".getBytes());
output.flush(); //This actually sends the message. It is automatically called when the buffer length reaches 2000 characters.
//Let's read the next message
String msg = (char)input.read() + "";
while(input.hasNext()){
msg += (char)input.read();
}
System.out.println(msg);
```