Skip to content

Commit

Permalink
Replace some magic values with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jedenastka committed Oct 2, 2024
1 parent 91bb748 commit dd5ae94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.aliucord.Utils;
import com.aliucord.utils.GsonUtils;
import com.aliucord.utils.ReflectUtils;
import com.discord.api.channel.Channel;
import com.discord.models.commands.Application;
import com.discord.models.commands.ApplicationCommand;
import com.discord.models.commands.ApplicationCommandKt;
Expand Down Expand Up @@ -90,8 +91,7 @@ public void loadPatches(Context context) throws Throwable {
// Only create a DM index source for bots
var channel = storeChannelsSelected.getSelectedChannel();
var channelType = channel.D();
// Channel type 1 is a DM
if (channelType == 1) {
if (channelType == Channel.DM) {
var user = channel.z().get(0);
var userIsBot = user.e();
if (userIsBot) {
Expand Down Expand Up @@ -244,11 +244,10 @@ private void passCommandData(StoreApplicationCommands storeApplicationCommands,
}
applicationIndexes.add(this.requestApplicationIndex(new ApplicationIndexSourceUser()));
var applicationIndex = new ApplicationIndex(applicationIndexes);
// Remove all commands that aren't slash commands (type 1)
applicationIndex
.applicationCommands
.entrySet()
.removeIf(applicationCommand -> applicationCommand.getValue().type != 1);
.removeIf(applicationCommand -> applicationCommand.getValue().type != RemoteApplicationCommand.TYPE_CHAT_INPUT);
applicationIndex.populateCommandCounts(this.applicationCommandCountField);

var applications = new ArrayList<Application>(applicationIndex.applications.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class RemoteApplicationCommand extends com.discord.models.commands.RemoteApplica
public Permissions permissions_;
public int type;

public static final int TYPE_CHAT_INPUT = 1;

public RemoteApplicationCommand(String id, long applicationId, String name, String description, List<ApplicationCommandOption> options, Permissions permissions, Long guildId, String version, int type) {
super(id, applicationId, name, description, options, guildId, version, null, null, null);
this.permissions_ = permissions;
Expand Down

0 comments on commit dd5ae94

Please sign in to comment.