当前位置: 首页>>代码示例>>Java>>正文


Java ChannelType类代码示例

本文整理汇总了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);
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:19,代码来源:CommandUtils.java

示例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();
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:27,代码来源:Help.java

示例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");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:18,代码来源:SummonCommand.java

示例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:");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:22,代码来源:ShuffleCommand.java

示例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:");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:21,代码来源:NowPlayingCommand.java

示例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:");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:27,代码来源:PlayCommand.java

示例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");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:22,代码来源:SearchCommand.java

示例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");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:18,代码来源:DisconnectCommand.java

示例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;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:20,代码来源:GameBotCommand.java

示例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);
  }
}
 
开发者ID:Svetroid,项目名称:Hobbes-v1,代码行数:18,代码来源:BotListener.java

示例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);
  }
}
 
开发者ID:Svetroid,项目名称:Hobbes-v1,代码行数:17,代码来源:Help.java

示例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++;
}
 
开发者ID:Sanduhr32,项目名称:Uselessbot,代码行数:25,代码来源:Pub.java

示例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;
    }
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:25,代码来源:TextChannelListener.java

示例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();
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:23,代码来源:TempChannel.java

示例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.");
	}
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:17,代码来源:PrefixCommand.java


注:本文中的net.dv8tion.jda.core.entities.ChannelType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。