本文整理匯總了Java中net.dv8tion.jda.core.entities.Message類的典型用法代碼示例。如果您正苦於以下問題:Java Message類的具體用法?Java Message怎麽用?Java Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Message類屬於net.dv8tion.jda.core.entities包,在下文中一共展示了Message類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: action
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public void action(String head, String[] args, MessageReceivedEvent event)
{
AccountManagerUpdatable manager = Main.getShardManager().getJDA().getSelfUser().getManagerUpdatable();
if(event.getMessage().getAttachments().isEmpty()) return;
Message.Attachment attachment = event.getMessage().getAttachments().get(0);
try
{
File file = new File(attachment.getFileName());
attachment.download(file);
Icon icon = Icon.from(file);
manager.getAvatarField().setValue(icon).update().complete();
MessageUtilities.sendPrivateMsg("Updated bot avatar!", event.getAuthor(), null);
file.delete();
}
catch (IOException e)
{
Logging.exception(this.getClass(), e);
MessageUtilities.sendPrivateMsg("Failed to update bot avatar!", event.getAuthor(), null);
}
}
示例2: shutdown
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@SuppressWarnings("static-access")
public static void shutdown(Message m, User u) {
//Disable JDA
for (JDA jda : shards) {
jda.setAutoReconnect(false);
jda.removeEventListener(listener);
}
try {
//Reload this class using reflection
Class<?> main = Thread.currentThread().getContextClassLoader().getSystemClassLoader()
.loadClass(mainClass);
String[] args = new String[]{"-r"};
ArrayUtils.addAll(args, Bot.args);
main.getDeclaredMethods()[MethodName.SET_MESSAGE.num].invoke(null, m);
main.getDeclaredMethods()[MethodName.SET_USER.num].invoke(null, u);
main.getDeclaredMethods()[MethodName.LOAD.num].invoke(null, (Object) args);
} catch (Exception ex) {
ex.printStackTrace();
}
//Stop the thread
thread.interrupt();
}
示例3: run
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
Message message = event.getMessage();
TextChannel channel = event.getChannel();
JDA shard = event.getJDA();
if (!embedHasAvatarURL) {
embedBuilder.setAuthor("Safety Jim", null, shard.getSelfUser().getAvatarUrl());
embed = embedBuilder.build();
embedHasAvatarURL = true;
}
DiscordUtils.successReact(bot, message);
DiscordUtils.sendMessage(channel, embed);
return false;
}
示例4: execute
import net.dv8tion.jda.core.entities.Message; //導入依賴的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();
}
}
}
示例5: removeCustomPrefix
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
private boolean removeCustomPrefix(Message message, GuildTransformer transformer, Category category) {
transformer.getPrefixes().remove(category.getName().toLowerCase());
try {
updateGuildPrefixes(message, transformer);
MessageFactory.makeSuccess(message, "All commands in the `:category` command category has been reset to use the `:prefix` prefix.")
.set("category", category.getName())
.set("prefix", category.getPrefix())
.queue();
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
示例6: sendCurrentAutoRole
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
private PlaceholderMessage sendCurrentAutoRole(Message message, GuildTransformer transformer) {
if (transformer.getAutorole() == null) {
return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**.");
}
Role role = message.getGuild().getRoleById(transformer.getAutorole());
if (role == null) {
try {
updateAutorole(transformer, message, null);
} catch (SQLException ex) {
ex.printStackTrace();
AvaIre.getLogger().error(ex.getMessage(), ex);
}
return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**.");
}
return MessageFactory.makeSuccess(message, ":user The **auto assign role** is currently set to **:role**")
.set("role", role.getName());
}
示例7: groupRemove
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
private static void groupRemove(Scanner scanner, Message message) {
Optional<StockTypeGroup> groupOpt = getTargetGroup(scanner, message, "REMOVE");
if (groupOpt.isPresent()) {
List<StockType> stockTypes = getTargetStockTypes(scanner, message, "REMOVE");
StockTypeGroup group = groupOpt.get();
if (!stockTypes.isEmpty()) {
List<StockType> types = group.getTypes();
if (types == null) {
group.setTypes(new ArrayList<>());
}
group.getTypes().removeAll(stockTypes);
getStockTypeGroupDao().update(group);
message.addReaction(Speaker.Reaction.SUCCESS).queue();
}
}
}
示例8: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入依賴的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) {
for (Submission s : RedditHandler.getPosts(commandNParameters[1], 2)) {
channel.sendMessage("https://www.reddit.com" + s.getPermalink()).complete();
}
} else
channel.sendMessage("```" + prefix + usage + "```").complete();
} catch (Exception e) {
System.out.println(e.getMessage());
channel.sendMessage("```" + e.getMessage() + "```").complete();
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例9: handle
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
if (args.length == 1) {
printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
return;
}
String msg = message.getRawContent();
String mention = kyoko.getJda().getSelfUser().getAsMention();
if (msg.startsWith(mention)) {
msg = msg.substring(mention.length()).trim().substring(args[0].length());
} else {
msg = msg.substring(kyoko.getSettings().getPrefix().length() + args[0].length());
}
if (msg.trim().isEmpty()) {
printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
return;
}
message.getTextChannel().sendMessage(msg).queue();
}
示例10: execute
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.getArgs();
Message message = parsedCommandInvocation.getMessage();
Message mymsg = message.getTextChannel().sendMessage(EmbedUtil.info("Generating", "Generating QR cde").build()).complete();
if(args.length > 0){
StringBuilder text = new StringBuilder();
for(int i = 0; i < args.length; i++){
text.append(args[i]).append(" ");
}
try {
InputStream code = new URL("https://api.qrserver.com/v1/create-qr-code/?data=" + text.toString().replace(" ", "+") + "&size=220x220&margin=0").openStream();
mymsg.delete().queue();
message.getTextChannel().sendFile(code, "qrcode.png", null).queue();
} catch (IOException e) {
e.printStackTrace();
}
} else {
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "qr <text>").build()).build();
}
return null;
}
示例11: onCommand
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public boolean onCommand(Message message, String[] args) {
GuildMusicManager musicManager = AudioHandler.getGuildAudioPlayer(message.getGuild());
if (musicManager.getPlayer().getPlayingTrack() == null) {
return sendErrorMessage(message, "Nothing to pause, request music first with `!play`");
}
if (musicManager.getPlayer().isPaused()) {
MessageFactory.makeWarning(message, "The music is already paused, use `!resume` to resume the music.").queue();
return true;
}
musicManager.getPlayer().setPaused(true);
MessageFactory.makeSuccess(message, "The music has been `paused`").queue();
return true;
}
示例12: handle
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public boolean handle(Message message, MiddlewareStack stack, String... args) {
if (!message.getChannelType().isGuild()) {
return stack.next();
}
if (message.getMember().hasPermission(Permissions.ADMINISTRATOR.getPermission())) {
return stack.next();
}
List<Role> roles = message.getMember().getRoles();
for (String roleName : args) {
if (!hasRole(roles, roleName)) {
MessageFactory.makeError(message, "You don't have the required role to execute this command:\n`:role`")
.set("role", roleName)
.queue();
return false;
}
}
return stack.next();
}
示例13: onCommand
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public boolean onCommand(Message message, String[] args) {
if (args.length == 0) {
return sendErrorMessage(message, "Missing argument `ip`, you must include a valid IP address.");
}
if (!urlRegEX.matcher(args[0]).find()) {
return sendErrorMessage(message, "Invalid IP address given, you must parse a valid IP address.");
}
RequestFactory.makeGET("http://ipinfo.io/" + args[0] + "/json").send((Consumer<Response>) response -> {
JSONObject json = new JSONObject(response.toString());
MessageFactory.makeEmbeddedMessage(message.getChannel(), Color.decode("#005A8C"),
new MessageEmbed.Field("Hostname", json.has("hostname") ? json.getString("hostname") : "Unknown", true),
new MessageEmbed.Field("Organisation", json.has("org") ? json.getString("org") : "Unknown", true),
new MessageEmbed.Field("Country", generateLocation(json), false)
).setTitle(args[0]).setFooter(generateFooter(message), null).queue();
});
return true;
}
示例14: unregisterListener
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
public static boolean unregisterListener(Message message, boolean removeReactions) {
if (message == null) {
return false;
}
final Map<AdvancedEmote, ReactionContainer> containers = MESSAGE_REACTION_LISTENERS.get(message);
if (containers == null) {
return true;
}
MESSAGE_REACTION_LISTENERS.remove(message);
if (removeReactions) {
try {
Standard.getUpdatedMessage(message).queue((message_) -> message_.clearReactions().queue());
} catch (Exception ex) {
System.err.println("ReactionListener unregisterListener2 error: " + ex);
}
}
return true;
}
示例15: receiveMessage
import net.dv8tion.jda.core.entities.Message; //導入依賴的package包/類
@Override
public void receiveMessage(Message message) {
if (newestGroup.canAddMessage(message))
newestGroup.addMessage(message);
else {
newestGroup = new UIMessageGroup(message);
messageList.add(newestGroup, c, messageList.getComponentCount()); //Add the received message at the bottom of the message list
}
refresh();
scrollToBottom();
}