some1chan
some1chan
Explore posts from servers
SIASapphire - Imagine a framework
Created by chillihero on 2/18/2023 in #sapphire-support
Will using the new plugin-utilities-store enable HMR for this Helper files?
heya, im using @sapphire/plugin-utilities right now and HMR doesnt seem to be working. The utilities do import, however, and otherwise for other pieces like commands, HMR works. Anyone else experiencing this issue?
8 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
ah, that makes sense. thanks for the reply!
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
what's the edge cases?
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
oh fun
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
i'm guessing guild will always be cached, solely because of d.js's typings, since guild in channel.guild after !channel.isDMBased() can't be null. I could be easily wrong, as i don't know d.js's internals at all
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
also wondering if this convo should've been in #framework-development but it did have potential branches of "use this part of the framework and don't do what horrible thing you're doing"
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
My current guess for the original question is that the null typing is not needed then. Even if channel is a partial, and guild is unavailable, it'd be a DM channel judging by types. Might be worth refactoring later, unless a contributor who actually knows the codebase says otherwise. See https://discord.com/channels/737141877803057244/1150945163473059950/1151019618727645205
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
oh hey yeah, i can guarantee channel being a non-partial also! i think that's the best solution there
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
inCachedGuild() doesn't seem to work due to the Message typing, hmm
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
in that case, how can we be in a guild and have the guild be null?
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
im getting undefined because of messageOrInteraction.guild?, yep
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
oh wait a sec
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
I was about to post this:
in my edit, i spun off permissions into a new variable newPermissions. This is so I could do channel.permissionsFor(messageOrInteraction.applicationId); without the potential null output affecting the type of the function getPermissionsForChannel(), which I understand to be unnecessary. I think getPermissionsForChannel() can just be of type PermissionsBitField and not PermissionsBitField | null. If this was ever turned null by the applicationId fetch, I believe it'd make sure it'd always not be null, due to fetchMe(), presumably because fetchMe() would never be null
...except permissions is still technically nullable, because if fetchMe() for some reason can be undefined. I'm not 100% sure on how that'd be the case, but I presume that makes the | null function typing make sense. Did I get that right? (also, the reason on why it'd be undefined would be great. best guess is that somehow d.js has http bot support or something)
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
My potential code, in which I'm naively unaware if I'm about to make a mistake:
// Also pulled from the same src/preconditions:
const dmChannelPermissions = new PermissionsBitField(
~new PermissionsBitField([
//
PermissionFlagsBits.AddReactions,
PermissionFlagsBits.AttachFiles,
PermissionFlagsBits.EmbedLinks,
PermissionFlagsBits.ReadMessageHistory,
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.UseExternalEmojis,
PermissionFlagsBits.ViewChannel,
]).bitfield & PermissionsBitField.All,
).freeze();

export async function getPermissionsForChannel(
channel: TextBasedChannel,
messageOrInteraction: Message | BaseInteraction,
) {
// Edited to just use the dmChannelPermissions type, which from the types and my own understanding will always be set.
let permissions = dmChannelPermissions;

if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
let newPermissions: PermissionsBitField | null = permissions;
if (!isNullish(messageOrInteraction.applicationId)) {
newPermissions = channel.permissionsFor(
messageOrInteraction.applicationId,
);
}

if (isNullish(newPermissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = newPermissions;
}
}

return permissions;
}
// Also pulled from the same src/preconditions:
const dmChannelPermissions = new PermissionsBitField(
~new PermissionsBitField([
//
PermissionFlagsBits.AddReactions,
PermissionFlagsBits.AttachFiles,
PermissionFlagsBits.EmbedLinks,
PermissionFlagsBits.ReadMessageHistory,
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.UseExternalEmojis,
PermissionFlagsBits.ViewChannel,
]).bitfield & PermissionsBitField.All,
).freeze();

export async function getPermissionsForChannel(
channel: TextBasedChannel,
messageOrInteraction: Message | BaseInteraction,
) {
// Edited to just use the dmChannelPermissions type, which from the types and my own understanding will always be set.
let permissions = dmChannelPermissions;

if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
let newPermissions: PermissionsBitField | null = permissions;
if (!isNullish(messageOrInteraction.applicationId)) {
newPermissions = channel.permissionsFor(
messageOrInteraction.applicationId,
);
}

if (isNullish(newPermissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
} else {
permissions = newPermissions;
}
}

return permissions;
}
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 9/12/2023 in #sapphire-support
Why in line 79 for src/preconditions/ClientPermissions.ts is there `PermissionsBitField | null`?
private async getPermissionsForChannel(channel: TextBasedChannel, messageOrInteraction: Message | BaseInteraction) {
// Wondering about this line
let permissions: PermissionsBitField | null = this.dmChannelPermissions;

if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (!isNullish(messageOrInteraction.applicationId)) {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
}

if (isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
}

return permissions;
}
private async getPermissionsForChannel(channel: TextBasedChannel, messageOrInteraction: Message | BaseInteraction) {
// Wondering about this line
let permissions: PermissionsBitField | null = this.dmChannelPermissions;

if (messageOrInteraction.inGuild() && !channel.isDMBased()) {
if (!isNullish(messageOrInteraction.applicationId)) {
permissions = channel.permissionsFor(messageOrInteraction.applicationId);
}

if (isNullish(permissions)) {
const me = await messageOrInteraction.guild?.members.fetchMe();
if (me) {
permissions = channel.permissionsFor(me);
}
}
}

return permissions;
}
32 replies
SIASapphire - Imagine a framework
Created by some1chan on 8/24/2023 in #sapphire-support
Did the latest @sapphire/[email protected] update break things?
also fyi; i can't seem to mark this as the answer, as the Apps context menu isn't there. is that intended if I don't want to have the posts on answer overflow?
34 replies
SIASapphire - Imagine a framework
Created by some1chan on 8/24/2023 in #sapphire-support
Did the latest @sapphire/[email protected] update break things?
nvm, it did work! probably forgot to rerun with "resolveJsonModule": true i believe
34 replies
SIASapphire - Imagine a framework
Created by some1chan on 8/24/2023 in #sapphire-support
Did the latest @sapphire/[email protected] update break things?
oh wait a sec
34 replies
SIASapphire - Imagine a framework
Created by some1chan on 8/24/2023 in #sapphire-support
Did the latest @sapphire/[email protected] update break things?
seems to not have done anything, which puzzles me. just to double check, this would be correct?
...
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"useDefineForClassFields": true
},
"include": ["src/**/*", "src/**/*.json"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
}
...
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"useDefineForClassFields": true
},
"include": ["src/**/*", "src/**/*.json"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
}
34 replies
SIASapphire - Imagine a framework
Created by some1chan on 8/24/2023 in #sapphire-support
Did the latest @sapphire/[email protected] update break things?
at least for plugin-i18next, this seems to have worked! It also seems to have broken the hack I forgot I used to get typings for SentryOptions in '@kaname-png/plugin-sentry' it looked somewhat like this:
// setup.ts
import type { SentryOptions } from '@kaname-png/plugin-sentry/dist/lib/types';
// ...
declare module '@sapphire/framework' {
interface SapphireClientOptions {
sentry?: { options?: SentryOptions };
}
}
// setup.ts
import type { SentryOptions } from '@kaname-png/plugin-sentry/dist/lib/types';
// ...
declare module '@sapphire/framework' {
interface SapphireClientOptions {
sentry?: { options?: SentryOptions };
}
}
34 replies