本文整理汇总了Java中net.dv8tion.jda.core.entities.ChannelType类的典型用法代码示例。如果您正苦于以下问题:Java ChannelType类的具体用法?Java ChannelType怎么用?Java ChannelType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelType类属于net.dv8tion.jda.core.entities包,在下文中一共展示了ChannelType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commandParser
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
public static Optional<Scanner> commandParser(Message message) {
boolean pm = message.getChannelType().equals(ChannelType.PRIVATE);
if (!botMentioned(message) && !pm) {
return Optional.empty();
}
Scanner scanner = new Scanner(message.getContent());
if (pm) {
// skip the bot prefix if used
if (scanner.hasNext(BotConfig.getConfig().PREFIX)) {
scanner.next();
}
System.out.println("Mentioned with prefix: " + "private message");
} else {
String botPrefix = scanner.next();
System.out.println("Mentioned with prefix: " + botPrefix);
}
return Optional.of(scanner);
}
示例2: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
channel.sendMessage(author.getAsMention() + " **Commands:**\n"
+ "```"
+ "!list (Show the playlist)\n"
+ "!play <file or link> (Play given track now)\n"
+ "!add <file, folder or link> (Add given track to playlist)\n"
+ "!search <youtube video title> (Plays the first video that was found)\n"
+ "!save <name> (Save the current playlist)\n"
+ "!load <name> (Load a saved playlist)\n"
+ "!lists (List the saved playlists)\n"
+ "!pause (Pause or resume the current track)\n"
+ "!stop (Stop the playback and clear the playlist)\n"
+ "!volume (Change the playback volume)\n"
+ "!next (<how many songs>) (Skip one or more songs from the playlist)\n"
+ "!seek <hours:minutes:seconds> (Seek to the specified position)\n"
+ "!jump (<how many seconds>) (Jump forward in the current track)\n"
+ "!repeat (<how many times>) (Repeat the current playlist)\n"
+ "!shuffle (Randomize the track order)\n"
+ "!loop (Re add played track to the end of the playlist)\n"
+ "!uptime (See how long the bot is already online)\n"
+ "!about (Print about message)\n"
+ "!kill (Kill the bot)"
+ "```"
+ (channel.getType() == ChannelType.PRIVATE ? ("\n**Guild:** " + guild.getName()) : "") ).queue();
}
示例3: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.connectToVoiceChat(event.getGuild().getAudioManager(), event.getMember());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " Please connect in a voice channel first");
} else {
event.replySuccess("Connected");
}
}
示例4: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (!Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.getQueue().isEmpty()) {
Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.shuffleQueue();
event.reactSuccess();
}else{
event.reply("The queue is empty, there is nothing to shuffle");
}
}else{
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例5: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (Constant.music.getGuildAudioPlayer(event.getGuild()).player.getPlayingTrack() != null) {
Constant.nowPlayingList.get(event.getGuild().getId()).resendNowPlaying();
} else {
event.replyWarning("I'm not playing anything");
}
}else{
event.replyError(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例6: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
String id = null;
if (event.isFromType(ChannelType.TEXT)) {
id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (!event.getArgs().isEmpty()) {
Constant.music.loadAndPlay(event);
if (id != null) {
if (!Constant.nowPlayingList.containsKey(event.getGuild().getId())) {
new NowPlaying(event.getGuild(), Constant.music);
}
}
} else {
event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
}
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例7: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (!event.getArgs().isEmpty()) {
if (event.getGuild().getAudioManager().isConnected()) {
String cc = "ytsearch:" + event.getArgs();
Constant.music.loadAndPlaySearch(event, waiter, cc);
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
} else {
event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
}
}
示例8: execute
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.disconnectFromVoiceChat(event.getGuild().getAudioManager());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
} else {
event.replySuccess("Disconnected");
}
}
示例9: GameBotCommand
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
public GameBotCommand() {
this.name = "gamebot";
this.aliases = new String[]{"gb"};
this.help = "type " + Constant.prefix + "gameBot help";
this.helpBiConsumer = (CommandEvent event, Command command) -> {
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN);
builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getAvatarUrl());
builder.setTitle("The \"Game Bot\" Feature");
builder.setDescription("The \"Game Bot\" feature is quite simple:");
builder.addField("1.", "If you're playing a game, you just have to go in the server's game channel and react with :ok: in the bot channel", false);
builder.addField("2.", "After that you'll be moved in a channel with the name of your game", false);
builder.addField("3.", "If you leave the channel, it will automatically delete the channel", false);
builder.setImage(Constant.gameBotExampleUrl);
event.reply(builder.build());
};
this.guildOnly = false;
this.ownerCommand = false;
}
示例10: onMessageReceived
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent messageReceivedEvent) {
input = new Input(messageReceivedEvent);
output = new Output(input);
String msg = input.getRawContent().toLowerCase();
boolean canHandleMessages = !input.getAuthor().isBot();
boolean isCommandForBot = (msg.startsWith(Main.bot.getPrefix().toLowerCase())) || (msg
.startsWith(Main.bot.getDefaultPrefix().toLowerCase())) || (msg
.startsWith(input.getJDA().getSelfUser().getAsMention()))
|| (input.isFromType(ChannelType.PRIVATE)) && canHandleMessages;
if (isCommandForBot) {
commandHandler.execute(input, output);
}
}
示例11: sendCommandHelp
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
private void sendCommandHelp(Input input, Output output) {
SecureRandom r = new SecureRandom();
Command command = CommandUtils.getCommand(input.getArgument(0));
Message commandHelpEmbed = createEmbed(command.getSettings().getEmbedColor(),
"Help: " + command.getSettings().getName(),
"**Category:** `" + command.getSettings().getCategory() + "`\n**Usage:** `" + command
.getSettings()
.getHelp() + "`\n**Description:** `" + command
.getSettings().getDescription() + "`");
if (input.isFromType(ChannelType.TEXT)) {
output.sendMessage("Sent you a DM. " + emojis[r.nextInt(emojis.length)]);
output.sendPrivateMessage(commandHelpEmbed);
} else {
output.sendMessage(commandHelpEmbed);
}
}
示例12: onMessageReceived
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent e) {
String[] syntax = e.getMessage().getContent().split(" ");
//Never respond to a bot!
if (e.getAuthor().isBot())
return;
//Not the `CMD` command
if (!syntax[0].equalsIgnoreCase(PREFIX + "CMD")) {
return;
}
//If `CMD` command was received from a non-TextChannel, inform command is Guild-only
if (!e.isFromType(ChannelType.TEXT)) {
e.getChannel().sendMessage(ERROR_GUILDS).queue();
return;
}
receivedcmd++;
e.getMessage().delete().queue();
executedcmd++;
}
示例13: onMessageReceived
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent event) {
boolean self = event.getAuthor().equals(mcb.getBot().getJda().getSelfUser());
boolean blocked = prefixIsBlocked(event.getMessage().getContent()) || botIsBlocked(event.getAuthor().getId());
if (self || blocked)
return;
switch (channelType) {
case MOD_CHANNEL:
if (isModChannel(event.getTextChannel()))
execute(event);
break;
case BOUND_CHANNEL:
if (isRelayChannel(event.getTextChannel()))
execute(event);
break;
case DEFAULT_CHANNEL:
execute(event);
break;
case PRIVATE_CHANNEL:
if (event.getChannelType() == ChannelType.PRIVATE)
execute(event);
break;
}
}
示例14: TempChannel
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
public TempChannel(MessageReceivedEvent e) {
if (e.isFromType(ChannelType.PRIVATE)) {
e.getAuthor().getPrivateChannel()
.sendMessage("Error: !temp may not be used in a private channel.");
return;
}
this.event = e;
messageChannel = e.getTextChannel();
if(!PermissionUtil.checkPermission(e.getGuild(), e.getGuild().getSelfMember(), Permission.MANAGE_CHANNEL)) {
return;
}
if (TEMP_NUMBER >= TEMP_MAX) {
messageChannel.sendMessage("The maximum number of temporary voice channels is already reached.");
return;
}
this.voiceChannel = createChannel();
startTimer();
}
示例15: onCommand
import net.dv8tion.jda.core.entities.ChannelType; //导入依赖的package包/类
@Override
public void onCommand(MessageReceivedEvent e, String[] args) {
if (e.isFromType(ChannelType.PRIVATE)) {
SendMessage.sendMessage(e, "Error: Cannot set prefix in private message.");
return;
}
if (args.length == 2) {
SettingsManager.getInstance(e.getGuild().getId()).getSettings().setPrefix(args[1]);
SettingsManager.getInstance(e.getGuild().getId()).saveSettings();
SendMessage.sendMessage(e, "Set prefix for " + e.getGuild().getName() + " to \"" + args[1] + "\".");
}
else {
SendMessage.sendMessage(e, "Error: Incorrect usage. Prefix must not contain spaces.");
}
}