本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}