Kay
Kay
Explore posts from servers
DDeno
Created by Kay on 6/13/2024 in #help
Check if class instance is instance of provided type
I have a function that dynamically loads a folder with ts files, initiates the classes in them and saves them. The function takes in a type for its return type like this load<T extends BaseInteraction>. But when i use DynamicClass instanceof T it says 'T' only refers to a type, but is being used as a value here.. is there a way to compare the class to the provided class?
3 replies
DDeno
Created by Kay on 6/3/2024 in #help
Emit with dynamic imports?
Does deno emit work with dynamic imports?
4 replies
DDeno
Created by Kay on 5/23/2024 in #help
Invalid protocol value while using websockets
When using discord.js with deno and i try logging my bot in it returns error: Uncaught (in promise) SyntaxError: Invalid protocol value. When trying to login using node it works fine my full logs:
[INFO] 2024-05-23T04:42:00.418Z Registring events.
[DEBUG] 2024-05-23T04:42:00.458Z Registered interactionCreate
[DEBUG] 2024-05-23T04:42:00.478Z Registered ready
[INFO] 2024-05-23T04:42:00.481Z Registered events.
[DISCORD] [DEBUG] 2024-05-23T04:42:00.744Z Provided token: MTIwNDE1NDY5OTQzMjA3MTIyOQ.GLE-6a.**************************************
[DISCORD] [DEBUG] 2024-05-23T04:42:00.747Z Preparing to connect to the gateway...
[DISCORD] [DEBUG] 2024-05-23T04:42:00.924Z [WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[DISCORD] [DEBUG] 2024-05-23T04:42:00.926Z [WS => Manager] Session Limit Information
Total: 1000
Remaining: 999
[DISCORD] [DEBUG] 2024-05-23T04:42:00.934Z [WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
error: Uncaught (in promise) SyntaxError: Invalid protocol value.
at new WebSocket (ext:deno_websocket/01_websocket.js:203:13)
at WebSocketShard.internalConnect (file:///C:/Users/titul/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/ws/1.1.0/dist/index.js:675:24)
at eventLoopTick (ext:core/01_core.js:168:7)
[INFO] 2024-05-23T04:42:00.418Z Registring events.
[DEBUG] 2024-05-23T04:42:00.458Z Registered interactionCreate
[DEBUG] 2024-05-23T04:42:00.478Z Registered ready
[INFO] 2024-05-23T04:42:00.481Z Registered events.
[DISCORD] [DEBUG] 2024-05-23T04:42:00.744Z Provided token: MTIwNDE1NDY5OTQzMjA3MTIyOQ.GLE-6a.**************************************
[DISCORD] [DEBUG] 2024-05-23T04:42:00.747Z Preparing to connect to the gateway...
[DISCORD] [DEBUG] 2024-05-23T04:42:00.924Z [WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[DISCORD] [DEBUG] 2024-05-23T04:42:00.926Z [WS => Manager] Session Limit Information
Total: 1000
Remaining: 999
[DISCORD] [DEBUG] 2024-05-23T04:42:00.934Z [WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
error: Uncaught (in promise) SyntaxError: Invalid protocol value.
at new WebSocket (ext:deno_websocket/01_websocket.js:203:13)
at WebSocketShard.internalConnect (file:///C:/Users/titul/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/ws/1.1.0/dist/index.js:675:24)
at eventLoopTick (ext:core/01_core.js:168:7)
2 replies
DDeno
Created by Kay on 4/4/2024 in #help
deny path of website instead of whole website
Is it possible to for example deny only a path of a website instead of the whole website?
2 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
I want to log all output immediately when its logged in the child process. how would i do that?
27 replies
DDeno
Created by Kay on 4/1/2024 in #help
Interface with unknown amount of keys but all the same type
How do i create an interface/type that can have unlimited keys but the values are all the same type?
3 replies
DDeno
Created by Kay on 3/31/2024 in #help
Deno deploy running my code multiple times
Im hosting a small discord bot on deno deploy but for some reason its firing the events multiple times and everytime i save the project to shut it down and start it again it doubles. so in this case when i delete a message it first send one message telling me its deleted. then when i patched a bug it became 2 messages and now its 4. is there a way to fix this?
4 replies
DDeno
Created by Kay on 3/23/2024 in #help
Bundle ts code to ts using deno emit
When bundling code using https://deno.land/x/[email protected] it bundles into javascript but i want it to be typescript. is it possible to do this?
2 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
I have this page which displays a render using threejs and renders it into a png and downloads it. i need that image to use it in a canvas from deno-canvas but when i download it using this package it returns this:
error: Uncaught (in promise) Error: The filename, directory name, or volume label syntax is incorrect. (os error 123): writefile 'C:\Users\titul\AppData\Local\Temp\deno_dwld2b5d29e3bc7dd136/E:\Arcunis\recipeImageMaker\stone.png'
error: Uncaught (in promise) Error: The filename, directory name, or volume label syntax is incorrect. (os error 123): writefile 'C:\Users\titul\AppData\Local\Temp\deno_dwld2b5d29e3bc7dd136/E:\Arcunis\recipeImageMaker\stone.png'
code where i download it:|
import { download } from "https://deno.land/x/[email protected]/mod.ts";
import { join } from "https://deno.land/std/path/mod.ts";
export default async function generateBlock(block: String) {
await download("http://localhost:8000/renderer/index.html?material=" + block, {file: join(Deno.cwd(), block + ".png")});
}
import { download } from "https://deno.land/x/[email protected]/mod.ts";
import { join } from "https://deno.land/std/path/mod.ts";
export default async function generateBlock(block: String) {
await download("http://localhost:8000/renderer/index.html?material=" + block, {file: join(Deno.cwd(), block + ".png")});
}
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image data from automated download
I have this page which displays a render using threejs and renders it into a png and downloads it. i need that image to use it in a canvas from deno-canvas but when i download it using this package it returns this 'C:\Users\titul\AppData\Local\Temp\deno_dwldf3d5cf300f407d23/E:\Arcunis\recipeImageMaker\stone.png' code where i download it:|
import { download } from "https://deno.land/x/[email protected]/mod.ts";
export default async function generateBlock(block: String) {
await download("http://localhost:8000/renderer/index.html?material=" + block, {file: Deno.cwd() + "\\stone.png"});
}
import { download } from "https://deno.land/x/[email protected]/mod.ts";
export default async function generateBlock(block: String) {
await download("http://localhost:8000/renderer/index.html?material=" + block, {file: Deno.cwd() + "\\stone.png"});
}
2 replies
DDeno
Created by Kay on 3/1/2024 in #help
Wait until Deno.Command process has exited
How would i stop code execution until the process has exited? since its not a promise i cant just do await. is there a way and how?
4 replies
DDeno
Created by Kay on 1/13/2024 in #help
how to compress string into string
How would i go about compressing a string? i need to compress a string but i need the compressed value to also be a string or be able to be turned into a string
6 replies
DDeno
Created by Kay on 12/22/2023 in #help
Make deno.serve handler asynchronous
How can i make the Deno.serve handler asynchronous? or like make it so that it can execute asynchronous functions
2 replies
DDeno
Created by Kay on 12/21/2023 in #help
Deno.serve get full path instead of only params and url
I need to get params from an url like this http://localhost:8000/auth#token_type=Bearer&access_token=CENCORED&expires_in=604800&scope=identify but the params arnt after a ? but after a # so how do i get that using deno.serve?
5 replies
DDeno
Created by Kay on 12/12/2023 in #help
Better way of finding element from map
Im making an api and all routes are stored in a map. is there a better and more optimised way to look if the route exists and to get it?
handleRequest(req: Request, info: Deno.ServeHandlerInfo): Response {
const path = new URL(req.url).pathname;
const route = this.getRoute(path);
if (!route) return new Response("not found", {status: 404});
console.log(route);

return new Response("Hello World!");
}

getRoute(pathname: string): Route | undefined {
const paths = pathname.split("/").filter(val => val.length > 0);
const path = paths.join("/");
let routes = Array.from(this.routes.keys());
for (const route of routes) {
const regex = new RegExp(`^(${route.replaceAll(/\[.*\]/g, "(.*)")})$`)
if (!regex.test(path)) continue;
return this.routes.get(route);
}

}
handleRequest(req: Request, info: Deno.ServeHandlerInfo): Response {
const path = new URL(req.url).pathname;
const route = this.getRoute(path);
if (!route) return new Response("not found", {status: 404});
console.log(route);

return new Response("Hello World!");
}

getRoute(pathname: string): Route | undefined {
const paths = pathname.split("/").filter(val => val.length > 0);
const path = paths.join("/");
let routes = Array.from(this.routes.keys());
for (const route of routes) {
const regex = new RegExp(`^(${route.replaceAll(/\[.*\]/g, "(.*)")})$`)
if (!regex.test(path)) continue;
return this.routes.get(route);
}

}
3 replies
DDeno
Created by Kay on 11/30/2023 in #help
Compiled program cannot write to file
I made a program that can download the latest version of papermc or velocity. and it does download it but it also should update the config file to set the latest build value to the build number of the downloaded jar. and just by running deno run -A ./Main.ts that does work but after compiling it it doesn't. it still downloads the jar
3 replies
DDeno
Created by Kay on 9/14/2023 in #help
WalkSync dosnt get files
No description
3 replies
DDeno
Created by Kay on 7/28/2023 in #help
Dynamic interfaces
Is it possible to have like an interface that has a type entry and when it is a string for example the interface has a maxlength and minlength or when its a number it has a max and min?
6 replies
DDeno
Created by Kay on 7/20/2023 in #help
Log Deno.command process output
i need to execute a command wich will keep running until stopped and log the output. i found this but it dosnt work
const command = new Deno.Command(
"java",
{
args: [
"-Xms512M",
"-Xmx512M",
"-XX:+UseG1GC",
"-XX:G1HeapRegionSize=4M",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+ParallelRefProcEnabled",
"-XX:+AlwaysPreTouch",
"-jar",
"proxy.jar"
],
stdout: "piped",
stdin: "piped",
stderr: "piped",
},
);
const process = command.spawn();
for await (const line of readLines(process.stdout)) {
emit_console_out(line);
}
const command = new Deno.Command(
"java",
{
args: [
"-Xms512M",
"-Xmx512M",
"-XX:+UseG1GC",
"-XX:G1HeapRegionSize=4M",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+ParallelRefProcEnabled",
"-XX:+AlwaysPreTouch",
"-jar",
"proxy.jar"
],
stdout: "piped",
stdin: "piped",
stderr: "piped",
},
);
const process = command.spawn();
for await (const line of readLines(process.stdout)) {
emit_console_out(line);
}
this says: Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of type 'Reader'. Property 'read' is missing in type 'ReadableStream<Uint8Array>' but required in type 'Reader' and i know that process.stdout has a getReader but that dosnt seem to work either
5 replies