本文整理汇总了Java中net.dv8tion.jda.core.AccountType.CLIENT属性的典型用法代码示例。如果您正苦于以下问题:Java AccountType.CLIENT属性的具体用法?Java AccountType.CLIENT怎么用?Java AccountType.CLIENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.dv8tion.jda.core.AccountType
的用法示例。
在下文中一共展示了AccountType.CLIENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessage
public Message createMessage(JSONObject jsonObject, boolean exceptionOnMissingUser)
{
final long channelId = jsonObject.getLong("channel_id");
MessageChannel chan = api.getTextChannelById(channelId);
if (chan == null)
chan = api.getPrivateChannelById(channelId);
if (chan == null)
chan = api.getFakePrivateChannelMap().get(channelId);
if (chan == null && api.getAccountType() == AccountType.CLIENT)
chan = api.asClient().getGroupById(channelId);
if (chan == null)
throw new IllegalArgumentException(MISSING_CHANNEL);
return createMessage(jsonObject, chan, exceptionOnMissingUser);
}
示例2: onMessageReceived
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getMessage().getRawContent().startsWith(jba.getPrefix(event.getGuild())) &&
(jba.getClient().getAccountType() == AccountType.BOT && !event.getAuthor().isBot() || jba.getClient().getAccountType() == AccountType.CLIENT && event.getMessage()
.getAuthor().getId().equals(jba.getClient().getSelfUser().getId()))) {
String message = event.getMessage().getRawContent();
String command = message.replaceFirst(Pattern.quote(jba.getPrefix(event.getGuild())), "");
String[] args = new String[0];
if (message.contains(" ")) {
command = command.substring(0, command.indexOf(" "));
args = message.substring(message.indexOf(" ") + 1).split(" ");
}
for (Command cmd : jba.getCommands()) {
if (cmd.getCommand().equalsIgnoreCase(command)) {
execute(cmd, args, event);
return;
} else {
for (String alias : cmd.getAliases()) {
if (alias.equalsIgnoreCase(command)) {
execute(cmd, args, event);
return;
}
}
}
}
}
}
示例3: getShardInfo
public ShardInfo getShardInfo() {
int sId = jda.getShardInfo() == null ? 0 : jda.getShardInfo().getShardId();
if(jda.getAccountType() == AccountType.CLIENT) {
return new ShardInfo(0, 1);
} else {
return new ShardInfo(sId, Config.CONFIG.getNumShards());
}
}
示例4: createSelfUser
public SelfUser createSelfUser(JSONObject self)
{
SelfUserImpl selfUser = ((SelfUserImpl) api.getSelfUser());
if (selfUser == null)
{
final long id = self.getLong("id");
selfUser = new SelfUserImpl(id, api);
api.setSelfUser(selfUser);
}
if (!api.getUserMap().containsKey(selfUser.getIdLong()))
api.getUserMap().put(selfUser.getIdLong(), selfUser);
selfUser.setVerified(self.getBoolean("verified"))
.setMfaEnabled(self.getBoolean("mfa_enabled"))
.setName(self.getString("username"))
.setDiscriminator(self.getString("discriminator"))
.setAvatarId(self.optString("avatar", null))
.setBot(Helpers.optBoolean(self, "bot"));
if (this.api.getAccountType() == AccountType.CLIENT)
{
selfUser
.setEmail(self.optString("email", null))
.setMobile(Helpers.optBoolean(self, "mobile"))
.setNitro(Helpers.optBoolean(self, "premium"))
.setPhoneNumber(self.optString("phone", null));
}
return selfUser;
}
示例5: createRelationship
public Relationship createRelationship(JSONObject relationshipJson)
{
if (api.getAccountType() != AccountType.CLIENT)
throw new AccountTypeException(AccountType.CLIENT, "Attempted to create a Relationship but the logged in account is not a CLIENT!");
RelationshipType type = RelationshipType.fromKey(relationshipJson.getInt("type"));
User user;
if (type == RelationshipType.FRIEND)
user = createUser(relationshipJson.getJSONObject("user"));
else
user = createFakeUser(relationshipJson.getJSONObject("user"), true);
Relationship relationship = api.asClient().getRelationshipById(user.getIdLong(), type);
if (relationship == null)
{
switch (type)
{
case FRIEND:
relationship = new FriendImpl(user);
break;
case BLOCKED:
relationship = new BlockedUserImpl(user);
break;
case INCOMING_FRIEND_REQUEST:
relationship = new IncomingFriendRequestImpl(user);
break;
case OUTGOING_FRIEND_REQUEST:
relationship = new OutgoingFriendRequestImpl(user);
break;
default:
return null;
}
api.asClient().getRelationshipMap().put(user.getIdLong(), relationship);
}
return relationship;
}
示例6: isNitro
@Override
public boolean isNitro() throws AccountTypeException
{
if (api.getAccountType() != AccountType.CLIENT)
throw new AccountTypeException(AccountType.CLIENT, "Nitro status retrieval can only be done on CLIENT accounts!");
return this.nitro;
}
示例7: JDAImpl
public JDAImpl(AccountType accountType, String token, SessionController controller, OkHttpClient.Builder httpClientBuilder, WebSocketFactory wsFactory,
boolean autoReconnect, boolean audioEnabled, boolean useShutdownHook, boolean bulkDeleteSplittingEnabled, boolean retryOnTimeout, boolean enableMDC,
int corePoolSize, int maxReconnectDelay, ConcurrentMap<String, String> contextMap)
{
this.accountType = accountType;
this.setToken(token);
this.httpClientBuilder = httpClientBuilder;
this.wsFactory = wsFactory;
this.autoReconnect = autoReconnect;
this.audioEnabled = audioEnabled;
this.shutdownHook = useShutdownHook ? new Thread(this::shutdown, "JDA Shutdown Hook") : null;
this.bulkDeleteSplittingEnabled = bulkDeleteSplittingEnabled;
this.pool = new ScheduledThreadPoolExecutor(corePoolSize, new JDAThreadFactory());
this.maxReconnectDelay = maxReconnectDelay;
this.sessionController = controller == null ? new SessionControllerAdapter() : controller;
if (enableMDC)
this.contextMap = contextMap == null ? new ConcurrentHashMap<>() : contextMap;
else
this.contextMap = null;
this.presence = new PresenceImpl(this);
this.requester = new Requester(this);
this.requester.setRetryOnTimeout(retryOnTimeout);
this.jdaClient = accountType == AccountType.CLIENT ? new JDAClientImpl(this) : null;
this.jdaBot = accountType == AccountType.BOT ? new JDABotImpl(this) : null;
}
示例8: verifyAccountType
private void verifyAccountType(JSONObject userResponse)
{
if (getAccountType() == AccountType.BOT)
{
if (!userResponse.has("bot") || !userResponse.getBoolean("bot"))
throw new AccountTypeException(AccountType.BOT, "Attempted to login as a BOT with a CLIENT token!");
}
else
{
if (userResponse.has("bot") && userResponse.getBoolean("bot"))
throw new AccountTypeException(AccountType.CLIENT, "Attempted to login as a CLIENT with a BOT token!");
}
}
示例9: getEmail
@Override
public String getEmail() throws AccountTypeException
{
if (api.getAccountType() != AccountType.CLIENT)
throw new AccountTypeException(AccountType.CLIENT, "Email retrieval can only be done on CLIENT accounts!");
return email;
}
示例10: getPhoneNumber
@Override
public String getPhoneNumber() throws AccountTypeException
{
if (api.getAccountType() != AccountType.CLIENT)
throw new AccountTypeException(AccountType.CLIENT, "Phone number retrieval can only be done on CLIENT accounts!");
return this.phoneNumber;
}
示例11: isMobile
@Override
public boolean isMobile() throws AccountTypeException
{
if (api.getAccountType() != AccountType.CLIENT)
throw new AccountTypeException(AccountType.CLIENT, "Mobile app retrieval can only be done on CLIENT accounts!");
return this.mobile;
}
示例12: handleMessageEmbed
private Long handleMessageEmbed(JSONObject content)
{
EntityBuilder builder = api.getEntityBuilder();
final long messageId = content.getLong("id");
final long channelId = content.getLong("channel_id");
LinkedList<MessageEmbed> embeds = new LinkedList<>();
MessageChannel channel = api.getTextChannelMap().get(channelId);
if (channel == null)
channel = api.getPrivateChannelMap().get(channelId);
if (channel == null)
channel = api.getFakePrivateChannelMap().get(channelId);
if (channel == null && api.getAccountType() == AccountType.CLIENT)
channel = api.asClient().getGroupById(channelId);
if (channel == null)
{
api.getEventCache().cache(EventCache.Type.CHANNEL, channelId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("Received message update for embeds for a channel/group that JDA does not have cached yet.");
return null;
}
JSONArray embedsJson = content.getJSONArray("embeds");
for (int i = 0; i < embedsJson.length(); i++)
{
embeds.add(builder.createMessageEmbed(embedsJson.getJSONObject(i)));
}
if (channel instanceof TextChannel)
{
TextChannel tChannel = (TextChannel) channel;
if (api.getGuildLock().isLocked(tChannel.getGuild().getIdLong()))
return tChannel.getGuild().getIdLong();
api.getEventManager().handle(
new GuildMessageEmbedEvent(
api, responseNumber,
messageId, tChannel, embeds));
}
else if (channel instanceof PrivateChannel)
{
api.getEventManager().handle(
new PrivateMessageEmbedEvent(
api, responseNumber,
messageId, (PrivateChannel) channel, embeds));
}
else
{
api.getEventManager().handle(
new GroupMessageEmbedEvent(
api, responseNumber,
messageId, (Group) channel, embeds));
}
//Combo event
api.getEventManager().handle(
new MessageEmbedEvent(
api, responseNumber,
messageId, channel, embeds));
return null;
}
示例13: guildLoadComplete
public void guildLoadComplete(JSONObject content)
{
api.getClient().setChunkingAndSyncing(false);
EntityBuilder builder = api.getEntityBuilder();
JSONArray privateChannels = content.getJSONArray("private_channels");
if (api.getAccountType() == AccountType.CLIENT)
{
JSONArray relationships = content.getJSONArray("relationships");
JSONArray presences = content.getJSONArray("presences");
JSONObject notes = content.getJSONObject("notes");
JSONArray readstates = content.has("read_state") ? content.getJSONArray("read_state") : null;
JSONArray guildSettings = content.has("user_guild_settings") ? content.getJSONArray("user_guild_settings") : null;
for (int i = 0; i < relationships.length(); i++)
{
JSONObject relationship = relationships.getJSONObject(i);
Relationship r = builder.createRelationship(relationship);
if (r == null)
JDAImpl.LOG.error("Provided relationship in READY with an unknown type! JSON: {}", relationship);
}
for (int i = 0; i < presences.length(); i++)
{
JSONObject presence = presences.getJSONObject(i);
String userId = presence.getJSONObject("user").getString("id");
FriendImpl friend = (FriendImpl) api.asClient().getFriendById(userId);
if (friend == null)
WebSocketClient.LOG.warn("Received a presence in the Presences array in READY that did not correspond to a cached Friend! JSON: {}", presence);
else
builder.createPresence(friend, presence);
}
}
for (int i = 0; i < privateChannels.length(); i++)
{
JSONObject chan = privateChannels.getJSONObject(i);
ChannelType type = ChannelType.fromId(chan.getInt("type"));
switch (type)
{
case PRIVATE:
builder.createPrivateChannel(chan);
break;
case GROUP:
builder.createGroup(chan);
break;
default:
WebSocketClient.LOG.warn("Received a Channel in the priv_channels array in READY of an unknown type! JSON: {}", type);
}
}
api.getClient().ready();
}
示例14: setupHandlers
private void setupHandlers()
{
final SocketHandler.NOPHandler nopHandler = new SocketHandler.NOPHandler(api);
handlers.put("CHANNEL_CREATE", new ChannelCreateHandler(api));
handlers.put("CHANNEL_DELETE", new ChannelDeleteHandler(api));
handlers.put("CHANNEL_UPDATE", new ChannelUpdateHandler(api));
handlers.put("GUILD_BAN_ADD", new GuildBanHandler(api, true));
handlers.put("GUILD_BAN_REMOVE", new GuildBanHandler(api, false));
handlers.put("GUILD_CREATE", new GuildCreateHandler(api));
handlers.put("GUILD_DELETE", new GuildDeleteHandler(api));
handlers.put("GUILD_EMOJIS_UPDATE", new GuildEmojisUpdateHandler(api));
handlers.put("GUILD_MEMBER_ADD", new GuildMemberAddHandler(api));
handlers.put("GUILD_MEMBER_REMOVE", new GuildMemberRemoveHandler(api));
handlers.put("GUILD_MEMBER_UPDATE", new GuildMemberUpdateHandler(api));
handlers.put("GUILD_MEMBERS_CHUNK", new GuildMembersChunkHandler(api));
handlers.put("GUILD_ROLE_CREATE", new GuildRoleCreateHandler(api));
handlers.put("GUILD_ROLE_DELETE", new GuildRoleDeleteHandler(api));
handlers.put("GUILD_ROLE_UPDATE", new GuildRoleUpdateHandler(api));
handlers.put("GUILD_SYNC", new GuildSyncHandler(api));
handlers.put("GUILD_UPDATE", new GuildUpdateHandler(api));
handlers.put("MESSAGE_CREATE", new MessageCreateHandler(api));
handlers.put("MESSAGE_DELETE", new MessageDeleteHandler(api));
handlers.put("MESSAGE_DELETE_BULK", new MessageBulkDeleteHandler(api));
handlers.put("MESSAGE_REACTION_ADD", new MessageReactionHandler(api, true));
handlers.put("MESSAGE_REACTION_REMOVE", new MessageReactionHandler(api, false));
handlers.put("MESSAGE_REACTION_REMOVE_ALL", new MessageReactionBulkRemoveHandler(api));
handlers.put("MESSAGE_UPDATE", new MessageUpdateHandler(api));
handlers.put("PRESENCE_UPDATE", new PresenceUpdateHandler(api));
handlers.put("READY", new ReadyHandler(api));
handlers.put("TYPING_START", new TypingStartHandler(api));
handlers.put("USER_UPDATE", new UserUpdateHandler(api));
handlers.put("VOICE_SERVER_UPDATE", new VoiceServerUpdateHandler(api));
handlers.put("VOICE_STATE_UPDATE", new VoiceStateUpdateHandler(api));
// Unused events
handlers.put("CHANNEL_PINS_ACK", nopHandler);
handlers.put("CHANNEL_PINS_UPDATE", nopHandler);
handlers.put("GUILD_INTEGRATIONS_UPDATE", nopHandler);
handlers.put("PRESENCES_REPLACE", nopHandler);
handlers.put("WEBHOOKS_UPDATE", nopHandler);
if (api.getAccountType() == AccountType.CLIENT)
{
handlers.put("CALL_CREATE", new CallCreateHandler(api));
handlers.put("CALL_DELETE", new CallDeleteHandler(api));
handlers.put("CALL_UPDATE", new CallUpdateHandler(api));
handlers.put("CHANNEL_RECIPIENT_ADD", new ChannelRecipientAddHandler(api));
handlers.put("CHANNEL_RECIPIENT_REMOVE", new ChannelRecipientRemoveHandler(api));
handlers.put("RELATIONSHIP_ADD", new RelationshipAddHandler(api));
handlers.put("RELATIONSHIP_REMOVE", new RelationshipRemoveHandler(api));
// Unused client events
handlers.put("MESSAGE_ACK", nopHandler);
}
}
示例15: handleInternally
@Override
protected Long handleInternally(JSONObject content)
{
JSONObject emoji = content.getJSONObject("emoji");
final long userId = content.getLong("user_id");
final long messageId = content.getLong("message_id");
final long channelId = content.getLong("channel_id");
final Long emojiId = emoji.isNull("id") ? null : emoji.getLong("id");
String emojiName = emoji.optString("name", null);
final boolean emojiAnimated = emoji.optBoolean("animated");
if (emojiId == null && emojiName == null)
{
WebSocketClient.LOG.debug("Received a reaction {} with no name nor id. json: {}",
JDALogger.getLazyString(() -> add ? "add" : "remove"), content);
return null;
}
User user = api.getUserById(userId);
if (user == null)
user = api.getFakeUserMap().get(userId);
if (user == null)
{
api.getEventCache().cache(EventCache.Type.USER, userId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("Received a reaction for a user that JDA does not currently have cached");
return null;
}
MessageChannel channel = api.getTextChannelById(channelId);
if (channel == null)
{
channel = api.getPrivateChannelById(channelId);
}
if (channel == null)
{
channel = api.getFakePrivateChannelMap().get(channelId);
}
if (channel == null && api.getAccountType() == AccountType.CLIENT)
{
channel = api.asClient().getGroupById(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");
return null;
}
MessageReaction.ReactionEmote rEmote;
if (emojiId != null)
{
Emote emote = api.getEmoteById(emojiId);
if (emote == null)
{
if (emojiName != null)
{
emote = new EmoteImpl(emojiId, api).setAnimated(emojiAnimated).setName(emojiName);
}
else
{
WebSocketClient.LOG.debug("Received a reaction {} with a null name. json: {}",
JDALogger.getLazyString(() -> add ? "add" : "remove"), content);
return null;
}
}
rEmote = new MessageReaction.ReactionEmote(emote);
}
else
{
rEmote = new MessageReaction.ReactionEmote(emojiName, null, api);
}
MessageReaction reaction = new MessageReaction(channel, rEmote, messageId, user.equals(api.getSelfUser()), -1);
if (add)
onAdd(reaction, user);
else
onRemove(reaction, user);
return null;
}