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


Java TextChannel类代码示例

本文整理汇总了Java中net.dv8tion.jda.entities.TextChannel的典型用法代码示例。如果您正苦于以下问题:Java TextChannel类的具体用法?Java TextChannel怎么用?Java TextChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onVoiceJoin

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
public void onVoiceJoin(VoiceJoinEvent event) {
    MessageBuilder mb = new MessageBuilder();
    Optional<TextChannel> channel =
            event.getJDA().getTextChannelsByName(Configuration.MAIN_CHANNEL).stream().findFirst();

    if (channel.isPresent()) {
        channel.get().sendMessageAsync(mb.appendString(Configuration.GREETING).build(),
                c -> LOG.info("Send greeting message to '" + Configuration.MAIN_CHANNEL + "'"));
    } else {
        LOG.warning("Could not find channel '" + Configuration.MAIN_CHANNEL + "'");
    }

    audioService.sendGreeting();

    super.onVoiceJoin(event);
}
 
开发者ID:flaiker,项目名称:bottimus,代码行数:18,代码来源:JoinMessageListener.java

示例2: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String text = (String)args[0];
    TextChannel channel=null;
    if(text.matches("<#\\d+>.*"))
    {
        String id = text.substring(2,text.indexOf(">"));
        text = text.substring(text.indexOf(">")+1).trim();
        channel = event.getJDA().getTextChannelById(id);
        if(channel!=null && !channel.getGuild().equals(event.getGuild()))
            channel = null;
    }
    if(channel==null)
        channel = event.getTextChannel();
    if(PermissionUtil.checkPermission(event.getJDA().getSelfInfo(), Permission.MESSAGE_MANAGE, channel))
        event.getMessage().deleteMessage();
    if(!Sender.sendMsg(text, channel))
    {
        Sender.sendResponse(SpConst.ERROR, event);
        return false;
    }
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:24,代码来源:Say.java

示例3: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    TextChannel tchan = (TextChannel)(args[0]);
    String options = args[1]==null ? "" : (String)args[1];
    if(tchan==null)
        tchan = event.getTextChannel();
    //check bot permissions for channel
    if(!PermissionUtil.checkPermission(event.getJDA().getSelfInfo(), Permission.MESSAGE_WRITE, tchan) || !PermissionUtil.checkPermission(event.getJDA().getSelfInfo(), Permission.MESSAGE_READ, tchan))
    {
        Sender.sendResponse(String.format(SpConst.NEED_PERMISSION,Permission.MESSAGE_READ+", "+Permission.MESSAGE_WRITE+
                ", and preferably "+Permission.MESSAGE_ATTACH_FILES), event);
        return false;
    }
    String str = "";
    String[] current = feeds.feedForGuild(event.getGuild(), Feeds.Type.MODLOG);
    if(current!=null)
        str+=SpConst.WARNING+"Feed "+Feeds.Type.MODLOG+" has been removed from <#"+current[Feeds.CHANNELID]+">\n";
    feeds.set(new String[]{tchan.getId(),Feeds.Type.MODLOG.toString(),event.getGuild().getId(),options});
    str+=SpConst.SUCCESS+"Feed "+Feeds.Type.MODLOG+" has been added to <#"+tchan.getId()+">"
            + "\n*The `modlog` feed is for tracking bans, and other moderator commands like kicks, mutes, and cleans*"
            + "\n*If you want a feed to track message edits, message deletes, avatar changes, and more, use the `serverlog` feed.*";
    Sender.sendResponse(str, event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:25,代码来源:Feed.java

示例4: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    TextChannel tc = (TextChannel)args[0];
    Role role = (Role)args[1];
    String content = (String)args[2];
    if(!tc.checkPermission(event.getJDA().getSelfInfo(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))
    {
        Sender.sendResponse(String.format(SpConst.NEED_PERMISSION,Permission.MESSAGE_READ+", "+Permission.MESSAGE_WRITE), event);
        return false;
    }
    boolean mentionable = role.isMentionable();
    if(!mentionable)
    {
        if(!PermissionUtil.canInteract(event.getJDA().getSelfInfo(), role))
        {
            Sender.sendResponse(SpConst.ERROR+"I cannot make the role *"+role.getName()+"* mentionable because I cannot edit it. Make sure it is listed below my highest role.", event);
            return false;
        }
        role.getManager().setMentionable(true).update();
    }
    if(content.contains("{role}"))
        content = content.replace("{role}", role.getAsMention());
    else
        content = role.getAsMention()+": "+content;
    Sender.sendMsg(content, tc, m -> {
        if(!mentionable)
            role.getManager().setMentionable(false).update();
        Sender.sendResponse(SpConst.SUCCESS+"Announcement sent to <#"+tc.getId()+">!", event);
    });
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:32,代码来源:Announce.java

示例5: sendMsgFile

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
public static boolean sendMsgFile(String message, File file, String alternate, TextChannel tchan)
{
    if(PermissionUtil.checkPermission(tchan, tchan.getJDA().getSelfInfo(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))
    {
        ArrayList<String> bits = splitMessage(message);
        
        if(PermissionUtil.checkPermission(tchan, tchan.getJDA().getSelfInfo(), Permission.MESSAGE_ATTACH_FILES))
        {
            tchan.sendFileAsync(file, bits.isEmpty() ? null : new MessageBuilder().appendString(bits.get(0)).build(), null);
        }
        else
        {
            bits.stream().forEach((bit) -> {
                tchan.sendMessageAsync(bit, null);
            });
        }
        return true;
    }
    return false;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:21,代码来源:Sender.java

示例6: checkReminders

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
public void checkReminders(JDA jda)
{
    if(jda.getStatus()!=JDA.Status.CONNECTED)
        return;
    List<String[]> list = getExpiredReminders();
    list.stream().map((item) -> {
        removeReminder(item);
        return item;
    }).forEach((item) -> {
        TextChannel chan = jda.getTextChannelById(item[Reminders.CHANNELID]);
        if(chan==null)
        {
            User user = jda.getUserById(item[Reminders.USERID]);
            if(user!=null)
                Sender.sendPrivate("\u23F0 "+item[Reminders.MESSAGE], user.getPrivateChannel());
        }
        else
        {
            Sender.sendMsg("\u23F0 <@"+item[Reminders.USERID]+"> \u23F0 "+item[Reminders.MESSAGE], chan);
        }
    });
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:23,代码来源:Reminders.java

示例7: getOtherLine

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
public synchronized TextChannel getOtherLine(TextChannel current)
{
    if(ids.size()<2)
        return null;
    TextChannel chan;
    if(ids.get(0).equals(current.getId()))
    {
        chan = current.getJDA().getTextChannelById(ids.get(1));
    }
    else if(ids.get(1).equals(current.getId()))
    {
        chan = current.getJDA().getTextChannelById(ids.get(0));
    }
    else return null;
    if(chan==null)
    {
        ids.clear();
        Sender.sendMsg(CONNECTION_LOST, current);
    }
    return chan;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:22,代码来源:PhoneConnections.java

示例8: fetchMessages

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
private void fetchMessages() {
    todoEntries.clear();
    if(channel == null) {
        return;
    }
    TextChannel tc = api.getTextChannelById(channel);
    if(tc == null) {
        Statics.LOG.warn(cfg.getGuild().getName()+'('+cfg.getGuild().getId()+") Messed up Kanzebot!!!");
        channel = null;
        cfg.save();
        return;
    }
    Map<String, List<String>> messages = new HashMap<>();
    List<String> toFind = new ArrayList<>(todoMessage);
    MessageHistory history = new MessageHistory(tc);
    while(!toFind.isEmpty()) {
        List<Message> retrieve = history.retrieve();
        if(retrieve == null) {
            return;
        }
        retrieve.forEach(m -> {
            if(toFind.contains(m.getId())) {
                toFind.remove(m.getId());
                List<String> tmp = new LinkedList<>();
                for(String line : m.getRawContent().split("\n")) {
                    Matcher matcher = msgPattern.matcher(line);
                    if(matcher.matches()) {
                        tmp.add(matcher.group(1));
                    }
                }
                messages.put(m.getId(), tmp);
            }
        });
    }
    todoMessage.forEach(i -> messages.get(i).forEach(todoEntries::add));
}
 
开发者ID:kantenkugel,项目名称:KanzeBot,代码行数:37,代码来源:Todo.java

示例9: modelToDto

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
public GuildDTO modelToDto(GuildEntity model) {
    GuildDTO dto = null;
    if(model != null){
        dto = new GuildDTO();

        final Guild guild = jda.getGuildById(Long.toString(model.getServerId()));
        final DiscordGuildDTO guildDTO = this.discordGuildTransformer.modelToDto(guild);
        dto.setServer(guildDTO);

        final TextChannel channel = jda.getTextChannelById(Long.toString(model.getChannelId()));
        final DiscordChannelDTO channelDTO = this.discordChannelTransformer.modelToDto(channel);
        dto.setChannel(channelDTO);
        dto.setActive(model.isActive());
        dto.setCompact(model.isCompact());
        dto.setCleanup(model.getCleanup());

        final List<QueueItemDTO> queueItems = this.queueItemTransformer.modelToDto(new ArrayList<QueueitemEntity>(model.getQueue()));
        dto.setQueue(queueItems);

        final List<UserDTO> notifications = this.notificationTransformer.modelToDto(new ArrayList<NotificationEntity>(model.getNotifications()));
        dto.setNotifications(notifications);

        final List<PermissionDTO> permissions = this.permissionTransformer.modelToDto(new ArrayList<PermissionEntity>(model.getPermissions()));
        dto.setPermissions(permissions);
    }
    return dto;
}
 
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:29,代码来源:GuildTransformer.java

示例10: modelToDto

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
public DiscordChannelDTO modelToDto(TextChannel model) {
    DiscordChannelDTO dto = null;
    if(model != null){
        dto = new DiscordChannelDTO();
        dto.setId(model.getId());
        dto.setGuildId(model.getGuild().getId());
        dto.setName(model.getName());
    }
    return dto;
}
 
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:12,代码来源:DiscordChannelTransformer.java

示例11: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    TextChannel tchan = (TextChannel)args[0];
    String current = settings.getSettingsForGuild(event.getGuild().getId())[Settings.WELCOMEMSG];
    if(current==null || current.equals(""))
    {
        Sender.sendResponse(SpConst.WARNING+"There is no welcome message set for the server!", event);
        return false;
    }
    String[] parts = Settings.parseWelcomeMessage(current);
    settings.setSetting(event.getGuild().getId(), Settings.WELCOMEMSG, "<#"+tchan.getId()+">:"+parts[1]);
    Sender.sendResponse(SpConst.SUCCESS+"The welcome message will now be sent to <#"+tchan.getId()+">", event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:15,代码来源:Welcome.java

示例12: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String id = type==Argument.Type.SHORTSTRING ? (String)args[0] : ((User)args[0]).getId();
    String[] feed = feeds.feedForGuild(event.getGuild(), Feeds.Type.MODLOG);
    if(feed==null)
    {
        Sender.sendResponse(SpConst.ERROR+"The modlog feed has not been set up on this server!",event);
        return false;
    }
    TextChannel tc = event.getJDA().getTextChannelById(feed[Feeds.CHANNELID]);
    if(tc == null || !tc.checkPermission(event.getJDA().getSelfInfo(), Permission.MESSAGE_READ, Permission.MESSAGE_HISTORY))
    {
        Sender.sendResponse(SpConst.ERROR+"The modlog feed channel has been deleted or cannot be accessed.",event);
        return false;
    }
    event.getChannel().sendTyping();
    List<Message> logs = tc.getHistory().retrieve(500).stream().filter(m -> m.getRawContent().contains(id)).collect(Collectors.toList());
    if(logs.isEmpty())
    {
        Sender.sendResponse(SpConst.WARNING+"Could not find anything in the modlog for ID `"+id+"` in the past 500 messages!",event);
        return true;
    }
    StringBuilder builder = new StringBuilder(SpConst.SUCCESS+"`"+logs.size()+"` actions found for ID `"+id+"`:");
    Collections.reverse(logs);
    logs.stream().forEach(m -> {
        builder.append("\n`[").append(m.getTime().format(DateTimeFormatter.ofPattern("d MMM uuuu"))).append("]` ").append(FormatUtil.appendAttachmentUrls(m).replaceAll("^`\\[[\\d:]+\\]`\\s+", ""));
    });
    Sender.sendResponse(builder.toString(), event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:31,代码来源:Note.java

示例13: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String ignores = settings.getSettingsForGuild(event.getGuild().getId())[Settings.IGNORELIST];
StringBuilder builder = new StringBuilder();
if(ignores==null || ignores.equals(""))
{
    builder.append(SpConst.WARNING+"Nothing is currently ignored on the server!");
}
else
{
    builder.append("\uD83D\uDEAB Current ignores on **").append(event.getGuild().getName()).append("**:");
    for(String id: ignores.split("\\s+"))
    {
        if(id.startsWith("u"))
        {
            User u = event.getJDA().getUserById(id.substring(1));
            if(u!=null)
                builder.append("\nUser: **").append(u.getUsername()).append("** #").append(u.getDiscriminator());
            else
                builder.append("\nUser with ID: ").append(id.substring(1));
        }
        else if (id.startsWith("c"))
        {
            TextChannel chan = event.getJDA().getTextChannelById(id.substring(1));
            if(chan!=null)
                builder.append("\nChannel: <#").append(id.substring(1)).append(">");
        }
        else if (id.startsWith("r"))
        {
            event.getGuild().getRoles().stream().filter((r) -> (r.getId().equals(id.substring(1)))).forEach((r) -> {
                builder.append("\nRole: *").append(r.getName()).append("*");
            });
        }
    }
}
builder.append("\nSee `"+SpConst.PREFIX+"ignore help` for how to add or remove ignores");
Sender.sendResponse(builder.toString(), event);
return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:40,代码来源:Ignore.java

示例14: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    TextChannel channel = (TextChannel)(args[0]);
    if(channel==null)
        channel = event.getTextChannel();
    String[] room = rooms.get(channel.getId());
    if(room==null)
    {
        Sender.sendResponse(SpConst.ERROR+"<#"+channel.getId()+"> is not a "+SpConst.BOTNAME+" room!", event);
        return false;
    }
    String[] currentSettings = settings.getSettingsForGuild(event.getGuild().getId());
    PermLevel authorperm = PermLevel.getPermLevelForUser(event.getAuthor(), event.getGuild(), currentSettings);
    if(!room[Rooms.OWNERID].equals(event.getAuthor().getId()) && !authorperm.isAtLeast(PermLevel.ADMIN))
    {
        Sender.sendResponse(SpConst.ERROR+"You cannot remove a room you don't own!", event);
        return false;
    }
    if(room[Rooms.OWNERID].equals(event.getJDA().getSelfInfo().getId()))
    {
        Sender.sendResponse(SpConst.ERROR+"You cannot remove a permanent room with this command. Please check `"+SpConst.PREFIX+"room permanent help`", event);
        return false;
    }
    boolean same = channel.getId().equals(event.getTextChannel().getId());
    String name = channel.getName();
    Guild guild = event.getGuild();
    try{
        channel.getManager().delete();
    }catch(Exception e){
        Sender.sendResponse(SpConst.WARNING+"I failed to remove the room.", event);
        return false;
    }
    
    if(!same)
        Sender.sendResponse(SpConst.SUCCESS+"You have removed \""+channel.getName()+"\"", event);
    rooms.remove(channel.getId());
    handler.submitText(Feeds.Type.SERVERLOG, guild, "\uD83D\uDCFA Text channel **"+name+
            "** (ID:"+channel.getId()+") has been removed by **"+event.getAuthor().getUsername()+"** (ID:"+event.getAuthor().getId()+")");
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:41,代码来源:Room.java

示例15: execute

import net.dv8tion.jda.entities.TextChannel; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    TextChannel channel = (TextChannel)(args[0]);
    if(channel==null)
        channel = event.getTextChannel();
    String info = "\uD83D\uDCFA Information about <#"+channel.getId()+">\n";
    info += SpConst.LINESTART+"Server: **"+event.getGuild().getName()+"**\n";
    info += SpConst.LINESTART+"Channel ID: **"+channel.getId()+"**\n";
    info += SpConst.LINESTART+"Creation: **"+MiscUtil.getCreationTime(channel.getId()).format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n";
    info += SpConst.LINESTART+"Num Users: **"+channel.getUsers().size()+"**";
    if(channel.getTopic()!=null && !channel.getTopic().trim().equals(""))
        info += "\n"+SpConst.LINESTART+"__**Topic**__:\n"+FormatUtil.demention(channel.getTopic());
    Sender.sendResponse(info, event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:16,代码来源:ChannelCmd.java


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