本文整理汇总了Java中sx.blah.discord.api.internal.DiscordUtils类的典型用法代码示例。如果您正苦于以下问题:Java DiscordUtils类的具体用法?Java DiscordUtils怎么用?Java DiscordUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiscordUtils类属于sx.blah.discord.api.internal包,在下文中一共展示了DiscordUtils类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joinGuild
import sx.blah.discord.api.internal.DiscordUtils; //导入依赖的package包/类
@Override
public void joinGuild(IGuild guild) {
checkScope(Scope.GUILDS_JOIN);
refreshTokenIfNeeded();
DiscordUtils.checkPermissions(this.user.getClient(), guild, EnumSet.of(Permissions.CREATE_INVITE));
try {
((DiscordClientImpl) this.user.getClient()).REQUESTS.PATCH.makeRequest(
DiscordEndpoints.GUILDS + guild.getLongID() + "/members/" + user.getStringID(),
DiscordUtils.MAPPER_NO_NULLS.writeValueAsString(new MemberAddRequest.Builder(getAccessToken()).build()));
} catch (JsonProcessingException e) {
Discord4J.LOGGER.error(LogMarkers.HANDLE, "Discord4J Internal Exception", e);
}
}
示例2: joinGuildWithInviteCode
import sx.blah.discord.api.internal.DiscordUtils; //导入依赖的package包/类
@Override
public IInvite joinGuildWithInviteCode(String inviteCode) {
checkScope(Scope.GUILDS_JOIN);
refreshTokenIfNeeded();
InviteObject obj = Requests.GENERAL_REQUESTS.POST.makeRequest(DiscordEndpoints.INVITE + inviteCode, InviteObject.class, new BasicNameValuePair("Authorization", "Bearer " + this.getAccessToken()));
return DiscordUtils.getInviteFromJSON(user.getClient(), obj);
}
示例3: getOAuthUserForRefreshToken
import sx.blah.discord.api.internal.DiscordUtils; //导入依赖的package包/类
@Override
public IOAuthUser getOAuthUserForRefreshToken(String refreshToken) {
AuthorizeUserResponse authorize = Requests.GENERAL_REQUESTS.POST.makeRequest(DiscordEndpoints.OAUTH + "token", String.format("grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s", refreshToken, clientID, clientSecret), AuthorizeUserResponse.class, new BasicNameValuePair("Content-Type", "application/x-www-form-urlencoded"));
IUser user = DiscordUtils.getUserFromJSON(client.getShards().get(0), Requests.GENERAL_REQUESTS.GET.makeRequest(DiscordEndpoints.USERS + "@me", UserObject.class, new BasicNameValuePair("Authorization", "Bearer " + authorize.access_token)));
return addOAuthUser(user, authorize);
}