• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Request类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMessageById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@CheckReturnValue
public RestAction<MessageJson> getMessageById(long channelId, long messageId)
{
    Route.CompiledRoute route = Route.Messages.GET_MESSAGE.compile(Long.toString(channelId), Long.toString(messageId));
    return new RestAction<MessageJson>(fakeJDA, route)
    {
        @Override
        protected void handleResponse(Response response, Request<MessageJson> request)
        {
            if (response.isOk())
                request.onSuccess(new MessageJson(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:17,代码来源:RestJDA.java


示例2: handleResponse

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
protected void handleResponse(Response response, Request<List<Long>> request)
{
    if (!response.isOk())
    {
        request.onFailure(response);
        return;
    }
    final JSONArray array = response.getArray();
    final List<Long> users = new LinkedList<>();
    for (int i = 0; i < array.length(); i++)
    {
        JSONObject user = array.getJSONObject(i);
        long id = user.getLong("id");
        last = id;
        if(user.has("bot") && user.getBoolean("bot"))
            continue;
        users.add(id);
        if (useCache)
            cached.add(id);
    }

    request.onSuccess(users);
}
 
开发者ID:jagrosh,项目名称:GiveawayBot,代码行数:25,代码来源:EditedReactionPaginationAction.java


示例3: getApplicationById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Application> getApplicationById(String id)
{
    Checks.notEmpty(id, "id");

    Route.CompiledRoute route = Route.Applications.GET_APPLICATION.compile(id);
    return new RestAction<Application>(api, route)
    {
        @Override
        protected void handleResponse(Response response, Request<Application> request)
        {
            if (response.isOk())
                request.onSuccess(api.getEntityBuilder().createApplication(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:19,代码来源:JDAClientImpl.java


示例4: getAuthorizedApplicationById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<AuthorizedApplication> getAuthorizedApplicationById(String id)
{
    Checks.notEmpty(id, "id");

    Route.CompiledRoute route = Route.Applications.GET_AUTHORIZED_APPLICATION.compile(id);
    return new RestAction<AuthorizedApplication>(api, route)
    {
        @Override
        protected void handleResponse(Response response, Request<AuthorizedApplication> request)
        {
            if (response.isOk())
                request.onSuccess(api.getEntityBuilder().createAuthorizedApplication(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:19,代码来源:JDAClientImpl.java


示例5: delete

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Void> delete()
{
    Route.CompiledRoute route = Route.Applications.DELETE_AUTHORIZED_APPLICATION.compile(getAuthId());

    return new RestAction<Void>(this.api, route)
    {
        @Override
        protected void handleResponse(final Response response, final Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:18,代码来源:AuthorizedApplicationImpl.java


示例6: createBot

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Application.Bot> createBot()
{
    if (this.hasBot())
        return new RestAction.EmptyRestAction<>(getJDA(), this.bot);

    return new RestAction<Application.Bot>(this.api, Route.Applications.CREATE_BOT.compile(getId()))
    {
        @Override
        protected void handleResponse(final Response response, final Request<Application.Bot> request)
        {
            if (response.isOk())
                request.onSuccess(ApplicationImpl.this.bot = new BotImpl(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:19,代码来源:ApplicationImpl.java


示例7: resetSecret

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Application> resetSecret()
{
    Route.CompiledRoute route = Route.Applications.RESET_BOT_TOKEN.compile(getId());
    return new RestAction<Application>(this.api, route)
    {
        @Override
        protected void handleResponse(final Response response, final Request<Application> request)
        {
            if (response.isOk())
                request.onSuccess(ApplicationImpl.this.updateFromJson(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:ApplicationImpl.java


示例8: resetToken

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Bot> resetToken()
{
    Route.CompiledRoute route = Route.Applications.RESET_BOT_TOKEN.compile(getId());
    return new RestAction<Bot>(getJDA(), route)
    {
        @Override
        protected void handleResponse(final Response response, final Request<Bot> request)
        {
            if (response.isOk())
                request.onSuccess(BotImpl.this.updateFromJson(response.getObject()));
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:ApplicationImpl.java


示例9: getApplicationInfo

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<ApplicationInfo> getApplicationInfo()
{
    Route.CompiledRoute route = Route.Applications.GET_BOT_APPLICATION.compile();
    return new RestAction<ApplicationInfo>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<ApplicationInfo> request)
        {
            if (!response.isOk())
            {
                request.onFailure(response);
                return;
            }

            ApplicationInfo info = api.getEntityBuilder().createApplicationInfo(response.getObject());
            JDABotImpl.this.clientId = info.getId();
            request.onSuccess(info);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:22,代码来源:JDABotImpl.java


示例10: getGateway

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public String getGateway(JDA api)
{
    Route.CompiledRoute route = Route.Misc.GATEWAY.compile();
    return new RestAction<String>(api, route)
    {
        @Override
        protected void handleResponse(Response response, Request<String> request)
        {
            if (response.isOk())
                request.onSuccess(response.getObject().getString("url"));
            else
                request.onFailure(response);
        }
    }.complete();
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:SessionControllerAdapter.java


示例11: handleResponse

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
protected void handleResponse(Response response, Request<MessageHistory> request)
{
    if (!response.isOk())
    {
        request.onFailure(response);
        return;
    }
    final MessageHistory result = new MessageHistory(channel);
    final JSONArray array = response.getArray();
    final EntityBuilder builder = api.getEntityBuilder();
    for (int i = 0; i < array.length(); i++)
    {
        try
        {
            JSONObject obj = array.getJSONObject(i);
            result.history.put(obj.getLong("id"), builder.createMessage(obj, channel, false));
        }
        catch (JSONException | NullPointerException e)
        {
            LOG.warn("Encountered exception in MessagePagination", e);
        }
    }
    request.onSuccess(result);
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:26,代码来源:MessageHistory.java


示例12: delete

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
    Route.CompiledRoute route = Route.Webhooks.DELETE_TOKEN_WEBHOOK.compile(getId(), token);
    return new AuditableRestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:WebhookImpl.java


示例13: delete

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
    checkPermission(Permission.MANAGE_CHANNEL);

    Route.CompiledRoute route = Route.Channels.DELETE_CHANNEL.compile(getId());
    return new AuditableRestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:19,代码来源:AbstractChannelImpl.java


示例14: delete

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
    if (!channel.getGuild().getSelfMember().hasPermission(channel, Permission.MANAGE_PERMISSIONS))
        throw new InsufficientPermissionException(Permission.MANAGE_PERMISSIONS);

    String targetId = isRoleOverride() ? getRole().getId() : getMember().getUser().getId();
    Route.CompiledRoute route = Route.Channels.DELETE_PERM_OVERRIDE.compile(channel.getId(), targetId);
    return new AuditableRestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:21,代码来源:PermissionOverrideImpl.java


示例15: close

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Void> close()
{
    Route.CompiledRoute route = Route.Channels.DELETE_CHANNEL.compile(getId());
    return new RestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:PrivateChannelImpl.java


示例16: deleteWebhookById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> deleteWebhookById(String id)
{
    Checks.notEmpty(id, "webhook id");

    if (!guild.getSelfMember().hasPermission(this, Permission.MANAGE_WEBHOOKS))
        throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS);

    Route.CompiledRoute route = Route.Webhooks.DELETE_WEBHOOK.compile(id);
    return new AuditableRestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:22,代码来源:TextChannelImpl.java


示例17: clearReactionsById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Void> clearReactionsById(String messageId)
{
    Checks.notEmpty(messageId, "Message ID");

    checkPermission(Permission.MESSAGE_MANAGE);
    final Route.CompiledRoute route = Route.Messages.REMOVE_ALL_REACTIONS.compile(getId(), messageId);
    return new RestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:20,代码来源:TextChannelImpl.java


示例18: removeReactionById

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Void> removeReactionById(String messageId, String unicode, User user)
{
    Checks.noWhitespace(messageId, "Message ID");
    Checks.noWhitespace(unicode, "Unicode emoji");
    Checks.notNull(user, "User");
    if (!getJDA().getSelfUser().equals(user))
        checkPermission(Permission.MESSAGE_MANAGE);
    final String code = MiscUtil.encodeUTF8(unicode);
    Route.CompiledRoute route;
    if (user.equals(getJDA().getSelfUser()))
        route = Route.Messages.REMOVE_OWN_REACTION.compile(getId(), messageId, code);
    else
        route = Route.Messages.REMOVE_REACTION.compile(getId(), messageId, code, user.getId());
    return new RestAction<Void>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (!response.isOk())
                request.onFailure(response);
            else
                request.onSuccess(null);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:27,代码来源:TextChannelImpl.java


示例19: getPrunableMemberCount

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Integer> getPrunableMemberCount(int days)
{
    if (!isAvailable())
        throw new GuildUnavailableException();
    if (!getSelfMember().hasPermission(Permission.KICK_MEMBERS))
        throw new InsufficientPermissionException(Permission.KICK_MEMBERS);

    if (days < 1)
        throw new IllegalArgumentException("Days amount must be at minimum 1 day.");

    Route.CompiledRoute route = Route.Guilds.PRUNABLE_COUNT.compile(getId()).withQueryParams("days", Integer.toString(days));
    return new RestAction<Integer>(getJDA(), route)
    {
        @Override
        protected void handleResponse(Response response, Request<Integer> request)
        {
            if (response.isOk())
                request.onSuccess(response.getObject().getInt("pruned"));
            else
                request .onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:25,代码来源:GuildImpl.java


示例20: leave

import net.dv8tion.jda.core.requests.Request; //导入依赖的package包/类
@Override
public RestAction<Void> leave()
{
    if (owner.equals(getSelfMember()))
        throw new IllegalStateException("Cannot leave a guild that you are the owner of! Transfer guild ownership first!");

    Route.CompiledRoute route = Route.Self.LEAVE_GUILD.compile(getId());
    return new RestAction<Void>(api, route)
    {
        @Override
        protected void handleResponse(Response response, Request<Void> request)
        {
            if (response.isOk())
                request.onSuccess(null);
            else
                request.onFailure(response);
        }
    };
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:20,代码来源:GuildImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LDAPSearchException类代码示例发布时间:2022-05-23
下一篇:
Java C2dmConstants类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap