Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiSky v4.12.2-beta1 #163

Merged
merged 22 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1ed2ba7
:zap: Added a better null check for emojis in react section
ItsTheSky Aug 6, 2023
0b93be3
:zap: Added a null check for 'has role' condition
ItsTheSky Aug 6, 2023
7fcd110
:sparkles: Added way to reply to deferred & waited interactions
ItsTheSky Aug 6, 2023
2bc7975
:zap: DiSky v4.12.0
ItsTheSky Aug 6, 2023
6ae2618
:bug: Fixed event-channel (see https://github.com/DiSkyOrg/DiSky/issu…
ItsTheSky Aug 7, 2023
56b2cc7
:zap: Enhanced bot login error system
ItsTheSky Aug 7, 2023
08f4821
:zap: Added way to use options in entries
ItsTheSky Aug 7, 2023
cf8a762
:zap: Moved scopes/structs loading after Skript verifications
ItsTheSky Aug 7, 2023
d9efb9c
:zap: Removed debug message from BaseScope.java
ItsTheSky Aug 7, 2023
9e83c1d
Merge branch 'master' of https://github.com/DiSkyOrg/DiSky
ItsTheSky Aug 11, 2023
9e046db
:zap: Added a better error try/catch system for the nickname effect
ItsTheSky Aug 26, 2023
046b85f
:sparkles: Added JSON serialization for embeds
ItsTheSky Aug 26, 2023
6b2af78
:fire: Discriminator are no longer defaulted in toString methods
ItsTheSky Aug 26, 2023
f4dedce
:zap: Bumped to JDA v5-beta13
ItsTheSky Aug 26, 2023
f2455fd
:sparkles: Added new media channel type
ItsTheSky Oct 2, 2023
70b7689
:sparkles: Added supports for custom status for bots
ItsTheSky Oct 2, 2023
ba2c590
:zap: Bumped to JDA 5-beta15 / DiSky v4.13.0
ItsTheSky Oct 2, 2023
0319681
Merge remote-tracking branch 'origin/master'
ItsTheSky Oct 5, 2023
ac4361e
Merge remote-tracking branch 'origin/master'
ItsTheSky Jan 6, 2024
286841d
:rocket: Bumped to JDA 19
ItsTheSky Jan 6, 2024
97bc2c9
:zap: Added debug messages for the `open private channel` effect.
ItsTheSky Jan 6, 2024
20601a1
:sparkles: Added way to "reset" the state of a user/role's permission…
ItsTheSky Jan 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ group = 'info.itsthesky'
// Semantic Versioning
def major = '4'
def minor = '12'
def patch = '1'
def patch = '2'

def channel = ''
def channelVersion = ''
def channel = 'beta'
def channelVersion = '1'

version = major + '.' + minor + '.' + patch + (channel ? '-' + channel + channelVersion : '')

Expand All @@ -33,7 +33,7 @@ dependencies {

// Commits: com.github.dv8fromtheworld:jda
// Stable: net.dv8tion:JDA
implementation 'net.dv8tion:JDA:5.0.0-beta.13'
implementation 'net.dv8tion:JDA:5.0.0-beta.19'

// Class manipulation
implementation 'net.bytebuddy:byte-buddy:1.11.22'
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'disky'
rootProject.name = 'DiSky'
4 changes: 4 additions & 0 deletions src/main/java/info/itsthesky/disky/elements/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public static class DiSkyConverters {
Channel::getName,
input -> DiSky.getManager().searchIfAnyPresent(bot -> bot.getInstance().getForumChannelById(input))
).eventExpression().register();
new DiSkyType<>(MediaChannel.class, "mediachannel",
Channel::getName,
input -> DiSky.getManager().searchIfAnyPresent(bot -> bot.getInstance().getMediaChannelById(input))
).eventExpression().register();
new DiSkyType<>(ChannelAction.class, "channelaction",
action -> action.getType().name(),
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import info.itsthesky.disky.core.Utils;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.CacheRestAction;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -42,12 +44,20 @@ public boolean initEffect(Expression<?>[] exprs, int i, Kleenean kleenean, Skrip
@Override
public void runEffect(@NotNull Event e, Bot bot) {
final User rawUser = parseSingle(exprUser, e, null);
DiSky.debug("Opening private channel of user " + rawUser.getId() + " ...");
if (anyNull(this, rawUser, bot)) {
restart();
return;
}

rawUser.openPrivateChannel().queue(this::restart, ex -> {
final CacheRestAction<PrivateChannel> response = rawUser.openPrivateChannel();
DiSky.debug("Request for private channel of user " + rawUser.getId() + " created. sending ...");

response.queue(entity -> {
restart(entity);
DiSky.debug("Private channel of user " + rawUser.getId() + " opened and stored in " + changedVariable.toString(e, true) + ".");
}, ex -> {
DiSky.debug("Cannot open private channel of user " + rawUser.getId() + ": " + ex.getMessage() + ".");
DiSky.getErrorHandler().exception(e, ex);
restart();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNul

@Override
public Class<?> @NotNull [] acceptChange(@NotNull Changer.ChangeMode mode) {
if (mode == Changer.ChangeMode.ADD || mode == Changer.ChangeMode.REMOVE)
return new Class[] {Permission[].class};
if (mode == Changer.ChangeMode.ADD || mode == Changer.ChangeMode.REMOVE || mode == Changer.ChangeMode.REMOVE_ALL)
return new Class[] {Permission[].class, Permission.class};
return new Class[0];
}

Expand All @@ -82,20 +82,25 @@ public void change(@NotNull Event e, @NotNull Object[] delta, @NotNull Changer.C
final Permission[] perms = (Permission[]) delta;
if (EasyElement.anyNull(this, holder, perms))
return;
if (channel != null && !(channel instanceof GuildChannel))
return;

switch (mode) {
case ADD:
if (holder instanceof Role && channel == null)
((Role) holder).getManager().givePermissions(perms).queue();
if (channel != null)
((GuildChannel) channel).getPermissionContainer().upsertPermissionOverride(holder).grant(perms).queue();
channel.getPermissionContainer().upsertPermissionOverride(holder).grant(perms).queue();
break;
case REMOVE:
if (holder instanceof Role && channel == null)
((Role) holder).getManager().revokePermissions(perms).queue();
if (channel != null)
((GuildChannel) channel).getPermissionContainer().upsertPermissionOverride(holder).deny(perms).queue();
channel.getPermissionContainer().upsertPermissionOverride(holder).deny(perms).queue();
break;
case REMOVE_ALL:
if (holder instanceof Role && channel == null)
DiSky.getInstance().getLogger().warning("You cannot clear/reset permissions of a role, without a target channel!");
if (channel != null)
channel.getPermissionContainer().upsertPermissionOverride(holder).clear(perms).queue();
break;
}
}
Expand Down Expand Up @@ -128,7 +133,7 @@ public void change(@NotNull Event e, @NotNull Object[] delta, @NotNull Changer.C
return new Permission[0];
if (channel == null)
return holder.getPermissions().toArray(new Permission[0]);
return holder.getPermissions((GuildChannel) channel).toArray(new Permission[0]);
return holder.getPermissions(channel).toArray(new Permission[0]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class ExprPresence extends SimpleExpression<Activity> {
"watching [to] %string%",
"playing [to] %string%",
"streaming [to] %string% with [the] url %string%",
"competing [to] %string%"
"competing [to] %string%",
"custom status [of] %string%"
);
}

Expand Down Expand Up @@ -64,6 +65,8 @@ public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNul
break;
case 4:
activity = Activity.competing(input);
case 5:
activity = Activity.customStatus(input);
}
return new Activity[] {activity};
}
Expand Down Expand Up @@ -91,6 +94,8 @@ public boolean isSingle() {
return "streaming " + exprInput.toString(e, debug) + " with url " + exprURL.toString(e, debug);
case 4:
return "competing " + exprInput.toString(e, debug);
case 5:
return "custom status " + exprInput.toString(e, debug);
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package info.itsthesky.disky.elements.properties.channels;

import info.itsthesky.disky.api.skript.action.GuildAction;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.requests.restaction.ChannelAction;
import org.jetbrains.annotations.NotNull;

public class NewMediaChannel extends GuildAction<ChannelAction> {

static {
register(
NewMediaChannel.class,
ChannelAction.class,
"media[( |-)]channel"
);
}

@Override
protected ChannelAction create(@NotNull Guild guild) {
return guild.createMediaChannel("default channel");
}

@Override
public String getNewType() {
return "mediachannel";
}

@Override
public Class<? extends ChannelAction> getReturnType() {
return ChannelAction.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class MessageWrapper extends ReceivedMessage {

public MessageWrapper(Message message) {
super(message.getIdLong(),
message.getChannelIdLong(),
message.getGuildIdLong(),
message.getJDA(),
message.getGuild(),
message.getChannel(),
message.getType(),
message.getMessageReference(),
Expand Down
Loading