how to upload an html transcript to a website in discord.js

I’m making a ticket bot and when I close the ticket, I generate an .html file and send it to a log channel. This file is the channel’s transcript, which shows all the messages said on the channel.

My plan is not to send the file on this channel anymore, but rather to upload the entire file to a website and access it via the address: https://exemple.com/(ticket number).

How do I make this happen? I don’t know much about programming, so I’m struggling to find some content that helps me with this part.

PDF with no border, no scroll, single page

ive got a problem.

i have a pdf with 144 sites, but with links from adobe indesign. So i want to show the embed pdf on my site with no scrool, no toolbar and you cannot scroll in pdf. if i click a link, i will jump to another page on this pdf, but i can still not scroll up and down.

i was trying to use parameter #toolbar, statusbar, navpanes but in all cases i can still scroll up and down.

overflow hidden aswell.

thanks for helping.

JS or SDKs are welcome,

cheers

pdf embed with iframe and parameter

How to unwrap lines from it’s containers and append to parent element?

I need to somehow unwrap these lines of text and append them as plain text to the p element without all the divs, using js. How can i do that?

The result i am after is to go from this:

    <p>
      <div class="line">
        <div>
          some text
        </div>
      </div>
      <div class="line">
        <div>
          some text
        </div>
      </div>
      <div class="line">
        <div>
          some text
        </div>
      </div>
    </p>

to this:

<p>
  some text some text some text
</p>

Below is what i am trying right now, which is not much at the moment.

const lines = [...document.querySelectorAll('.line')]

lines.forEach((el, index) => {
  
})

Cookies or Google Analytics Tracking Exit Sessions

If an ad-blocker is detected, i am showing a popup asking the user to disable their ad-blocker. Currently close button is in the popup to close the popup. I am planning to force users to disable ad blocker by not showing close button in the popup. My question is – How to know if user who was asked to disable ad-blocker, has he disabled the ad-blocker and reload the page OR he just left the page?

Currently I have event — when ad-blocker is detected.

 gtag('event', 'ad_blocker_detected', {
    event_category: 'user',
    event_label: 'Ad-blocker Detected',
  });

I want to know how to set up event or cookie for tracking when user decides not to disable adblocker and left the page. (Note – no close btn in the popup). I want to answer % of users agrees to disable ad-blocker when they are forced to disable it.

Padding in WGSL memory layout

I’m trying to write a WGSL structs parser (sort of webgpu-utils thing). In order to better understand the memory layout, I’m using wgsl offset computer as a helper.

Having the next struct:

struct A {
  a: array<vec3f, 3>,
  b: f32
};

The layout given by the mentioned tool looks like:
enter image description here

I’m struggling with the difference between the graphical representation and the AInfo object. In the graphics, it is clearly seen that each item in the array<vec3f, 3> has alignment padding of 4 bytes and the offsets for three items are 0, 16 and 32 respectively. On the other hand, in the AInfo object the offset of the array a is zero and the length is 36 bytes, which implies the bytes arrangement in the array is consequent and all the padding is “moved to the end” (thus, the 48 offset for .b). Referencing to the graphics, I would expect the object representation to be sort of:

const AInfo = {
  a: [
    {type: Float32Array, byteOffset: 0, length: 4}, // 16 bytes
    {type: Float32Array, byteOffset: 16, length: 4}, // 16 bytes
    {type: Float32Array, byteOffset: 32, length: 4}, // 16 bytes
  ],
  b: {type: Float32Array, byteOffset: 48, length: 1}
};

What am I missing here?

why does assigned cost increase even if check box uncheck [closed]

When user checked the check box , guide cost adds to overall cost, but sudden after user uncheck the box, even guide cost adds, but it should deduct.

let guide Cost = guide Needed ? (adventure Type. includes('adult') ? 1000 : 500) : 0;

let adventure Type = adventure Type Input. value;

let guide Needed = guide Needed Input. checked;

let adventure Cost = calculate Adventure Cost (adventure Type, guide Needed);

Fetch Data from a Directus API using StaticToken

I’m trying out Directus as a faster way to deliver my API’s. But I’m having trouble to fetch data with a static token authentication.

Below is my client setup:

import { createDirectus, staticToken,rest, withToken} from "@directus/sdk";

const directus = createDirectus(process.env.NEXT_PUBLIC_API_URL as string).with(rest());
const client = directus.with(staticToken(process.env.ADMIN_TOKEN as string))

export default client;

and here is my fetch posts implementation

    const getAllPosts = async () => {
        try {
            const response = await client.request(readItems("posts", { fields: ["id", "title"] }));
            const posts = response || [];
            return posts;
        } catch (error) {
            console.log('error', error);
        }
    };

The response is the following:

response: Response {
    [Symbol(realm)]: null,
    [Symbol(state)]: {
      aborted: false,
      rangeRequested: false,
      timingAllowPassed: true,
      requestIncludesCredentials: true,
      type: 'default',
      status: 401,
      timingInfo: [Object],
      cacheState: '',
      statusText: 'Unauthorized',
      headersList: [HeadersList],
      urlList: [Array],
      body: [Object]
    },
    [Symbol(headers)]: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    }
  }
}
error {
  errors: [ { message: 'Invalid user credentials.', extensions: [Object] } ],
  response: Response {
    [Symbol(realm)]: null,
    [Symbol(state)]: {
      aborted: false,
      rangeRequested: false,
      timingAllowPassed: true,
      requestIncludesCredentials: true,
      type: 'default',
      status: 401,
      timingInfo: [Object],
      cacheState: '',
      statusText: 'Unauthorized',
      headersList: [HeadersList],
      urlList: [Array],
      body: [Object]
    },
    [Symbol(headers)]: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    }
  }
}

in a 2022 directus thread thread the auth process for static tokes looked like this:

const { Directus } = require("@directus/sdk");

(async () => {
    const directus = new Directus("...", { auth: { staticToken: "your_static_token" } } )

    const playlist = await directus.items("playlist").readOne(5)

    console.log(playlist)
})()

Though with the latest SDK its no longer working…

It looks like I am not authorized to access the data even though my secret token (ADMIN_TOKEN) is set to an admin user (which has access to all the tables). In my opinion the documentation deserved improvements because this is not clear at all. Anyone can help me to find out the problem?

403 when fetching user.photoURL from onAuthStateChanged()?

In my server handle hook (SvelteKit) I have:

const sessionCookie = event.cookies.get('__session')
event.locals.decodedIdToken = await adminAuth.verifySessionCookie(sessionCookie!)
event.locals.firebaseCustomToken = await adminAuth.createCustomToken(event.locals.decodedIdToken.uid)

In the front-end in my firebase.ts I have:

export const auth = getAuth()
setPersistence(auth, inMemoryPersistence)

// Custom token auth
export async function signIn(token: string): Promise<UserCredential | null> {
  return await signInWithCustomToken(auth, token)
}

// Irrelevant to this question I think, but here is how I'm getting the user credentials
export function authStore() {
  let unsubscribe: () => void

  if (!auth || !globalThis.window) {
    console.warn('Auth is not initialized or not in browser')
    const { subscribe } = writable(null)
    return { subscribe }
  }

  const { subscribe } = writable(auth?.currentUser ?? null, (set) => {
    unsubscribe = onAuthStateChanged(auth, (user) => {
      set(user)
    })

    return () => unsubscribe()
  })

  return { subscribe }
}

export const userCredentials = authStore()

And in my root layout I call the signIn function:

export let data

onMount(() => {
  if (data.firebaseCustomToken) {
    signIn(data.firebaseCustomToken)
  }
})

And in one of my components when I try to load an image with the user.photoURL src, I’m getting 403 error. I can copy-paste the same URL in a new tab and it loads fine.

The decoded credentials from the server hook return the same URL. The authenticated user is using Google Auth.

What am I doing wrong?

Deployment error on Vercel On Next Js App

ERROR OCCURED WHEN I TRY TO DEPLOY ON VERCEL.
Type error: Type ‘AnimeProp[]’ is not assignable to type ‘ReactNode’.
Type ‘AnimeProp[]’ is not assignable to type ‘Iterable’.
The types returned by ‘Symbol.iterator.next(…)’ are incompatible between these types.
Type ‘IteratorResult<AnimeProp, any>’ is not assignable to type ‘IteratorResult<ReactNode, any>’.
Type ‘IteratorYieldResult’ is not assignable to type ‘IteratorResult<ReactNode, any>’.
Type ‘IteratorYieldResult’ is not assignable to type ‘IteratorYieldResult’.
Type ‘AnimeProp’ is not assignable to type ‘ReactNode’.

MY GITHUB LINK IS GIVEN BELOW
https://github.com/Huzaifa246/NextJS-ServerSide

Javascript: Put a JSON objects infromation to a HTML file

I’m trying to solve this example that we were given.

<ul class="wrapper">
      <li class="form-row">
        <label id="label">ID</label>
        <label id="label">TYPE</label>
        <label id="label">STATUS</label>
        <label id="label">SPEED</label>
      </li>
      <li class="form-row-robot" id="robot1">
        <label for="topic">839</label>
        <label id="type">R-1000</label>
        <label id="status">ON</label>
        <label id="speed">0</label>
      </li>
      <li class="form-row-robot" *id="robot2"*>
        <label for="topic">240</label>
        <label id="type">R-2000</label>
        <label id="status">ON</label>
        <label id="speed">0</label>
      </li>

I have manually put in each ID, TYPE, STATUS and SPEED, in this html file. I have a list of JSON objects with the same information in my JavaScript file. That looks like this

var robot = {
Id : int,
Type : char,
Status : boolean,
Speed : int
}

Is there a easy way to do this? I want to still have the class form-row-robot and id=”robot2″ from the html file but each id will be robot + I. Seems like a long request but everything that can guide me into the right direction will help.

How do I convert a JSON Object into a HTML table? is an good solution to my problem but I have problem to put in the class=”form-row-robot” id=”robot1″?

I’m sorry if anything is blurry, I’m new to JavaScript.

Does stream-chat-react’s MessageSimple Component Indicate Edited Messages?

"stream-chat-react": "^10.8.8"

Description

I am currently using the stream-chat-react library to integrate chat functionalities into my application. My application utilizes the MessageSimple component for displaying messages. I have encountered a specific question regarding the handling of edited messages.

Question

Does the stream-chat-react library, specifically the MessageSimple component, automatically provide an “Edited” label for messages that have been edited after being sent? Currently, MessageSimple renders the message content and the timestamp (e.g., “Today at 6:22 PM”) but does not indicate if a message has been edited.

Context

In my application, it’s important for users to know when a message has been edited after its initial posting. The MessageSimple component handles the rendering of messages, including their timestamps, but it does not seem to display any indication of whether the message has been edited. I noticed that messages have created_at and updated_at timestamps, and I am considering using these to manually implement an “Edited” label. However, before proceeding, I wanted to confirm if such a feature already exists in the stream-chat-react library or if there are recommended practices for this.

Screenshot

enter image description here
Attached is a screenshot for reference, showing how messages are currently displayed using the MessageSimple component. My aim is to add an “Edited” label next to the timestamp when a message has been modified after its initial creation.

I want the Edited Label right after the Timestamp something like this Today at 6:22PM (Edited).

Code Usage

import {
  MessageSimple,
  StreamMessage,
  useChannelStateContext,
  useMessageContext,
} from 'stream-chat-react';

export const IamCustomMessage = (): JSX.Element => {
  const { message } = useMessageContext();

  const isMessageEdited =
    message.created_at !== undefined &&
    message.updated_at !== undefined &&
    new Date(message.updated_at).getTime() >
    new Date(message.created_at).getTime();
      
return (
         <div>
               <MessageSimple />
         </div>
    );
}

Additional Information

I would greatly appreciate any guidance or information regarding this feature. If it’s not currently available, could you please advise on the best approach to implement this functionality manually?

Trouble making a GET request with the requests library in Python

I’m currently working on a Python project where I need to make a GET request to a remote API using the requests library. Here’s the code snippet I’m using:

import requests

url = "https://api.example.com/data"
response = requests.get(url)

print(response.text)

I expected to see the data from the API in the console, but I’m encountering an issue. Instead of the data, I’m getting an error message: [Insert the specific error message here]. I’ve checked the API documentation, and I believe I’m using the requests library correctly.

I’ve also tried a few things, like checking my internet connection, ensuring the API endpoint is correct, and checking for typos in my code, but I’m still stuck. Can someone please help me identify what might be causing this issue and how I can resolve it?

Thank you so much for your assistance!

Use CSS Custom Highlight API for highlight text with very slow paint

Use CSS Custom Highlight API for highlight text with scroll container with very slow operation in the first render and also when we scroll the page which it takes over 4 seconds for painting. Is there any way for me to diagnose further what the root cause is? And also want to know when the elements are in the scroll overflow using CSS Custom Highlight API, why it could cause paint very slow. In the same situation, if I highlight the text via modifying the DOM, which would not cause the page paint very slow. Could someone help me out.

enter image description here

I tried to highlight text by modifying DOM, it would not cause the page paint very slow. I could not figure out what’s different between use CSS Custom Highlight API and modifying DOM to highlight when the elements are in the scroll overflow.

SwiperJS : slide order and slide per column does not work properly in grid

sandbox: demo

Swiper version: ^11.0.5

The order of the slide displayed and the rows per column is not as expected. I am working on Vue using the swiper element but the same problem is shown in the simple html demo. In order to get 3 rows per column in 1 view, I have set

  1. slidesPerView: 1
  2. grid: {
    rows: 3,
    fill: “row”
    }

However, only 2 rows are shown in the 1st page and the order is not in ascending order.

I am looping through the slides so it is not possible to put 3 elements in 1 slide.

I have tried to remove property fill but then all slides are shown in the 1st page. Editing CSS of .swiper-wrapper to display:grid; grid-template-rows: repeat(3, 1fr); also does not work. It causes the same result. SlidesPerColumn does not work in this swiper version.

Is there any solution on this issue?

Expected behavior

for 1st page

1

2

3

for 2nd page

4

Actual behavior

for 1st page

1

3

for 2nd page

2

4

i have compilation error in connecting with firebase

Compiled with problems:
×
ERROR in ./src/App.js 6:0-39
Module not found: Error: Can’t resolve ‘./Components/Login’ in ‘C:UsersUSERDesktopReact_Projectcontact-managersrc’
ERROR in ./src/App.js 7:0-41
Module not found: Error: Can’t resolve ‘./Components/Signup’ in ‘C:UsersUSERDesktopReact_Projectcontact-managersrc’
ERROR in ./src/App.js 8:0-37
Module not found: Error: Can’t resolve ‘./Components/Home’ in ‘C:UsersUSERDesktopReact_Projectcontact-managersrc’

i need to remove this error and have a connection with firebase
these code are saved in a App.js file using vscode
i can’t understand what is the problem