ZachHandley
ZachHandley
Explore posts from servers
SIASapphire - Imagine a framework
Created by ZachHandley on 3/19/2024 in #sapphire-support
Just curious, can I declare a map of string to Class on container as a type?
yeah I figured if I used the container.configHandlers.get and it's undefined then I create & set it
6 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
I'll run tests and pull
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
that's the format
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
not gonna use that check lol, but
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
fixed
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
okaydokey
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
that's just client perms just as an example of what i had in mind
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
yeh
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
just swapped the message for context and checked the class instnace
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
this look good?
export const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {
const resolved = new PermissionsBitField(permissionsResolvable);
const resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);

return createFunctionPrecondition((context: Message | BaseInteraction) => {
if (context instanceof Message) {
if (resolvedIncludesServerPermissions && isDMChannel(context.channel)) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,
message: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'
});
}

if (isGuildBasedChannel(context.channel)) {
const missingPermissions = context.channel.permissionsFor(context.guild!.members.me!).missing(resolved);

if (missingPermissions.length) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,
message: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,
context: {
missing: missingPermissions
}
});
}
}
} else {
if (resolvedIncludesServerPermissions && isDMChannel(context.channel)) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,
message: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'
});
}

if (context.channel && isGuildBasedChannel(context.channel)) {
const missingPermissions = context.channel.permissionsFor(context.guild!.members.me!).missing(resolved);

if (missingPermissions.length) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,
message: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,
context: {
missing: missingPermissions
}
});
}
}
}

return true;
});
};
export const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {
const resolved = new PermissionsBitField(permissionsResolvable);
const resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);

return createFunctionPrecondition((context: Message | BaseInteraction) => {
if (context instanceof Message) {
if (resolvedIncludesServerPermissions && isDMChannel(context.channel)) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,
message: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'
});
}

if (isGuildBasedChannel(context.channel)) {
const missingPermissions = context.channel.permissionsFor(context.guild!.members.me!).missing(resolved);

if (missingPermissions.length) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,
message: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,
context: {
missing: missingPermissions
}
});
}
}
} else {
if (resolvedIncludesServerPermissions && isDMChannel(context.channel)) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,
message: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'
});
}

if (context.channel && isGuildBasedChannel(context.channel)) {
const missingPermissions = context.channel.permissionsFor(context.guild!.members.me!).missing(resolved);

if (missingPermissions.length) {
throw new UserError({
identifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,
message: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,
context: {
missing: missingPermissions
}
});
}
}
}

return true;
});
};
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
I just use a Playwright browser
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
Lol they just released Pingora, their rust based API framework, maybe with that knowledge you can make it even better
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
hehehe I have a Browserless up that gets past all of that
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
is there some error throwing? It looks like it's just skipping
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
it looks like your script is stopping for some reason on Generate JavaScript Companion library
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
all good man the amount of times my bugs are the dumbest thing
89 replies