diff --git a/build.gradle b/build.gradle index 5df2467925..da3f2271f6 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '2.0.1' } -def versionObj = new Version(major: 3, minor: 7, revision: 0) +def versionObj = new Version(major: 3, minor: 7, revision: 1) group = "net.dv8tion" archivesBaseName = "JDA" diff --git a/src/main/java/net/dv8tion/jda/bot/sharding/ShardManager.java b/src/main/java/net/dv8tion/jda/bot/sharding/ShardManager.java index f953dc4edc..9680cbb138 100644 --- a/src/main/java/net/dv8tion/jda/bot/sharding/ShardManager.java +++ b/src/main/java/net/dv8tion/jda/bot/sharding/ShardManager.java @@ -373,6 +373,22 @@ default Guild getGuildById(final String id) return this.getGuildCache().getElementById(id); } + /** + * An unmodifiable list of all {@link net.dv8tion.jda.core.entities.Guild Guilds} that have the same name as the one provided. + *
If there are no {@link net.dv8tion.jda.core.entities.Guild Guilds} with the provided name, then this returns an empty list. + * + * @param name + * The name of the requested {@link net.dv8tion.jda.core.entities.Guild Guilds}. + * @param ignoreCase + * Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.Guild#getName()}. + * + * @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Guild Guilds} that all have the same name as the provided name. + */ + default List getGuildsByName(final String name, final boolean ignoreCase) + { + return this.getGuildCache().getElementsByName(name, ignoreCase); + } + /** * {@link net.dv8tion.jda.core.utils.cache.SnowflakeCacheView SnowflakeCacheView} of * all cached {@link net.dv8tion.jda.core.entities.Guild Guilds} visible to this ShardManager instance. diff --git a/src/main/java/net/dv8tion/jda/core/audio/AudioConnection.java b/src/main/java/net/dv8tion/jda/core/audio/AudioConnection.java index fbe51bf441..083d84f111 100644 --- a/src/main/java/net/dv8tion/jda/core/audio/AudioConnection.java +++ b/src/main/java/net/dv8tion/jda/core/audio/AudioConnection.java @@ -568,6 +568,7 @@ private void setSpeaking(boolean isSpeaking) this.speaking = isSpeaking; JSONObject obj = new JSONObject() .put("speaking", isSpeaking ? 1 : 0) + .put("ssrc", webSocket.getSSRC()) .put("delay", 0); webSocket.send(VoiceCode.USER_SPEAKING_UPDATE, obj); if (!isSpeaking) @@ -656,7 +657,7 @@ public ByteBuffer getNextPacketRaw(boolean changeTalking) } nextPacket = getPacketData(rawAudio); - if (!speaking && changeTalking) + if (!speaking) setSpeaking(true); if (seq + 1 > Character.MAX_VALUE) diff --git a/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java b/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java index 11b2bfff40..c9d9314a32 100644 --- a/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java +++ b/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java @@ -171,9 +171,17 @@ public ChannelAction setNSFW(boolean nsfw) } /** - * Adds a new Role-{@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} + * Adds a new Role or Member {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * for the new Channel. * + *

Example: + *

{@code
+     * Role role = guild.getPublicRole();
+     * EnumSet allow = EnumSet.of(Permission.MESSAGE_READ);
+     * EnumSet deny = EnumSet.of(Permission.MESSAGE_WRITE);
+     * channelAction.addPermissionOverride(role, allow, deny);
+     * }
+ * * @param target * The not-null {@link net.dv8tion.jda.core.entities.Role Role} or {@link net.dv8tion.jda.core.entities.Member Member} for the override * @param allow @@ -182,10 +190,11 @@ public ChannelAction setNSFW(boolean nsfw) * The denied {@link net.dv8tion.jda.core.Permission Permissions} for the override or null * * @throws java.lang.IllegalArgumentException - * If the specified {@link net.dv8tion.jda.core.entities.Role Role} is null - * or not within the same guild. + * If the specified target is null or not within the same guild. * * @return The current ChannelAction, for chaining convenience + * + * @see java.util.EnumSet */ @CheckReturnValue public ChannelAction addPermissionOverride(IPermissionHolder target, Collection allow, Collection deny) @@ -199,11 +208,19 @@ public ChannelAction addPermissionOverride(IPermissionHolder target, Collection< } /** - * Adds a new Role-{@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} + * Adds a new Role or Member {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * for the new Channel. * + *

Example: + *

{@code
+     * Role role = guild.getPublicRole();
+     * long allow = Permission.MESSAGE_READ.getRawValue();
+     * long deny = Permission.MESSAGE_WRITE.getRawValue() | Permission.MESSAGE_ADD_REACTION.getRawValue();
+     * channelAction.addPermissionOverride(role, allow, deny);
+     * }
+ * * @param target - * The not-null {@link net.dv8tion.jda.core.entities.Role Role} for the override + * The not-null {@link net.dv8tion.jda.core.entities.Role Role} or {@link net.dv8tion.jda.core.entities.Member Member} for the override * @param allow * The granted {@link net.dv8tion.jda.core.Permission Permissions} for the override * Use {@link net.dv8tion.jda.core.Permission#getRawValue()} to retrieve these Permissions. @@ -213,7 +230,7 @@ public ChannelAction addPermissionOverride(IPermissionHolder target, Collection< * * @throws java.lang.IllegalArgumentException *
    - *
  • If the specified {@link net.dv8tion.jda.core.entities.Role Role} is null + *
  • If the specified target is null * or not within the same guild.
  • *
  • If one of the provided Permission values is invalid
  • *
@@ -362,14 +379,6 @@ protected void handleResponse(Response response, Request request) request.onSuccess(channel); } - protected void checkPermissions(Permission... permissions) - { - if (permissions == null) - return; - for (Permission p : permissions) - Checks.notNull(p, "Permissions"); - } - protected void checkPermissions(Collection permissions) { if (permissions == null)