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


Java JDA.getTextChannelById方法代码示例

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


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

示例1: verifyAnnouncementAdd

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
/**
 *  Returns error message (or empty string) for announcement add keyword verification
 */
public static String verifyAnnouncementAdd(String[] args, int index, String head, MessageReceivedEvent event)
{
    if (args.length - index < 3)
    {
        return "That's not the right number of arguments for **" + args[index - 2] +" "+ args[index - 1] + "**!\n" +
                "Use ``" + head + " " + args[0] + " " + args[index - 2] + " " + args[index - 1] + " [#target] [time] [message]``";
    }
    JDA jda = Main.getShardManager().getJDA(event.getGuild().getId());
    String channelId = args[index].replaceAll("[^\\d]", "");
    if (!channelId.matches("\\d+") || jda.getTextChannelById(channelId)==null)
    {
        return "**" + args[index] + "** is not a channel on your server!";
    }
    if(!VerifyUtilities.verifyTimeString(args[index+1]))
    {
        return "**" + args[index+1] + "** is not a properly formed announcement time!\n" +
                "Times use the format \"TYPE+/-OFFSET\". Ex: ``START+10m``, ``END-1h``";
    }
    return "";
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:24,代码来源:VerifyUtilities.java

示例2: getTextChannelById

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public TextChannel getTextChannelById(long id)
{
    for(JDA shard: shards)
    {
        TextChannel tc = shard.getTextChannelById(id);
        if(tc!=null)
            return tc;
    }
    return null;
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:11,代码来源:Bot.java

示例3: announcementsToString

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
/**
 * creates string display for event announcements
 * @return
 */
public String announcementsToString()
{
    String body = "// Event Announcements\n";
    JDA jda = Main.getShardManager().getJDA(this.guildId);
    for (String id : this.announcementTimes.keySet())
    {
        TextChannel channel = jda.getTextChannelById(this.announcementTargets.get(id));
        body += "(" + (Integer.parseInt(id)+1) + ") \"" + this.announcementMessages.get(id)+ "\"" +
                " at \"" + this.announcementTimes.get(id) + "\"" +
                " to \"#" + (channel==null ? "unknown_channel" : channel.getName())+"\"\n";
    }
    return body;
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:18,代码来源:ScheduleEntry.java

示例4: getTextChannelById

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public static TextChannel getTextChannelById(String id) {
	for (JDA jda : Bot.shards) {
		TextChannel channel = jda.getTextChannelById(id);
		if (channel != null) return channel;
	}
	return null;
}
 
开发者ID:Tisawesomeness,项目名称:Minecord,代码行数:8,代码来源:DiscordUtils.java

示例5: getTextChannelById

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
/**
 * Get a text channel from an ID from all shards
 * @param channelId Channel ID
 * @return TextChannel if found, null if not
 */
public TextChannel getTextChannelById(long channelId) {
	for (JDA j : jdaClients) {
		TextChannel t;
		if ((t = j.getTextChannelById(channelId)) != null) {
			return t;
		}
	}
	return null;
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:15,代码来源:Bot.java

示例6: closePortal

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
private void closePortal(CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
    JDA jda = parsedCommandInvocation.getMessage().getJDA();
    Guild messageGuild = parsedCommandInvocation.getMessage().getGuild();
    TextChannel messageChannel = parsedCommandInvocation.getMessage().getTextChannel();

    //Check if portal exists
    String oldGuildPortalEntry = RubiconBot.getMySQL().getGuildValue(messageGuild, "portal");
    if (oldGuildPortalEntry.equals("closed")) {
        messageChannel.sendMessage(EmbedUtil.error("Portal error!", "Portal is already closed").build()).queue();
        return;
    }
    if (oldGuildPortalEntry.equals("waiting")) {
        RubiconBot.getMySQL().updateGuildValue(messageGuild, "portal", "closed");
        messageChannel.sendMessage(EmbedUtil.success("Portal", "Successful closed portal request.").build()).queue();
        return;
    }
    Guild partnerGuild = jda.getGuildById(RubiconBot.getMySQL().getPortalValue(messageGuild, "partnerid"));

    //Close Channels
    TextChannel channelOne = null;
    TextChannel channelTwo = null;
    try {
        channelOne = jda.getTextChannelById(RubiconBot.getMySQL().getPortalValue(messageGuild, "channelid"));
        channelTwo = jda.getTextChannelById(RubiconBot.getMySQL().getPortalValue(partnerGuild, "channelid"));
    } catch (NullPointerException ignored) {
        //Channels doesn't exist
    }

    if (channelOne != null)
        channelOne.getManager().setName(closedChannelName).queue();
    if (channelTwo != null)
        channelTwo.getManager().setName(closedChannelName).queue();

    //Close and delete DB Portal
    RubiconBot.getMySQL().updateGuildValue(messageGuild, "portal", "closed");
    RubiconBot.getMySQL().deletePortal(messageGuild);
    RubiconBot.getMySQL().updateGuildValue(partnerGuild, "portal", "closed");
    RubiconBot.getMySQL().deletePortal(partnerGuild);

    EmbedBuilder portalClosedMessage = new EmbedBuilder();
    portalClosedMessage.setAuthor("Portal closed!", null, jda.getSelfUser().getEffectiveAvatarUrl());
    portalClosedMessage.setDescription("Portal was closed. Create a new one with `" + parsedCommandInvocation.getPrefix() + "portal create`");
    portalClosedMessage.setColor(Colors.COLOR_ERROR);

    channelOne.sendMessage(portalClosedMessage.build()).queue();
    portalClosedMessage.setDescription("Portal was closed. Create a new one with `" + parsedCommandInvocation.getPrefix() + "portal create`");
    channelTwo.sendMessage(portalClosedMessage.build()).queue();

    channelOne.getManager().setTopic("Portal closed").queue();
    channelTwo.getManager().setTopic("Portal closed").queue();
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:52,代码来源:CommandPortal.java

示例7: handle

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
    HttpServerRequest request = ctx.request();
    HttpServerResponse response = ctx.response();

    String guildId = request.getParam("guildId");
    int shardId = DiscordUtils.getShardIdFromGuildId(Long.parseLong(guildId), bot.getConfig().jim.shard_count);
    JDA shard = bot.getShards().get(shardId).getShard();
    Guild guild = shard.getGuildById(guildId);
    SettingsRecord record = database.selectFrom(Tables.SETTINGS)
                                    .where(Tables.SETTINGS.GUILDID.eq(guildId))
                                    .fetchAny();

    if (record == null || guild == null) {
        response.setStatusCode(404);
        response.end();
        return;
    }

    Gson gson = new GsonBuilder().serializeNulls().create();
    List<PartialChannel> channels = guild.getTextChannels()
                                         .stream()
                                         .map((channel) -> new PartialChannel(channel.getId(), channel.getName()))
                                         .collect(Collectors.toList());
    List<PartialRole> roles = guild.getRoles()
                                   .stream()
                                   .map((role) -> new PartialRole(role.getId(), role.getName()))
                                   .collect(Collectors.toList());

    Channel modLogChannel = shard.getTextChannelById(record.getModlogchannelid());
    PartialChannel modLogChannelPartial = new PartialChannel(modLogChannel.getId(), modLogChannel.getName());
    Channel welcomeMessageChannel = shard.getTextChannelById(record.getWelcomemessagechannelid());
    PartialChannel welcomeMessageChannelPartial = new PartialChannel(welcomeMessageChannel.getId(), welcomeMessageChannel.getName());
    Role holdingRoomRole = null;
    PartialRole holdingRoomRolePartial = null;

    if (record.getHoldingroomroleid() != null) {
        holdingRoomRole = shard.getRoleById(record.getHoldingroomroleid());
        holdingRoomRolePartial = new PartialRole(holdingRoomRole.getId(), holdingRoomRole.getName());
    }

    GuildSettings settings = new GuildSettings(
            guildId,
            record.getModlog(),
            modLogChannelPartial,
            record.getHoldingroom(),
            holdingRoomRolePartial,
            record.getHoldingroomminutes(),
            record.getInvitelinkremover(),
            record.getWelcomemessage(),
            record.getMessage(),
            welcomeMessageChannelPartial,
            record.getPrefix(),
            record.getSilentcommands(),
            record.getNospaceprefix(),
            record.getStatistics(),
            channels,
            roles
    );
    String responseJson = gson.toJson(settings);
    response.putHeader("Content-Type", "application/json");
    response.end(responseJson);
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:64,代码来源:GetGuildSettings.java

示例8: createModLogEntry

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public static void createModLogEntry(DiscordBot bot, JDA shard, Message message, Member member, String reason, String action, int id, Date expirationDate, boolean expires) {
    SettingsRecord guildSettings = DatabaseUtils.getGuildSettings(bot.getDatabase(), member.getGuild());
    Date now = new Date();

    boolean modLogActive = guildSettings.getModlog();
    String prefix = guildSettings.getPrefix();

    if (!modLogActive) {
        return;
    }

    TextChannel modLogChannel = shard.getTextChannelById(guildSettings.getModlogchannelid());

    if (modLogChannel == null) {
        sendMessage(message.getChannel(), "Invalid moderator log channel in guild configuration, set a proper one via `" + prefix + " settings` command.");
        return;
    }

    EmbedBuilder embed = new EmbedBuilder();
    User user = member.getUser();
    TextChannel channel = message.getTextChannel();
    embed.setColor(modLogColors.get(action));
    embed.addField("Action ", modLogActionTexts.get(action) + " - #" + id, false);
    embed.addField("User:", getUserTagAndId(user), false);
    embed.addField("Reason:", reason, false);
    embed.addField("Responsible Moderator:", getUserTagAndId(message.getAuthor()), false);
    embed.addField("Channel", getChannelMention(channel), false);
    embed.setTimestamp(now.toInstant());

    if (expires) {
        String dateText = expirationDate == null ? "Indefinitely" : expirationDate.toString();
        String untilText = null;

        switch (action) {
            case "ban":
                untilText = "Banned until";
                break;
            case "mute":
                untilText = "Muted until";
                break;
            default:
                break;
        }

        embed.addField(untilText, dateText, false);
    }

    sendMessage(modLogChannel, embed.build());
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:50,代码来源:DiscordUtils.java


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