export const guildProcedure = protectedProcedure
.input(z.object({ guildId: z.string() }))
.use(async ({ ctx, next, input }) => {
const hasPermissions = await someExpensiveOperationToCheckPermissions(input.guildId)
if(!hasPermissions) {
throw new TRPCError({ code: 'FORBIDDEN', message: 'You do not have permission to access this guild' });
}
return next({
ctx: {
session: { ...ctx.session, user: ctx.session.user },
},
});
});
export const guildProcedure = protectedProcedure
.input(z.object({ guildId: z.string() }))
.use(async ({ ctx, next, input }) => {
const hasPermissions = await someExpensiveOperationToCheckPermissions(input.guildId)
if(!hasPermissions) {
throw new TRPCError({ code: 'FORBIDDEN', message: 'You do not have permission to access this guild' });
}
return next({
ctx: {
session: { ...ctx.session, user: ctx.session.user },
},
});
});