本文整理汇总了Java中sx.blah.discord.handle.obj.IVoiceChannel类的典型用法代码示例。如果您正苦于以下问题:Java IVoiceChannel类的具体用法?Java IVoiceChannel怎么用?Java IVoiceChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IVoiceChannel类属于sx.blah.discord.handle.obj包,在下文中一共展示了IVoiceChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runCommand
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Skips song in voice channel
* @param event passed event
* @param args passed arguments
*/
@Override
public final void runCommand(MessageReceivedEvent event, String args) {
List<IVoiceChannel> connectedVoiceChannels
= rexCord.getClient().getConnectedVoiceChannels();
if (connectedVoiceChannels.size() == 0) {
rexCord.sendMessage(event.getChannel(),
rexCord.NOT_IN_VOICE_CHANNEL);
return;
}
AudioPlayer player
= AudioPlayer.getAudioPlayerForGuild(event.getGuild());
if (player.getPlaylistSize() >= 1) {
player.skip();
rexCord.sendMessage(event.getChannel(), "Skipped song.");
} else {
rexCord.sendMessage(event.getChannel(),
"There is nothing to skip.");
}
}
示例2: joinCommand
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Command(
command = "join",
alias = "join",
description = "The Bot joins voice Server",
arguments = {},
permission = "music_control",
prefix = Globals.MUSIC_PREFIX
)
public boolean joinCommand(MessageReceivedEvent event, String[] args) {
if (DRIVER.getPropertyOnly(DRIVER.CONFIG, "music_disabled_default").equals(false) || !SERVER_CONTROL.getDisabledlist(SERVER_CONTROL.MUSIC_MODULE).contains(event.getGuild().getStringID())) {
IVoiceChannel userVoiceChannel = event.getAuthor().getVoiceStateForGuild(event.getGuild()).getChannel();
if (userVoiceChannel == null)
return false;
userVoiceChannel.join();
this.volumeMusic(event, new String[]{DRIVER.getPropertyOnly(DRIVER.CONFIG, "defaultvolume").toString()});
return true;
} else {
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.getTranslation("disabledserver")), true);
return false;
}
}
示例3: leaveMusic
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Command(
command = "leave",
alias = "leave",
description = "The Bot leaves voice Server",
arguments = {},
permission = "music_control",
prefix = Globals.MUSIC_PREFIX
)
public boolean leaveMusic(MessageReceivedEvent event, String[] args) {
IVoiceChannel botVoiceChannel = event.getClient().getOurUser().getVoiceStateForGuild(event.getGuild()).getChannel();
if (botVoiceChannel == null) {
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.getTranslation("music_notinchannel_user")), true);
return false;
}
AudioPlayer audioP = AudioPlayer.getAudioPlayerForGuild(event.getGuild());
audioP.clear();
botVoiceChannel.leave();
return true;
}
示例4: playMusic
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Command(
command = "play",
alias = "play",
description = "The Bot plays the first song.",
arguments = {"Url or Path"},
permission = "music_control",
prefix = Globals.MUSIC_PREFIX
)
public boolean playMusic(MessageReceivedEvent event, String[] args) {
IVoiceChannel botVoiceChannel = event.getClient().getOurUser().getVoiceStateForGuild(event.getGuild()).getChannel();
if (botVoiceChannel == null) {
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.getTranslation("music_notinchannel")), true);
return false;
}
// Turn the args back into a string separated by space
String searchStr = args[0];
loadAndPlay(event.getChannel(), searchStr);
return true;
}
示例5: check
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
private synchronized void check(IGuild guild) {
IVoiceChannel botVoiceChannel = guild.getClient().getOurUser().getVoiceStateForGuild(guild).getChannel();
if(botVoiceChannel == null) {
return;
}
GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(guild.getLongID());
if(guildMusic == null) {
return;
}
if(this.isAlone(botVoiceChannel) && !guildMusic.isLeavingScheduled()) {
BotUtils.sendMessage(Emoji.INFO + " Nobody is listening anymore, music paused. I will leave the voice channel in 1 minute.", guildMusic.getChannel());
guildMusic.getScheduler().getAudioPlayer().setPaused(true);
guildMusic.scheduleLeave();
} else if(!this.isAlone(botVoiceChannel) && guildMusic.isLeavingScheduled()) {
BotUtils.sendMessage(Emoji.INFO + " Somebody joined me, music resumed.", guildMusic.getChannel());
guildMusic.getScheduler().getAudioPlayer().setPaused(false);
guildMusic.cancelLeave();
}
}
示例6: play
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
private void play(File source, IMessage message, Integer volume) {
try {
Optional<IVoiceChannel> voiceChannel = message.getAuthor().getConnectedVoiceChannels()
.stream().filter(v -> message.getGuild().equals(v.getGuild()))
.findAny();
if (voiceChannel.isPresent()) {
synchronized (lock) {
if (tryJoin(voiceChannel)) {
AudioPlayer player = AudioPlayer.getAudioPlayerForGuild(message.getGuild());
volumeMap.put(source.getName(), volume != null ? volume : 100);
player.queue(source);
}
}
}
} catch (UnsupportedAudioFileException | IOException e) {
log.warn("Unable to play sound bite", e);
}
}
示例7: runCommand
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Joins a a voice channel after being summoned
* @param event passed event
* @param args passed arguments
*/
@Override
public final void runCommand(MessageReceivedEvent event, String args) {
// The channel the user is in
IVoiceChannel userChannel = event.getAuthor()
.getVoiceStateForGuild(event.getGuild()).getChannel();
if (userChannel == null) {
rexCord.sendMessageWithBlock(event.getChannel(),
"User is not in a voice channel!");
return;
}
userChannel.join();
}
示例8: runCommand
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Pauses song in voice channel
* @param event passed event
* @param args passed arguments
*/
@Override
public final void runCommand(MessageReceivedEvent event, String args) {
List<IVoiceChannel> connectedVoiceChannels
= rexCord.getClient().getConnectedVoiceChannels();
if (connectedVoiceChannels.size() == 0) {
rexCord.sendMessage(event.getChannel(),
rexCord.NOT_IN_VOICE_CHANNEL);
return;
}
AudioPlayer player
= AudioPlayer.getAudioPlayerForGuild(event.getGuild());
if (player.getPlaylistSize() >= 1) {
player.togglePause();
//Sends corresponding message after pause state has changed
if (player.isPaused()) {
rexCord.sendMessage(event.getChannel(), "Paused song.");
} else {
rexCord.sendMessage(event.getChannel(), "Unpaused song.");
}
} else {
rexCord.sendMessage(event.getChannel(),
"There is not a song to pause.");
}
}
示例9: runCommand
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Leaves current voice channel
* @param event passed event
* @param args passed arguments
*/
@Override
public final void runCommand(MessageReceivedEvent event, String args) {
// The channel the bot is in
IVoiceChannel currentChannel = event.getClient().getOurUser()
.getVoiceStateForGuild(event.getGuild()).getChannel();
if (currentChannel == null) {
rexCord.sendMessageWithBlock(event.getChannel(),
"RexCord is not in a voice channel!");
return;
}
currentChannel.leave();
}
示例10: getBotVoiceChannel
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Gets RexCord's Voice Channel
* @param event triggered event
* @return IVoiceChannel
*/
public IVoiceChannel getBotVoiceChannel(MessageReceivedEvent event) {
return getClient()
.getOurUser()
.getVoiceStateForGuild(event.getGuild())
.getChannel();
}
示例11: getUserVoiceChannelInEvent
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
/**
* Returns the IVoiceChannel in which the user that
* triggered the event is in
* @param event triggered event
* @return user's IVoiceChannel
*/
public IVoiceChannel getUserVoiceChannelInEvent(MessageReceivedEvent
event) {
return event.getAuthor().getVoiceStateForGuild(event.getGuild())
.getChannel();
}
示例12: not_null_IVoiceChanel_then_IVoiceChanel_leave
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Test
public void not_null_IVoiceChanel_then_IVoiceChanel_leave() throws Exception {
// arrange
IVoiceChannel mockIVoiceChannel = mock(IVoiceChannel.class);
when(mockEvent.getClient().getOurUser().getVoiceStateForGuild(mockEvent.getGuild()).getChannel())
.thenReturn(mockIVoiceChannel);
// act
command.runCommand(mockEvent, "");
// assert
verify(rexCord, never()).sendMessageWithBlock(any(IChannel.class), anyString());
verify(mockIVoiceChannel).leave();
}
示例13: setUp
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
List<IVoiceChannel> voiceChannels = new ArrayList<>();
voiceChannels.add(mock(IVoiceChannel.class));
when(rexCord.getClient().getConnectedVoiceChannels()).thenReturn(voiceChannels);
when(mockEvent.getChannel()).thenReturn(mockIChannel);
}
示例14: not_null_IVoiceChanel_then_IVoiceChanel_join
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
@Test
public void not_null_IVoiceChanel_then_IVoiceChanel_join() throws Exception {
// arrange
IVoiceChannel mockIVoiceChannel = mock(IVoiceChannel.class);
when(mockEvent.getAuthor().getVoiceStateForGuild(mockEvent.getGuild()).getChannel())
.thenReturn(mockIVoiceChannel);
// act
command.runCommand(mockEvent, "");
// assert
verify(rexCord, never()).sendMessageWithBlock(any(IChannel.class), anyString());
verify(mockIVoiceChannel).join();
}
示例15: AudioLoadResultListener
import sx.blah.discord.handle.obj.IVoiceChannel; //导入依赖的package包/类
public AudioLoadResultListener(GuildMusic guildMusic, IUser userDj, IVoiceChannel userVoiceChannel, String identifier, boolean putFirst) {
this.guildMusic = guildMusic;
this.userDj = userDj;
this.userVoiceChannel = userVoiceChannel;
this.identifier = identifier;
this.putFirst = putFirst;
}