本文整理汇总了Java中net.dv8tion.jda.core.entities.TextChannel类的典型用法代码示例。如果您正苦于以下问题:Java TextChannel类的具体用法?Java TextChannel怎么用?Java TextChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextChannel类属于net.dv8tion.jda.core.entities包,在下文中一共展示了TextChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkIcons
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
private void checkIcons(CMessage message, String[] args) {
TextChannel channel = message.getChannel();
if (args.length != 3) {
sendUsage(message, "!discord icons <guild id|this>");
return;
}
String guild = args[2];
Guild targetGuild = null;
if (guild.equals("this")) {
targetGuild = message.getGuild();
} else {
targetGuild = this.charrizard.getDiscordAPI().getGuildById(args[2]);
}
if (targetGuild == null) {
sendError(message, "This guild does not exists!");
return;
}
if (targetGuild.getEmotes().size() == 0) {
sendError(message, "This server does not have any own icons!");
return;
}
channel.sendMessage("**Icons**:").queue();
targetGuild.getEmotes().forEach(icon -> channel.sendMessage(icon.getAsMention() + " - " + icon.getImageUrl()).queue());
}
示例2: createGuild
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public void createGuild(Guild guild) {
if (guild == null) {
return;
}
if (getGuild(guild) != null) {
return;
}
CGuild cGuild = new CGuild(guild, charrizard);
for (TextChannel channel : guild.getTextChannels()) {
cGuild.createTextChannel(channel);
}
for (VoiceChannel voiceChannel : guild.getVoiceChannels()) {
cGuild.createVoiceChannel(voiceChannel);
}
guildCache.put(guild.getId(), cGuild);
}
示例3: Trivia
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public Trivia(TextChannel channel, TLongSet players, OpenTriviaDatabase.Question question) {
super(channel, players, question.correctAnswer, (question.incorrectAnswers.size() + 1) / 2);
List<String> options = new ArrayList<>(question.incorrectAnswers);
options.add(question.correctAnswer);
int triesLeft = options.size()/2;
totalOptions = options.size();
correctOptionIndex = options.indexOf(question.correctAnswer);
Collections.shuffle(options);
int[] idx = {1};
channel.sendMessage(new EmbedBuilder()
.setDescription("**" + question.question + "**")
.addField("Options", options.stream().map(o->idx[0]++ + " - " + o).collect(Collectors.joining("**\n**", "**", "**")), false)
.addField("Difficulty", question.difficulty, true)
.addField("Category", question.category, true)
.setFooter(triesLeft + " tries left | Answer with the option number", null)
.build()
).queue();
}
示例4: doge
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
@Command(
name = "doge",
description = "Sends doge images with custom texts",
usage = "`>>doge wow \"such doge\"`",
permission = CommandPermission.USER,
category = CommandCategory.IMAGE
)
public static void doge(@Argument("event") GuildMessageReceivedEvent event, @Argument("args") String[] args, @Argument("channel") TextChannel channel) {
checkVerification(event);
String url = "http://dogr.io/" + String.join("/", args).replace("\n", "%20").replace(" ", "%20") + ".png?split=false";
channel.sendMessage(new EmbedBuilder()
.setColor(Color.YELLOW)
.setTitle("Doge", "http://dogr.io")
.setImage(url)
.build()).queue();
}
示例5: friends
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
@Command(
name = "pokemonguess",
description = "Guess which pokemon it is",
usage = "`>>pokemonguess`: Play pokemon guess solo\n" +
"`>>pokemonguess @Someone @SomeoneElse ...`: Play pokemon guess with your friends (if you have any)",
permission = CommandPermission.USER,
category = CommandCategory.GAME
)
public static void pokemonguess(@Argument("channel") TextChannel channel, @Argument("author") User author, @Argument("message") Message message) {
if(check(channel)) return;
TLongSet players = new TLongHashSet();
players.add(author.getIdLong());
for(User u : message.getMentionedUsers()) players.add(u.getIdLong());
EventManagerThread.current().newThread(()->{
try {
Thread.sleep(100);
} catch(InterruptedException e) {
return;
}
InteractiveOperations.create(channel.getIdLong(), 120, new Pokemon(channel, players));
}, "Game Starter").start();
}
示例6: getTextChannel
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public final TextChannel getTextChannel(int index, boolean consume) {
if (guild == null) {
return null;
}
final String temp = getRaw(index);
if (temp == null) {
return null;
}
final Matcher matcher = PATTERN_MARKDOWN_CHANNEL.matcher(temp);
if (!matcher.matches()) {
return null;
}
if (consume) {
consumeRaw(index);
}
return guild.getTextChannelById(matcher.group(1));
}
示例7: voteskip
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public void voteskip(long userId) {
TextChannel tc = guildMusicPlayer.textChannel;
int votes = getRequiredVotes(guildMusicPlayer.voiceChannel);
if(voteskips.contains(userId)) {
voteskips.remove(userId);
tc.sendMessage("Your vote has been removed! " + (votes-voteskips.size()) + " more to skip").queue();
} else {
voteskips.add(userId);
if(voteskips.size() >= votes) {
tc.sendMessage("Reached required number of votes, skipping song").queue();
nextTrack();
} else {
tc.sendMessage("Your vote has been added! " + (votes-voteskips.size()) + " more to skip").queue();
}
}
}
示例8: execute
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
event.replyError("Please include a text channel or NONE");
else if(event.getArgs().equalsIgnoreCase("none"))
{
db.setLeaveChannel(event.getGuild(), null);
event.replySuccess("Leave channel disabled");
}
else
{
List<TextChannel> list = FinderUtil.findTextChannels(event.getArgs(), event.getGuild());
if(list.isEmpty())
event.replyWarning("No Text Channels found matching \""+event.getArgs()+"\"");
else if (list.size()>1)
event.replyWarning(FormatUtil.listOfTcChannels(list, event.getArgs()));
else
{
db.setLeaveChannel(event.getGuild(), list.get(0));
event.replySuccess("The message configured will be sent in "+list.get(0).getAsMention());
}
}
}
示例9: getModlogChannel
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public TextChannel getModlogChannel(Guild guild)
{
try
{
Statement statement = connection.createStatement();
statement.closeOnCompletion();
TextChannel tc;
try (ResultSet results = statement.executeQuery(String.format("SELECT modlog_id FROM GUILD_SETTINGS WHERE GUILD_ID = %s", guild.getId())))
{
if(results.next())
tc = guild.getTextChannelById(Long.toString(results.getLong("modlog_id")));
else tc=null;
}
return tc;
}
catch(SQLException e)
{
LOG.warn(e.toString());
return null;
}
}
示例10: getServerlogChannel
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public TextChannel getServerlogChannel(Guild guild)
{
try
{
Statement statement = connection.createStatement();
statement.closeOnCompletion();
TextChannel tc;
try (ResultSet results = statement.executeQuery(String.format("SELECT serverlog_id FROM GUILD_SETTINGS WHERE GUILD_ID = %s", guild.getId())))
{
if(results.next())
tc = guild.getTextChannelById(Long.toString(results.getLong("serverlog_id")));
else tc=null;
}
return tc;
}
catch(SQLException e)
{
LOG.warn(e.toString());
return null;
}
}
示例11: sendMessage
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public void sendMessage(String channel, String message) {
TextChannel textChannel = resolveChannel(channel);
if (textChannel != null) {
try {
com.gmt2001.Console.out.println("[DISCORD] [#" + textChannel.getName() + "] [CHAT] " + message);
textChannel.sendMessage(message).queue();
} catch (NullPointerException ex) {
com.gmt2001.Console.err.println("Failed to send a message to Discord [" + ex.getClass().getSimpleName() + "]: " + ex.getMessage());
channelMap.clear();
userMap.clear();
roleMap.clear();
users.clear();
botId = jdaAPI.getSelfUser().getId();
getTextChannels();
getUserNames();
getRoles();
textChannel = resolveChannel(channel);
if (textChannel != null) {
textChannel.sendMessage(message).queue();
}
}
}
}
示例12: blockChannel
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
private void blockChannel(CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
Message message = parsedCommandInvocation.getMessage();
if (message.getMentionedChannels().isEmpty()) {
message.getTextChannel().sendMessage(EmbedUtil.error("Unknown channel", "Please mention the textchannel that should be blacklisted").build()).queue(msg -> msg.delete().queueAfter(5, TimeUnit.SECONDS));
return;
}
TextChannel channel = message.getMentionedChannels().get(0);
if (RubiconBot.getMySQL().isBlacklisted(channel)) {
message.getTextChannel().sendMessage(EmbedUtil.error("Blacklisted channel", "That channel is already blacklisted").build()).queue(msg -> msg.delete().queueAfter(5, TimeUnit.SECONDS));
return;
}
String oldEntry = RubiconBot.getMySQL().getGuildValue(message.getGuild(), "blacklist");
String newEntry;
if (oldEntry.equals(""))
newEntry = channel.getId();
else
newEntry = oldEntry + "," + channel.getId();
RubiconBot.getMySQL().updateGuildValue(message.getGuild(), "blacklist", newEntry);
message.getTextChannel().sendMessage(EmbedUtil.success("Blacklisted channel!", "Successfully added channel to blacklist").build()).queue(msg -> msg.delete().queueAfter(5, TimeUnit.SECONDS));
}
示例13: addTextChannel
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
private void addTextChannel(CommandEvent e) {
String arg = e.getArgs();
java.util.List<TextChannel> tcArray = mcb.getRelayChannels();
String response;
boolean withID = StringUtils.isNumeric(arg) && e.getJDA().getTextChannelById(arg) != null;
TextChannel tc;
if (withID) {
tc = e.getJDA().getTextChannelById(arg);
} else {
java.util.List<TextChannel> result = FinderUtil.findTextChannel(arg, e.getGuild());
tc = result.size() > 0 ? result.get(0) : null;
}
if (tc != null) {
tcArray.add(tc);
configsManager.getChatConfig().set("Relay_Channels", asStringList(tcArray));
configsManager.getChatConfig().saveConfig();
} else {
response = Locale.getCommandsMessage("textchannel.invalid-tc").finish();
respond(e, String.format(response, arg), ResponseLevel.LEVEL_3);
return;
}
response = Locale.getCommandsMessage("textchannel.added-tc").finish();
respond(e, String.format(response, arg), ResponseLevel.LEVEL_1);
Logger.info("Added text channel " + arg);
}
示例14: execute
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
Message message = parsedCommandInvocation.getMessage();
if (message.getMentionedUsers().isEmpty())
return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "mute <@User>").build()).build();
Member target = message.getGuild().getMember(message.getMentionedUsers().get(0));
if (!message.getGuild().getSelfMember().canInteract(target))
return new MessageBuilder().setEmbed(EmbedUtil.error("No permission", "Sorry i can't mute this user! His/her role is higher than yours.").build()).build();
TextChannel channel = message.getTextChannel();
if (channel.getPermissionOverride(target) == null)
channel.createPermissionOverride(target).complete();
if (channel.getPermissionOverride(target).getDenied().contains(Permission.MESSAGE_WRITE))
return new MessageBuilder().setEmbed(EmbedUtil.error("Already muted", "This user is already muted.").build()).build();
message.getGuild().getTextChannels().forEach(c -> {
if (c.getPermissionOverride(target) == null)
c.createPermissionOverride(target).complete();
c.getPermissionOverride(target).getManager().deny(Permission.MESSAGE_WRITE).queue();
});
PrivateChannel targetch = target.getUser().openPrivateChannel().complete();
targetch.sendMessage(EmbedUtil.info("Muted", "You got muted on `" + message.getGuild().getName() + "` by " + message.getAuthor().getAsMention()).build()).queue();
return new MessageBuilder().setEmbed(EmbedUtil.success("Muted", "Successfully muted " + target.getAsMention()).build()).build();
}
示例15: onGuildMemberJoin
import net.dv8tion.jda.core.entities.TextChannel; //导入依赖的package包/类
public void onGuildMemberJoin(GuildMemberJoinEvent e) {
if (!RubiconBot.getMySQL().ifUserExist(e.getUser())) {
RubiconBot.getMySQL().createUser(e.getUser());
}
try {
String joinMessage = RubiconBot.getMySQL().getGuildValue(e.getGuild(), "joinmsg");
if (joinMessage.equals("0")) {
return;
} else {
TextChannel messageChannel = e.getJDA().getTextChannelById(RubiconBot.getMySQL().getGuildValue(e.getGuild(), "channel"));
if (messageChannel == null)
return;
joinMessage = joinMessage.replace("%user%", e.getMember().getAsMention());
joinMessage = joinMessage.replace("%guild%", e.getGuild().getName());
messageChannel.sendMessage(joinMessage).queue();
}
} catch (NullPointerException ex) {
//Channel does not exits
}
}