Listing Out Voices

18 views
Skip to first unread message

Daniel Amusin

unread,
Nov 10, 2015, 9:07:10 PM11/10/15
to pircbotx
Sorry, to preface I am a bit new to java so it may seem like a stupid question.

I was wondering, how would I go about listing everything returned in an ImmutableSortedSet. I was trying to create a command on which when issued, the bot would send a message with all of the people who are voiced in the channel, however, only channel operators could issue the command. I am getting stuck on trying to retrieve who is voiced/operator/etc.

Thanks.

Leon Blakey

unread,
Nov 11, 2015, 10:28:17 AM11/11/15
to pirc...@googlegroups.com
What about something like if(event.getUser().getChannelsVoiceIn().contains(event.getChannel()))) {...} ?

or

for(User curUser : event.getChannel().getVoices()) {...}

--
You received this message because you are subscribed to the Google Groups "pircbotx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Amusin

unread,
Nov 11, 2015, 10:51:40 AM11/11/15
to pircbotx
I guess my bigger question is how I would go about having the bot message the channel that includes all of the names inside of them. Ex {Voice1 Voice2 Voice3...}. I don't quit understand how I am retrieving their names.

Rob Porter

unread,
Nov 11, 2015, 11:08:56 AM11/11/15
to pirc...@googlegroups.com
Would this help you?

StringBuilder sb = new StringBuilder();
for( User user : event.getChannel().getVoices() ){
sb.append( user.getNick() ).append(" ");
}
event.getChannel().send().message("These users are voiced: " + sb.toString());

Its fairly easy to get the set of users from a channel.  Are you having difficulty using Sets in Java?

Daniel Amusin

unread,
Nov 11, 2015, 11:52:32 AM11/11/15
to pircbotx
Yes I was simply having difficulty with sets. That was a huge help. One other question, how would I be able to check if the sender of the command is inside of the set of ops for example. Once again, sorry for my newbiness.

Leon Blakey

unread,
Nov 11, 2015, 12:28:45 PM11/11/15
to pirc...@googlegroups.com
You can tweak that line and do

if(event.getUser().getChannelsOpIn().contains(event.getChannel()))) {...}

or by going through the channel

if(event.getChannel().getOps().contains(event.getUser()) {...}

Daniel Amusin

unread,
Nov 11, 2015, 12:31:42 PM11/11/15
to pircbotx
I see, big thanks guys! Really appreciate it!
Reply all
Reply to author
Forward
0 new messages