本文整理匯總了Java中net.dv8tion.jda.core.exceptions.RateLimitedException類的典型用法代碼示例。如果您正苦於以下問題:Java RateLimitedException類的具體用法?Java RateLimitedException怎麽用?Java RateLimitedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RateLimitedException類屬於net.dv8tion.jda.core.exceptions包,在下文中一共展示了RateLimitedException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
//Code by ZekroTJA(github.com/ZekroTJA)
StartArgumentHandler.args = args;
//MY CODE
builder = new JDABuilder(AccountType.BOT)
.setToken(SECRETS.TOKEN)
.setAudioEnabled(true)
.setAutoReconnect(true)
.setStatus(STATICS.STATUS)
.setGame(Game.of(STATICS.CUSTOM_MESSAGE + " | _help | coded by Lee", "http://twitch.tv/lordleeyt"))
;
initializeListeners();
initializeCommands();
SQL.connect();
LVL.connect();
try {
builder.buildBlocking();
} catch (InterruptedException | RateLimitedException | LoginException e) {
e.printStackTrace();
}
}
示例2: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
if (args.length == 0 || args.length == 1) {
sendUsage(message, charrizard.getSettings().getPrefix() + "statistics <bot|guild>");
return;
}
switch (args[1]) {
case "bot":
EmbedBuilder builder = getEmbedBuilder()
.addField("Servers", String.valueOf(charrizard.getDiscordAPI().getGuilds().size()), true)
.addField("Clients", String.valueOf(charrizard.getDiscordAPI().getUsers().size()), true)
.addField("Memory",
"Free: " + numberFormat.format(runtime.freeMemory() / 1024) + " KB" +
"\nAllocated: " + numberFormat.format(runtime.totalMemory() / 1024) + " KB" +
"\nMax: " + numberFormat.format(runtime.maxMemory() / 1024) + " KB", true);
sendEmbedMessage(message, builder);
break;
case "guild":
handleGuild(message, args);
break;
default:
sendUsage(message, charrizard.getSettings().getPrefix() + "statistics <bot|guild>");
break;
}
}
示例3: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
if (args.length < 2) {
sendUsage(message, charrizard.getSettings().getPrefix() + "audio <open/close/queue>");
return;
}
switch (args[1]) {
case "open":
open(message, args);
break;
case "close":
close(message, args);
break;
case "queue":
queue(message, args);
break;
default:
sendUsage(message, charrizard.getSettings().getPrefix() + "audio <open/close/queue>");
break;
}
}
示例4: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
if (args.length < 2) {
sendUsage(message, charrizard.getSettings().getPrefix() + "minecraft <status|server>");
return;
}
switch (args[1]) {
case "server":
checkServer(message, args);
break;
case "status":
checkStatus(message);
break;
default:
sendUsage(message, charrizard.getSettings().getPrefix() + "minecraft <status|server>");
break;
}
}
示例5: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
if (args.length != 2) {
sendUsage(message, charrizard.getSettings().getPrefix() + "cat <random|image|gif>");
return;
}
KiciusieMode mode;
try {
mode = KiciusieMode.valueOf(args[1].toUpperCase());
} catch (IllegalArgumentException iae) {
sendUsage(message, charrizard.getSettings().getPrefix() + "cat <random|image|gif>");
return;
}
try {
KiciusieResponse response = kiciusieResponses.call(mode);
EmbedBuilder builder = getEmbedBuilder()
.addField("Random cat", "powered by kiciusie.pl", true)
.setImage(response.getImageUrl());
sendEmbedMessage(message, builder);
} catch (ResponseException e) {
sendError(message, "An error occurred while connecting with " + e.getUrl());
}
}
示例6: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
TextChannel textChannel = message.getChannel();
if (args.length == 0 || args.length == 1) {
sendUsage(message, "!discord <user|guild|icons>");
return;
}
switch (args[1]) {
case "user":
this.checkUser(message, args);
break;
case "guild":
this.checkGuild(message, args);
break;
case "icons":
this.checkIcons(message, args);
break;
default:
sendUsage(message, "!discord <user|guild|icons>");
break;
}
}
示例7: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
Set<Command> commands = charrizard.getCommandCaller().getCommands();
String prefix = charrizard.getSettings().getPrefix();
StringBuilder labels = new StringBuilder();
StringBuilder descs = new StringBuilder();
for (Command command : commands) {
labels.append(prefix).append(command.getLabel()).append("\n");
descs.append(command.getDescription()).append("\n");
}
String ls = labels.toString();
String ds = descs.toString();
EmbedBuilder builder = getEmbedBuilder()
.setColor(new Color(230, 126, 34))
.addField("Command", ls.substring(0, ls.length() - 1), true)
.addField("Description", ds.substring(0, ds.length() - 1), true);
sendEmbedMessage(message, builder);
}
示例8: handle
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void handle(CMessage message, String[] args) throws RateLimitedException {
if (args.length < 2) {
sendUsage(message, "!reputation <info|reset>");
return;
}
switch (args[1]) {
case "info":
infoArgument(message, args);
break;
case "reset":
resetArgument(message, args);
break;
default:
sendUsage(message, "!reputation <info|reset>");
break;
}
}
示例9: start
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
public void start() throws RateLimitedException, InterruptedException, LoginException {
this.discordAPI = new JDABuilder(AccountType.BOT)
.setToken(settings.getToken())
.setGame(new GameImpl(settings.getGame(), settings.getGameUrl(), settings.isTwitch() ? Game.GameType.TWITCH : Game.GameType.DEFAULT))
.addListener(new EventCaller(this))
.setAutoReconnect(true)
.setAudioEnabled(true)
.setBulkDeleteSplittingEnabled(false)
.buildBlocking();
if (settings.getRedis().isEnabled()) {
redisConnection.start();
keepDataThread.start();
}
initCommands();
initListeners();
}
示例10: buildAsync
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public JDA buildAsync() throws LoginException, IllegalArgumentException, RateLimitedException {
OkHttpClient.Builder httpClientBuilder = this.httpClientBuilder == null ? new OkHttpClient.Builder() : this.httpClientBuilder;
WebSocketFactory wsFactory = this.wsFactory == null ? new WebSocketFactory() : this.wsFactory;
ClientJDA jda = new ClientJDA(accountType, httpClientBuilder, wsFactory, shardRateLimiter,
autoReconnect, enableVoice, enableShutdownHook, enableBulkDeleteSplitting,
requestTimeoutRetry, corePoolSize, maxReconnectDelay, gatewayClient);
if(eventManager != null)
jda.setEventManager(eventManager);
if(audioSendFactory != null)
jda.setAudioSendFactory(audioSendFactory);
listeners.forEach(jda::addEventListener);
jda.setStatus(JDA.Status.INITIALIZED); //This is already set by JDA internally, but this is to make sure the listeners catch it.
// Set the presence information before connecting to have the correct information ready when sending IDENTIFY
((PresenceImpl) jda.getPresence())
.setCacheGame(game)
.setCacheIdle(idle)
.setCacheStatus(status);
jda.login(token, shardInfo, reconnectQueue);
return jda;
}
示例11: login
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public void login(String token, ShardInfo shardInfo, SessionReconnectQueue reconnectQueue) throws LoginException, RateLimitedException {
setStatus(Status.LOGGING_IN);
if(token == null || token.isEmpty()) throw new LoginException("Provided token was null or empty!");
setToken(token);
verifyToken();
this.shardInfo = shardInfo;
JDAImpl.LOG.info("Login Successful!");
client = new ClientWebSocketClient(this, reconnectQueue, gatewayClient);
client.send(new JSONObject()
.put("d", presence.getFullPresence())
.put("op", WebSocketCode.PRESENCE).toString());
if(shutdownHook != null) {
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
}
示例12: buildAsync
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
@Override
public JDA buildAsync() throws LoginException, IllegalArgumentException, RateLimitedException {
OkHttpClient.Builder httpClientBuilder = this.httpClientBuilder == null ? new OkHttpClient.Builder() : this.httpClientBuilder;
WebSocketFactory wsFactory = this.wsFactory == null ? new WebSocketFactory() : this.wsFactory;
ServerJDA jda = new ServerJDA(accountType, httpClientBuilder, wsFactory, shardRateLimiter,
autoReconnect, enableVoice, enableShutdownHook, enableBulkDeleteSplitting,
requestTimeoutRetry, corePoolSize, maxReconnectDelay, gatewayServer);
if(eventManager != null)
jda.setEventManager(eventManager);
if(audioSendFactory != null)
jda.setAudioSendFactory(audioSendFactory);
listeners.forEach(jda::addEventListener);
jda.setStatus(JDA.Status.INITIALIZED); //This is already set by JDA internally, but this is to make sure the listeners catch it.
// Set the presence information before connecting to have the correct information ready when sending IDENTIFY
((PresenceImpl) jda.getPresence())
.setCacheGame(game)
.setCacheIdle(idle)
.setCacheStatus(status);
jda.login(token, shardInfo, reconnectQueue);
return jda;
}
示例13: getUserFromBearer
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
public static User getUserFromBearer(JDA jda, String token) {
try {
JSONObject user = Unirest.get(Requester.DISCORD_API_PREFIX + "/users/@me")
.header("Authorization", "Bearer " + token)
.header("User-agent", USER_AGENT)
.asJson()
.getBody()
.getObject();
if(user.has("id")){
return jda.retrieveUserById(user.getString("id")).complete(true);
}
} catch (UnirestException | RateLimitedException ignored) {}
return null;
}
示例14: start
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
public void start() throws LoginException, InterruptedException, RateLimitedException {
running = true;
// init logger
AnsiConsole.systemInstall();
log = Logger.getLogger("Kyoko");
log.setUseParentHandlers(false);
ColoredFormatter formatter = new ColoredFormatter();
ConsoleHandler handler = new ConsoleHandler();
handler.setFormatter(formatter);
log.addHandler(handler);
log.info("Kyoko v" + Constants.VERSION + " is starting...");
i18n.loadMessages();
JDABuilder builder = new JDABuilder(AccountType.BOT);
if (settings.getToken() != null) {
if (settings.getToken().equalsIgnoreCase("Change me")) {
System.out.println("No token specified, please set it in config.json");
System.exit(1);
}
builder.setToken(settings.getToken());
}
boolean gameEnabled = false;
if (settings.getGame() != null && !settings.getGame().isEmpty()) {
gameEnabled = true;
builder.setGame(Game.of("booting..."));
}
builder.setAutoReconnect(true);
builder.setBulkDeleteSplittingEnabled(false);
builder.addEventListener(eventHandler);
builder.setAudioEnabled(true);
builder.setStatus(OnlineStatus.IDLE);
jda = builder.buildBlocking();
log.info("Invite link: " + "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot&permissions=" + Constants.PERMISSIONS);
if (gameEnabled) {
Thread t = new Thread(new Kyoko.BlinkThread());
t.start();
}
registerCommands();
}
示例15: Shard
import net.dv8tion.jda.core.exceptions.RateLimitedException; //導入依賴的package包/類
public Shard(String token, Channel channel, int shardId, int totalShards, boolean nas) throws LoginException, InterruptedException, RateLimitedException, IOException {
logger = LoggerFactory.getLogger("Shard " + shardId);
this.eventManager = new EventManager(this, shardId);
this.gatewayClient = new GabrielGatewayClient(shardId, channel);
this.builder = new GatewayClientJDABuilder(gatewayClient)
.setToken(token)
.setHttpClientBuilder(new OkHttpClient.Builder()
.connectTimeout(20, TimeUnit.SECONDS)
.readTimeout(20, TimeUnit.SECONDS)
.writeTimeout(20, TimeUnit.SECONDS)
)
.setShardedRateLimiter(RATE_LIMITER)
.setAudioEnabled(GabrielData.config().music)
.setAudioSendFactory(nas ? new NativeAudioSendFactory() : new DefaultSendFactory())
.setCorePoolSize(10)
.setEventManager(eventManager)
.setIdle(true)
.addEventListener(new MainListener(), new ReactListener(), new MusicListener(), new StarboardListener(), new ShitboardListener(), InteractiveOperations.listener(), ReactionOperations.listener());
if(totalShards > 1) {
builder.useSharding(shardId, totalShards);
}
startJDA();
}