本文整理汇总了Java中net.dv8tion.jda.client.entities.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于net.dv8tion.jda.client.entities包,在下文中一共展示了Group类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadGroups
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Batch load a list of Groups
* @param groups
* @return a list of Groups converted to UI elements
*/
public static List<UIChannelListItem> loadGroups(List<Group> groups) {
ArrayList<UIChannelListItem> list = new ArrayList<>();
for (Group g : groups) {
list.add(new UIChannelListItem(g));
}
return list;
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:13,代码来源:UIChannelListItem.java
示例2: addGroups
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Add a list of Groups to the UI
* @param groups the list of Groups to add
*/
public void addGroups(List<Group> groups) {
for (UIChannelListItem item : UIChannelListItem.loadGroups(groups)) {
channelList.add(item, c, 0);
channelItems.put(item.getID(), item);
}
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:11,代码来源:UIChannelList.java
示例3: addGroupsAndPrivateChannels
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public void addGroupsAndPrivateChannels(List<Group> groups, List<PrivateChannel> channels) {
List<UIChannelListItem> uiItems = UIChannelListItem.loadGroups(groups);
uiItems.addAll(UIChannelListItem.loadPrivateChannels(channels));
Collections.sort(uiItems);
for (UIChannelListItem item : uiItems) {
channelList.add(item, c, channelList.getComponentCount());
channelItems.put(item.getID(), item);
}
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:10,代码来源:UIChannelList.java
示例4: getChat
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
private static UIChat getChat(MessageChannel channel) {
if (channel instanceof PrivateChannel) { //If the channel is a private channel...
UIPrivateChat pc;
if (chatWindows.containsKey(channel.getId())) //If the channel has already been opened...
pc = (UIPrivateChat) chatWindows.get(channel.getId()); //Retrieve the UIChat object from chatWindows
else {
pc = new UIPrivateChat((PrivateChannel) channel); //Otherwise, create a new UIChat
chatWindows.put(channel.getId(), pc); //Put it in chatWindows
}
return pc;
} else if (channel instanceof TextChannel) {
UITextChat tc;
TextChannel textChannel = (TextChannel) channel;
if (chatWindows.containsKey(channel.getId()))
tc = (UITextChat) chatWindows.get(channel.getId());
else {
tc = new UITextChat(textChannel);
chatWindows.put(channel.getId(), tc);
}
return tc;
} else if (channel instanceof Group) {
UIGroupChat gc;
Group group = (Group) channel;
if (chatWindows.containsKey(channel.getId()))
gc = (UIGroupChat) chatWindows.get(channel.getId());
else {
gc = new UIGroupChat(group);
chatWindows.put(channel.getId(), gc);
}
return gc;
} else {
return null;
}
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:37,代码来源:TransparentDiscord.java
示例5: getImage
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Returns an image for a generic message channel
* @param channel The channel to retrieve an image for
* @return either a profile image, Guild icon, or group icon depending on the channel type
*/
public static ImageIcon getImage(MessageChannel channel) {
if (channel instanceof PrivateChannel)
return getImage((PrivateChannel) channel);
else if (channel instanceof TextChannel) {
TextChannel tc = (TextChannel) channel;
return getImage(tc.getGuild());
}
else if (channel instanceof Group)
return getImage((Group) channel);
else
return null;
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:18,代码来源:TransparentDiscord.java
示例6: send
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public void send(SendableMessage message)
{
if (jda != null)
{
String actualMessage = "`NMO` " + message.message;
switch (message.targetType)
{
case SERVER:
TextChannel channel = jda.getTextChannelById(message.targetID);
if (channel != null)
{
channel.sendMessage(actualMessage).complete();
}
break;
case GROUP:
Group group = jda.asClient().getGroupById(message.targetID);
if (group != null)
{
group.sendMessage(actualMessage).complete();
}
break;
case USER:
User user = jda.getUserById(message.targetID);
if (user != null)
{
PrivateChannel pchannel = user.openPrivateChannel().complete();
pchannel.sendMessage(actualMessage).complete();
}
break;
}
}
}
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:33,代码来源:IntegrationDiscord.java
示例7: handleInternally
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
@Override
protected Long handleInternally(JSONObject content)
{
final long messageId = content.getLong("message_id");
final long channelId = content.getLong("channel_id");
MessageChannel channel = api.getTextChannelById(channelId);
if (channel == null)
{
api.getEventCache().cache(EventCache.Type.CHANNEL, channelId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("Received a reaction for a channel that JDA does not currently have cached channel_id: {} message_id: {}", channelId, messageId);
return null;
}
IEventManager manager = api.getEventManager();
switch (channel.getType())
{
case TEXT:
manager.handle(
new GuildMessageReactionRemoveAllEvent(
api, responseNumber,
messageId, (TextChannel) channel));
break;
case GROUP:
manager.handle(
new GroupMessageReactionRemoveAllEvent(
api, responseNumber,
messageId, (Group) channel));
}
manager.handle(
new MessageReactionRemoveAllEvent(
api, responseNumber,
messageId, channel));
return null;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:36,代码来源:MessageReactionBulkRemoveHandler.java
示例8: UIChannelListItem
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Constructs a list item around a group
* @param group
*/
public UIChannelListItem(Group group) {
this(group.getId());
StringBuilder name = new StringBuilder();
if (group.getName() == null) {
for (User user : group.getUsers())
name.append(user.getName() + ", ");
name.deleteCharAt(name.length()-1);
name.deleteCharAt(name.length()-1);
} else {
name.append(group.getName());
}
displayName = new JLabel(name.toString());
displayName.setBorder(new EmptyBorder(5,0,0,0));
displayName.setFont(TransparentDiscord.boldFont.deriveFont(Font.PLAIN, 12));
messagePreview = new JLabel();
messagePreview.setFont(TransparentDiscord.defaultFont.deriveFont(Font.PLAIN,12));
try {
Message m = group.getHistory().retrievePast(1).complete().get(0);
messagePreview.setText(m.getAuthor().getName() +": " + m.getContent());
time = m.getCreationTime();
content.add(messagePreview, BorderLayout.CENTER);
} catch (Exception e) {
out.println("Channel " + group.getName() + " does not have any messages");
}
icon = new JLabel(TransparentDiscord.resizeToWidth(TransparentDiscord.getImage(group),ICON_WIDTH));
icon.setBorder(new EmptyBorder(5,5,5,5));
content.add(displayName, BorderLayout.NORTH);
add(content, BorderLayout.CENTER);
add(icon, BorderLayout.WEST);
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
TransparentDiscord.openChat(group);
}
});
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:47,代码来源:UIChannelListItem.java
示例9: UIGroupChat
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Constructs a group chat from the given parameter
* @param group the group to construct this UI around
*/
public UIGroupChat(Group group) {
super();
this.channel = group;
this.messageHistory = group.getHistory();
//Set up gridbag to add new messages
c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
//Get some message history and add it to the message list
//Message history in order from newest to oldest
messageHistory.retrievePast(20).queue(messages -> {
newestGroup = oldestGroup = new UIMessageGroup(messages.get(0));
messageList.add(oldestGroup,c,0);
//Going from newest to oldest...
for (int i = 1; i < messages.size(); i++) {
if (oldestGroup.canAddMessage(messages.get(i))) {
oldestGroup.addMessage(messages.get(i));
}
else {
oldestGroup = new UIMessageGroup(messages.get(i));
messageList.add(oldestGroup,c,0);
}
}
refresh();
scrollToBottom();
doneLoad = true;
});
StringBuilder name = new StringBuilder();
if (group.getName() == null) {
for (User user : group.getUsers())
name.append(user.getName() + ", ");
name.deleteCharAt(name.length()-1);
name.deleteCharAt(name.length()-1);
} else {
name.append(group.getName());
}
add(new UITitleBar(name.toString(), TransparentDiscord.chatWindow), BorderLayout.NORTH);
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:52,代码来源:UIGroupChat.java
示例10: addGroup
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Add a Group to the UI
* @param group the Group to add
*/
public void addGroup(Group group) {
UIChannelListItem item = new UIChannelListItem(group);
channelList.add(item,c,0);
channelItems.put(item.getID(), item);
}
开发者ID:MCPlummet,项目名称:TransparentDiscord,代码行数:10,代码来源:UIChannelList.java
示例11: getGroup
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
@Override
public Group getGroup() {
return message.getGroup();
}
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:5,代码来源:DefaultMessageEvent.java
示例12: getGroup
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public Group getGroup() {
return messageReceivedEvent.getGroup();
}
开发者ID:Svetroid,项目名称:Hobbes-v1,代码行数:4,代码来源:Input.java
示例13: getParameters
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
/**
* Gets the parameters which are used to invoke the executor's method.
*
* @param splitMessage The spit message (index 0: command, index > 0: arguments)
* @param command The command.
* @param event The event.
* @return The parameters which are used to invoke the executor's method.
*/
private Object[] getParameters(String[] splitMessage, SimpleCommand command, MessageReceivedEvent event) {
String[] args = Arrays.copyOfRange(splitMessage, 1, splitMessage.length);
Class<?>[] parameterTypes = command.getMethod().getParameterTypes();
final Object[] parameters = new Object[parameterTypes.length];
int stringCounter = 0;
for (int i = 0; i < parameterTypes.length; i++) { // check all parameters
Class<?> type = parameterTypes[i];
if (type == String.class) {
if (stringCounter++ == 0) {
parameters[i] = splitMessage[0]; // the first split is the command
} else {
if (args.length + 2 > stringCounter) {
// the first string parameter is the command, the other ones are the arguments
parameters[i] = args[stringCounter - 2];
}
}
} else if (type == String[].class) {
parameters[i] = args;
} else if (type == MessageReceivedEvent.class) {
parameters[i] = event;
} else if (type == JDA.class) {
parameters[i] = event.getJDA();
} else if (type == MessageChannel.class) {
parameters[i] = event.getChannel();
} else if (type == Message.class) {
parameters[i] = event.getMessage();
} else if (type == User.class) {
parameters[i] = event.getAuthor();
} else if (type == Member.class) {
parameters[i] = event.getMember();
} else if (type == TextChannel.class) {
parameters[i] = event.getTextChannel();
} else if (type == PrivateChannel.class) {
parameters[i] = event.getPrivateChannel();
} else if (type == MessageChannel.class) {
parameters[i] = event.getChannel();
} else if (type == Channel.class) {
parameters[i] = event.getTextChannel();
} else if (type == Group.class) {
parameters[i] = event.getGroup();
} else if (type == Guild.class) {
parameters[i] = event.getGuild();
} else if (type == Integer.class || type == int.class) {
parameters[i] = event.getResponseNumber();
} else if (type == Object[].class) {
parameters[i] = getObjectsFromString(event.getJDA(), args);
} else {
// unknown type
parameters[i] = null;
}
}
return parameters;
}
开发者ID:BtoBastian,项目名称:sdcf4j,代码行数:62,代码来源:JDA3Handler.java
示例14: handleInternally
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
@Override
protected Long handleInternally(JSONObject content)
{
final long channelId = content.getLong("channel_id");
CallableChannel channel = api.asClient().getGroupById(channelId);
if (channel == null)
channel = api.getPrivateChannelMap().get(channelId);
if (channel == null)
{
api.getEventCache().cache(EventCache.Type.CHANNEL, channelId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("Received CALL_DELETE for a Group/PrivateChannel that is not yet cached. JSON: {}", content);
return null;
}
CallImpl call = (CallImpl) channel.getCurrentCall();
if (call == null)
{
api.getEventCache().cache(EventCache.Type.CALL, channelId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("Received a CALL_DELETE for a Call that is not yet cached. JSON: {}", content);
return null;
}
if (channel instanceof Group)
{
GroupImpl group = (GroupImpl) channel;
group.setCurrentCall(null);
call.getCallUserMap().forEachKey(userId ->
{
api.asClient().getCallUserMap().remove(userId);
return true;
});
}
else
{
PrivateChannelImpl priv = (PrivateChannelImpl) channel;
priv.setCurrentCall(null);
api.asClient().getCallUserMap().remove(priv.getUser().getIdLong());
api.asClient().getCallUserMap().remove(api.getSelfUser().getIdLong());
}
api.getEventManager().handle(
new CallDeleteEvent(
api, responseNumber,
call));
return null;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:47,代码来源:CallDeleteHandler.java
示例15: isGroupCall
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
@Override
public boolean isGroupCall()
{
return callableChannel instanceof Group;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:6,代码来源:CallImpl.java
示例16: getGroup
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
@Override
public Group getGroup()
{
return isGroupCall() ? (Group) callableChannel : null;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:6,代码来源:CallImpl.java
示例17: GroupMessageEmbedEvent
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public GroupMessageEmbedEvent(JDA api, long responseNumber, long messageId, Group group, List<MessageEmbed> embeds)
{
super(api, responseNumber, messageId, group);
this.embeds = embeds;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:6,代码来源:GroupMessageEmbedEvent.java
示例18: GroupMessageDeleteEvent
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public GroupMessageDeleteEvent(JDA api, long responseNumber, long messageId, Group group)
{
super(api, responseNumber, messageId, group);
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:5,代码来源:GroupMessageDeleteEvent.java
示例19: GenericGroupMessageEvent
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public GenericGroupMessageEvent(JDA api, long responseNumber, long messageId, Group group)
{
super(api, responseNumber, group);
this.messageId = messageId;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:6,代码来源:GenericGroupMessageEvent.java
示例20: GenericGroupMessageReactionEvent
import net.dv8tion.jda.client.entities.Group; //导入依赖的package包/类
public GenericGroupMessageReactionEvent(JDA api, long responseNumber, User user, MessageReaction reaction)
{
super(api, responseNumber, reaction.getMessageIdLong(), (Group) reaction.getChannel());
this.issuer = user;
this.reaction = reaction;
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:7,代码来源:GenericGroupMessageReactionEvent.java
注:本文中的net.dv8tion.jda.client.entities.Group类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论