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


Java IChannel.setTypingStatus方法代码示例

本文整理汇总了Java中sx.blah.discord.handle.obj.IChannel.setTypingStatus方法的典型用法代码示例。如果您正苦于以下问题:Java IChannel.setTypingStatus方法的具体用法?Java IChannel.setTypingStatus怎么用?Java IChannel.setTypingStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sx.blah.discord.handle.obj.IChannel的用法示例。


在下文中一共展示了IChannel.setTypingStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
    if (args.length == 0) {
        MessageUtils.sendMessage("Usage: _load [NAME]", channel);
        return;
    }
    String name = "";
    for (String arg : args) name += arg + ' ';
    name = name.trim();
    channel.setTypingStatus(true);
    try {
        String finalName = name;
        SQLController.runSqlTask(connection -> {
            connection.createStatement().execute("CREATE TABLE IF NOT EXISTS playlist (\n" +
                    "  name  VARCHAR(60),\n" +
                    "  guild VARCHAR(20),\n" +
                    "  list  TEXT,\n" +
                    "  PRIMARY KEY(name, guild)\n" +
                    ")");
            PreparedStatement exists = connection.prepareStatement("SELECT list FROM playlist WHERE name = ? AND guild = ?");
            exists.setString(1, finalName);
            exists.setString(2, channel.getGuild().getID());
            exists.execute();
            ResultSet set = exists.getResultSet();
            if (set.isBeforeFirst()) {
                set.next();
                VideoThread.getThread(finalName + '\u200B' + set.getString("list"), channel, sender).start();
            } else
                MessageUtils.sendMessage(MessageUtils.getEmbed(sender).withDesc("*That playlist does not exist!*").build(), channel);
        });
    } catch (SQLException e) {
        MessageUtils.sendException("**Database error!**", e, channel);
        FlareBot.LOGGER.error("Database error!", e);
    }
}
 
开发者ID:ArsenArsen,项目名称:FlareBot,代码行数:36,代码来源:LoadCommand.java

示例2: onCommand

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
    if (args.length == 0) {
        MessageUtils.sendMessage("Usage: _delete [NAME]", channel);
        return;
    }
    String name = "";
    for (String arg : args) name += arg + ' ';
    name = name.trim();
    channel.setTypingStatus(true);
    try {
        String finalName = name;
        SQLController.runSqlTask(connection -> {
            connection.createStatement().execute("CREATE TABLE IF NOT EXISTS playlist (\n" +
                    "  name VARCHAR(10),\n" +
                    "  guild VARCHAR(10),\n" +
                    "  list VARCHAR(80),\n" +
                    "  PRIMARY KEY(name, guild)\n" +
                    ")");
            PreparedStatement update = connection.prepareStatement("DELETE FROM playlist WHERE name = ? AND guild = ?");
            update.setString(1, finalName);
            update.setString(2, channel.getGuild().getID());
            if (update.executeUpdate() > 0) {
                MessageUtils.sendMessage(MessageUtils.getEmbed(sender).withDesc(String.format("*Removed the playlist %s*", finalName))
                        .build(), channel);
            } else MessageUtils.sendMessage(MessageUtils.getEmbed(sender)
                    .withDesc(String.format("*The playlist %s never existed!", finalName))
                    .build(), channel);
        });
    } catch (SQLException e) {
        MessageUtils.sendException("**Database error!**", e, channel);
    }
}
 
开发者ID:ArsenArsen,项目名称:FlareBot,代码行数:34,代码来源:DeleteCommand.java

示例3: process

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public void process(CommandContext ctx) throws CommandException {
    if (ctx.getArgs().size() < 1) {
        if (waiting && !confirmed) {
            confirmed = true;
            blockedThread.interrupt();
            return;
        } else {
            throw new CommandException("Invalid number of arguments.");
        }
    }
    
    IChannel channel = ctx.getChannel();
    IMessage confirmation = ctx.reply("This will kick and delete messages for the last 24 hrs! Say `!kickclear` again to confirm.");
    blockedThread = Thread.currentThread();
    waiting = true;
    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        // ignore, confirmation has occurred
    }
    waiting = false;
    blockedThread = null;
    
    try {
        if (confirmed) {
            channel.setTypingStatus(true);
            for (IUser user : ctx.getMessage().getMentions()) {
                channel.getGuild().kickUser(user);
                List<IMessage> toDelete = channel.getMessageHistoryTo(LocalDateTime.now().minus(Duration.ofDays(1))).stream()
                        .filter(m -> m.getAuthor().getLongID() == user.getLongID())
                        .collect(Collectors.toList());
                if (!toDelete.isEmpty()) {
                    channel.bulkDelete(toDelete);
                }
            }
        }

        ctx.getMessage().delete();
        confirmation.delete();
        if (confirmed) {
            IMessage msg = ctx.reply("Cleared and kicked user(s).");
            Threads.sleep(5000);
            msg.delete();
        }
    } finally {
        // Avoid state corruption by exception
        confirmed = false;
    }
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:51,代码来源:CommandKickClear.java

示例4: onCommand

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
    if (args.length == 0) {
        MessageUtils.sendMessage("Usage: _save [NAME]", channel);
        return;
    }
    String name = "";
    for (String arg : args) name += arg + ' ';
    name = name.trim();
    if (name.length() > 20) {
        MessageUtils.sendMessage("Name must be up to 20 characters!", channel);
        return;
    }
    if (!FlareBot.getInstance().getMusicManager().hasPlayer(channel.getGuild().getID())) {
        MessageUtils.sendMessage("Your playlist is empty!", channel);
        return;
    }
    Queue<Track> playlist = FlareBot.getInstance().getMusicManager().getPlayer(channel.getGuild().getID()).getPlaylist();
    if (playlist.isEmpty()) {
        MessageUtils.sendMessage("Your playlist is empty!", channel);
        return;
    }
    channel.setTypingStatus(true);
    try {
        String finalName = name;
        SQLController.runSqlTask(connection -> {
            connection.createStatement().execute("CREATE TABLE IF NOT EXISTS playlist (\n" +
                    "  name  VARCHAR(60),\n" +
                    "  guild VARCHAR(20),\n" +
                    "  list  TEXT,\n" +
                    "  PRIMARY KEY(name, guild)\n" +
                    ")");
            PreparedStatement exists = connection.prepareStatement("SELECT * FROM playlist WHERE name = ? AND guild = ?");
            exists.setString(1, finalName);
            exists.setString(2, channel.getGuild().getID());
            exists.execute();
            if (exists.getResultSet().isBeforeFirst()) {
                MessageUtils.sendMessage("That name is already taken!", channel);
                return;
            }
            PreparedStatement statement = connection.prepareStatement("INSERT INTO playlist (name, guild, list) VALUES (" +
                    "   ?," +
                    "   ?," +
                    "   ?" +
                    ")");
            statement.setString(1, finalName);
            statement.setString(2, channel.getGuild().getID());
            statement.setString(3, playlist.stream()
                    .map(track -> track.getTrack().getIdentifier())
                    .collect(Collectors.joining(",")));
            statement.executeUpdate();
            MessageUtils.sendMessage(MessageUtils.getEmbed(sender).withDesc("Success!").build(), channel);
        });
    } catch (SQLException e) {
        MessageUtils.sendException("**Database error!**", e, channel);
        FlareBot.LOGGER.error("Database error!", e);
    }
}
 
开发者ID:ArsenArsen,项目名称:FlareBot,代码行数:59,代码来源:SaveCommand.java


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