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


Java MessageChannel类代码示例

本文整理汇总了Java中net.dv8tion.jda.core.entities.MessageChannel的典型用法代码示例。如果您正苦于以下问题:Java MessageChannel类的具体用法?Java MessageChannel怎么用?Java MessageChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessageChannel类属于net.dv8tion.jda.core.entities包,在下文中一共展示了MessageChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
	if(!AudioPlayerThread.isPlaying()) {
		channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
		return;
	}

	int seconds;
	if(arg == null) {
		seconds = 10;
	} else {
		try {
			seconds = Integer.parseInt(arg);
			if(seconds == 0) {
				throw new NumberFormatException();
			}
		} catch(NumberFormatException e) {
			channel.sendMessage(author.getAsMention() +  " ``Invalid number``").queue();
			return;
		}
	}

	AudioTrack track = AudioPlayerThread.getMusicManager().player.getPlayingTrack();
	track.setPosition(track.getPosition() + (1000*seconds)); // Lavaplayer handles values < 0 or > track length
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:26,代码来源:Jump.java

示例2: doYaThing

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 1) {
            message.delete().complete();
            String whatToSay = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1);
            channel.sendMessage(whatToSay.substring(0, 1).toUpperCase() + whatToSay.substring(1) + ".").complete();
        } else {
            channel.sendMessage(getUsage()).complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:19,代码来源:Speak.java

示例3: doYaThing

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    User author = message.getAuthor();
    try {
        BufferedImage avatar = ReadImage.readImageFromURL(author.getAvatarUrl());
        BufferedImage triggered = ReadImage.readImageFromDisk("triggered.jpg");
        DrawOnImg.drawImg(avatar, triggered, 0, avatar.getHeight() - 20, avatar.getWidth(), 20);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(avatar, "png", baos);
        channel.sendFile(baos.toByteArray(), "triggered.png", null).complete();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:18,代码来源:Triggered.java

示例4: onGuildMemberJoin

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
    WelcomeMessage message = welcomeMessageRepository.findByGuild(event.getGuild());
    if (message == null || !message.isJoinEnabled() || (!message.isJoinToDM() && message.getJoinChannelId() == null)) {
        return;
    }

    MessageChannel channel = null;
    if (message.isJoinToDM() && !event.getJDA().getSelfUser().equals(event.getUser())) {
        User user = event.getUser();
        try {
            channel = user.openPrivateChannel().complete();
        } catch (Exception e) {
            LOGGER.error("Could not open private channel for user {}", user, e);
        }
    }
    if (channel == null) {
        channel = event.getGuild().getTextChannelById(message.getJoinChannelId());
    }
    send(event, channel, message.getJoinMessage(), message.isJoinRichEnabled());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:22,代码来源:WelcomeUserListener.java

示例5: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();
    if (hasPermission(author)) {
        //toggle command
        Boolean delCmd = !dbMan.getDeleteCommand(guildID);
        try {
            dbMan.setDeleteCommand(guildID, delCmd);
            if (!delCmd) {
                message.addReaction(":heavy_check_mark:").queue();
            }
        } catch (SQLException e) {
            channel.sendMessage(localize(channel, "command.toggle_delete.error.sql")).queue();
        }


    }

}
 
开发者ID:IANetworks,项目名称:Ducky-Mc-Duckerson,代码行数:20,代码来源:DeleteCommandCS.java

示例6: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();

    if (!dbMan.isWerewolfOn(guildID)) {
        //Werewolf is turned off for this guild, so ignore the command
        return;
    }

    if (hasPermission(author)) {
        //check to make sure that we're in a gamestarted state
        GameState gs = ww.getWerewolfGameState(guildID);
        if (gs != null && gs == GameState.GAMESTART) {
            ww.joinGame(guildID, author);
        }
    }
}
 
开发者ID:IANetworks,项目名称:Ducky-Mc-Duckerson,代码行数:18,代码来源:WerewolfJoinCS.java

示例7: doYaThing

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    EmbedBuilder embMsg = new EmbedBuilder();
    try {
        embMsg.setTitle("About DodoBot", "https://github.com/ExidCuter/JDodoBot");
        embMsg.setThumbnail("https://pbs.twimg.com/profile_images/932637770874589186/KgP5zJjH_400x400.jpg");
        embMsg.setColor(new Color(0x13FF00));
        embMsg.addField("Version", ver, true);
        embMsg.addField("By", "Dodo Dodović", true);
        embMsg.addField("Servers", Integer.toString(getNumOfServers()), true);
        embMsg.addField("GitHub", "https://github.com/ExidCuter/JDodoBot", false);
        embMsg.addField("Donate", " https://www.paypal.me/DodoDodovic", false);
        channel.sendMessage(embMsg.build()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:20,代码来源:About.java

示例8: sendHelpMessage

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
private void sendHelpMessage(MessageChannel channel) {
    channel.sendMessage(
            new EmbedBuilder()
                    .setColor(new Color(22, 138, 233))
                    .setDescription("__**WINNING OPTIONS FOR SLOT MACHINE**__\n`" + "slot <money> - 3 of a kind wins!`\n\n\n")

                    .addField("Winning multiplicator: x2",
                            ":bell: :football: :soccer: :8ball: :green_apple: :lemon: :strawberry: :watermelon:",  false)

                    .addField("Winning multiplicator: x3",
                            ":heart: :yellow_heart: :blue_heart: :green_heart:",  false)

                    .addField("Winning multiplicator: x5",
                            ":star2: :zap:",  false)

                    .addField("Winning multiplicator: x8",
                            ":diamonds:",  false)

                    .build()
    ).queue();
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:22,代码来源:CommandSlot.java

示例9: cleanUpRaidGroupAndDeleteSignUpsIfPossible

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
public static void cleanUpRaidGroupAndDeleteSignUpsIfPossible(MessageChannel messageChannel,
                                                              LocalDateTime startAt, String raidId,
                                                              EmoticonSignUpMessageListener emoticonSignUpMessageListener,
                                                              RaidRepository raidRepository,
                                                              BotService botService, String groupId) {
    Raid raid = null;
    try {
        if (startAt != null && raidId != null) {
            // Clean up all signups that should have done their raid now, if there still is a time
            // (Could be set to null due to an error, in that case keep signups in database)
            raid = raidRepository.removeAllSignUpsAt(raidId, startAt);
        }
    } catch (Throwable t) {
        // Do nothing, just log
        LOGGER.warn("Exception occurred when removing signups: " + t + "-" + t.getMessage());
        if (t instanceof ConcurrentModificationException) {
            LOGGER.warn("This is probably due to raid being removed while cleaning up signups, which is normal.");
        }
    } finally {
        final String raidDescription = raid == null ? "null" : raid.toString();
        cleanUpGroupMessageAndEntity(messageChannel, raidId, emoticonSignUpMessageListener, raidRepository,
                botService, groupId, raidDescription);
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:25,代码来源:NewRaidGroupCommand.java

示例10: action

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
if (core.permissionHandler.check(4,event)) return;
    MessageChannel channel = event.getChannel();
    channel.sendTyping().queue();
    event.getMessage().delete().queue();

    util.embedSender.sendEmbed(":battery: System Restarting!", channel, Color.GREEN);

    //Code by ZekroTJA(github.com/ZekroTJA)
    if (System.getProperty("os.name").toLowerCase().contains("linux"))
        Runtime.getRuntime().exec("screen python restart.py");

    System.exit(0);

}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:17,代码来源:Restart.java

示例11: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
	if(!AudioPlayerThread.isPlaying()) {
		channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
		return;
	}

	int skips;
	if (arg == null) {
		skips = 1;
	} else {
		try {
			skips = Integer.parseInt(arg);
			if (skips < 1) {
				throw new NumberFormatException();
			}
		} catch (NumberFormatException e) {
			channel.sendMessage(author.getAsMention() + " ``Invalid number``").queue();
			return;
		}
	}

	AudioPlayerThread.getMusicManager().scheduler.nextTrack(skips);
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:25,代码来源:Next.java

示例12: assertAllParametersOk

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
private static void assertAllParametersOk(MessageChannel channel, Config config, User user, Locale locale,
                                          LocalTime startAtTime, String raidId, LocaleService localeService,
                                          RaidRepository raidRepository, BotService botService,
                                          ServerConfigRepository serverConfigRepository,
                                          PokemonRepository pokemonRepository, GymRepository gymRepository,
                                          ClockService clockService, ExecutorService executorService) {
    Validate.notNull(channel, "Channel");
    Validate.notNull(config, "config");
    Validate.notNull(user, "User");
    Validate.notNull(locale, "Locale");
    Validate.notNull(startAtTime, "StartAtTime");
    Validate.notNull(localeService, "LocaleService");
    Validate.notNull(raidRepository, "RaidRepository");
    Validate.notNull(botService, "BotService");
    Validate.notNull(serverConfigRepository, "ServerConfigRepository");
    Validate.notNull(pokemonRepository, "PokemonRepository");
    Validate.notNull(gymRepository, "GymRepository");
    Validate.notNull(clockService, "ClockService");
    Validate.notNull(executorService, "ExecutorService");
    Validate.notEmpty(raidId, "Raid ID");
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:22,代码来源:NewRaidGroupCommand.java

示例13: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的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

示例14: execute

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void execute(User user, CommandContext args, MessageChannel channel) {
    String code = (String) args.getOne("code").get();
    //link successful
    if (this.bot.getCodes().containsKey(code)) {
        org.spongepowered.api.entity.living.player.User spongeUser = Sponge.getServiceManager().provideUnchecked(UserStorageService.class)
                .get(bot.getCodes().get(code)).get();
        spongeUser.getSubjectData().setOption(SubjectData.GLOBAL_CONTEXT, "discord-user", user.getId());

        AccountConfigData data = (AccountConfigData) this.phonon.getAllConfigs().get(AccountConfigData.class);
        data.getAccounts().put(user.getId(), spongeUser.getUniqueId());
        data.save();

        channel.sendMessage("You have successfully linked " + user.getName() + "#" +user.getDiscriminator()
                + " to " + spongeUser.getName()).queue();
    } else {
        channel.sendMessage("That is not a valid code!").queue();
    }

}
 
开发者ID:NucleusPowered,项目名称:Phonon,代码行数:21,代码来源:ConfirmAccountLinkCommand.java

示例15: doYaThing

import net.dv8tion.jda.core.entities.MessageChannel; //导入依赖的package包/类
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    try {
        String helpVoice = "join [name]  - Joins a voice channel that has the provided name\njoin [id]    - Joins a voice channel based on the provided id.\nleave        - Leaves the voice channel that the bot is currently in.\nplay         - Plays songs from the current queue. Starts playing again if it was previously paused\nplay [url]   - Adds a new song to the queue and starts playing if it wasn't playing already\npplay        - Adds a playlist to the queue and starts playing if not already playing\npause        - Pauses audio playback\nstop         - Completely stops audio playback, skipping the current song.\nskip         - Skips the current song, automatically starting the next\nnowplaying   - Prints information about the currently playing song (title, current time)\nnp           - alias for nowplaying\nlist         - Lists the songs in the queue\nvolume [val] - Sets the volume of the MusicPlayer [10 - 100]\nrestart      - Restarts the current song or restarts the previous song if there is no current song playing.\nrepeat       - Makes the player repeat the currently playing song\nreset        - Completely resets the player, fixing all errors and clearing the queue.\n";
        channel.sendMessage("```Voice Commands:  \n" + helpVoice + "```").complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:12,代码来源:HelpMusic.java


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