本文整理汇总了Java中net.dv8tion.jda.core.entities.TextChannel.getGuild方法的典型用法代码示例。如果您正苦于以下问题:Java TextChannel.getGuild方法的具体用法?Java TextChannel.getGuild怎么用?Java TextChannel.getGuild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.entities.TextChannel
的用法示例。
在下文中一共展示了TextChannel.getGuild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.dv8tion.jda.core.entities.TextChannel; //导入方法依赖的package包/类
public Result run(String[] argsOrig, MessageReceivedEvent e) {
//Check for proper argument length
if (argsOrig.length < 2) {
return new Result(Outcome.WARNING, ":warning: Please specify a message.");
}
//Extract channel
String[] args = ArrayUtils.remove(MessageUtils.getContent(e.getMessage(), true), 0);
TextChannel channel = null;
if (args[0].matches(MessageUtils.channelRegex)) {
channel = e.getMessage().getMentionedChannels().get(0);
} else if (args[0].matches(MessageUtils.idRegex)) {
channel = DiscordUtils.getTextChannelById(args[0]);
} else {
return new Result(Outcome.ERROR, ":x: Not a valid channel!");
}
//Send the message
String msg = String.join(" ", ArrayUtils.remove(args, 0));
channel.sendMessage(msg).queue();
//Log it
EmbedBuilder eb = new EmbedBuilder();
Guild guild = channel.getGuild();
eb.setAuthor(e.getAuthor().getName() + " (" + e.getAuthor().getId() + ")",
null, e.getAuthor().getAvatarUrl());
eb.setDescription("**Sent a msg to `" + channel.getName() + "` (" + channel.getId() + ")**\non `" +
guild.getName() + "` (" + guild.getId() + "):\n" + msg);
eb.setThumbnail(guild.getIconUrl());
MessageUtils.log(eb.build());
return new Result(Outcome.SUCCESS);
}