client permissions failing to resolve in channel

I just upgraded from: DiscordJS 14.8.0 > 14.18.0 Sapphire 4.2.2 > 5.3.3 I am running into an issue where any command that has requiredClientPermissions specified simply outputs:
I was unable to resolve my permissions in the chat input command invocation channel.
We ran into this issue a long ways back here: https://discord.com/channels/737141877803057244/1083064722355650641/1083169340259581973 which turned out to be a bug due to the age of our application. I am thinking this might be a regression in 5.x.x . Sample command constructor with issue:
constructor(context, options) {
super(context, {
...options,
requiredClientPermissions: [PermissionFlagsBits.EmbedLinks],
});
}
constructor(context, options) {
super(context, {
...options,
requiredClientPermissions: [PermissionFlagsBits.EmbedLinks],
});
}
Solution:
GitHub
fix(ClientPermissions): resolve client permissions for older applic...
In a likely regression of: #616 setting requiredClientPermissions in commands is resulting in consistent fallback messages of: I was unable to resolve my permissions in the chat input command invo...
Jump to solution
7 Replies
Favna
Favna2d ago
Have you also checked all your other dependencies? In particular other sapphire dependencies and discord-api-types? I can guarantee you that EmbedLinks through requiredClientPermissions is not bugged because @Dragonite uses that as well
Deadlystrike
DeadlystrikeOP2d ago
Everything should be up-to-date, I went scorched earth on it. Deleted my lock and node_modules ran npm-check-updates and forced all to latest and re-ran npm i Digging deeper in the ClientPermissions.cjs
async getPermissionsForChannel(channel, messageOrInteraction) {
let permissions = this.dmChannelPermissions;
if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (utilities.isNullish(messageOrInteraction.applicationId)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
}
}
return permissions;
}
async getPermissionsForChannel(channel, messageOrInteraction) {
let permissions = this.dmChannelPermissions;
if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (utilities.isNullish(messageOrInteraction.applicationId)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
}
}
return permissions;
}
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
is what is evaluating, and its returning null
Deadlystrike
DeadlystrikeOP2d ago
Assuming this is a regression in https://github.com/sapphiredev/framework/pull/616/files I patched in
if (utilities.isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
if (utilities.isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
Resulting in:
async getPermissionsForChannel(channel, messageOrInteraction) {
let permissions = this.dmChannelPermissions;
if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (utilities.isNullish(messageOrInteraction.applicationId)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
if (utilities.isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
}
}
return permissions;
}
async getPermissionsForChannel(channel, messageOrInteraction) {
let permissions = this.dmChannelPermissions;
if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (utilities.isNullish(messageOrInteraction.applicationId)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
if (utilities.isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
}
}
return permissions;
}
and no more error.
Favna
Favna2d ago
hm well if you can form it into a pr then submit it I'd say that said, that PR was already in 4.2.1
Deadlystrike
DeadlystrikeOP2d ago
I'll get that started now. Yeah, this was an issue I ran into when switching from our custom commando-fork to saphire which was on 4.2.0 at the time, Vlad snipped that bug so fast and issued 4.2.1 which has served us well for almost 2 years. It looks like the fix got removed a bit over a year later during some refactoring and updates.
Solution
Deadlystrike
Deadlystrike2d ago
GitHub
fix(ClientPermissions): resolve client permissions for older applic...
In a likely regression of: #616 setting requiredClientPermissions in commands is resulting in consistent fallback messages of: I was unable to resolve my permissions in the chat input command invo...
Favna
Favna2d ago
linting is failing @Deadlystrike

Did you find this page helpful?