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


Java DiscordUtils类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:xaanit,项目名称:D4J-OAuth,代码行数:15,代码来源:OAuthUser.java

示例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);
}
 
开发者ID:xaanit,项目名称:D4J-OAuth,代码行数:9,代码来源:OAuthUser.java

示例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);
}
 
开发者ID:xaanit,项目名称:D4J-OAuth,代码行数:7,代码来源:DiscordOAuth.java


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