Kay
Kay
Explore posts from servers
DIAdiscord.js - Imagine a bot
Created by Kay on 6/29/2024 in #djs-questions
Cannot use 'in' operator to search for 'code' in undefined
When running my bot it sometimes returns this error and exists
error: Uncaught TypeError: Cannot use 'in' operator to search for 'code' in undefined
at WebSocketShard.onError (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:1065:16)
at WebSocket.connection.onerror (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:683:12)
at WebSocket.wrappedHandler (ext:deno_web/02_event.js:1401:12)
at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
at invokeEventListeners (ext:deno_web/02_event.js:801:5)
at dispatch (ext:deno_web/02_event.js:658:9)
at WebSocket.dispatchEvent (ext:deno_web/02_event.js:1043:12)
at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:481:16)
at eventLoopTick (ext:core/01_core.js:168:7)
error: Uncaught TypeError: Cannot use 'in' operator to search for 'code' in undefined
at WebSocketShard.onError (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:1065:16)
at WebSocket.connection.onerror (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:683:12)
at WebSocket.wrappedHandler (ext:deno_web/02_event.js:1401:12)
at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
at invokeEventListeners (ext:deno_web/02_event.js:801:5)
at dispatch (ext:deno_web/02_event.js:658:9)
at WebSocket.dispatchEvent (ext:deno_web/02_event.js:1043:12)
at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:481:16)
at eventLoopTick (ext:core/01_core.js:168:7)
I am running the bot in a deno docker container. Bot code:
import { Client, Events, GuildMember } from "discord";

const client = new Client({
// Numbers since the GatewayIntentBits import does not work in deno for some reason
intents: [
1,
2,
4,
512,
1024,
4096,
32768,
16777216,
33554432
]
});

client.on(Events.GuildMemberAdd, (member: GuildMember) => {
member.roles.add("1205218206155935754", "Join role");
});

client.login(Deno.env.get("TOKEN"));
import { Client, Events, GuildMember } from "discord";

const client = new Client({
// Numbers since the GatewayIntentBits import does not work in deno for some reason
intents: [
1,
2,
4,
512,
1024,
4096,
32768,
16777216,
33554432
]
});

client.on(Events.GuildMemberAdd, (member: GuildMember) => {
member.roles.add("1205218206155935754", "Join role");
});

client.login(Deno.env.get("TOKEN"));
4 replies
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
DIAdiscord.js - Imagine a bot
Created by Kay on 5/22/2024 in #djs-questions
Invalid protocol value
getting this error
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/user/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)
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/user/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)
i tried resetting my token and removing the intents and that didnt fix it
2 replies
CDCloudflare Developers
Created by Kay on 5/12/2024 in #general-help
Redirect with path
How would i create a redirect url that woudl for example redirect example.domain.com to example.com but includes the path so if its example.domain.com/path-thingy it would redirect to example.com/path-thingy
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
CDCloudflare Developers
Created by Kay on 2/28/2024 in #general-help
Redirect to ip
i need a subdomain to redirect to an ip. is this possible and how?
15 replies
CDCloudflare Developers
Created by Kay on 2/9/2024 in #general-help
Responding to emails in gmail using my email from cloudflare
i made a support email using my cloudflare domain and i managed to be able to recieve and send emails using that email adress from gmail but i dont seem to be able to respond to emails with that email. is there a way and if so how?
13 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
DIAdiscord.js - Imagine a bot
Created by Kay on 12/21/2023 in #djs-questions
Cannot get params from url
@space ❄ (tagging u cous this is followup of my previous question which i closed and cant open anymore) so this is my code:
const params = new URL(req.url).searchParams
const [accessToken, tokenType] = [params.get('access_token'), params.get('token_type')];
console.log(accessToken, tokenType)
const params = new URL(req.url).searchParams
const [accessToken, tokenType] = [params.get('access_token'), params.get('token_type')];
console.log(accessToken, tokenType)
but this just logs null null this is the oauth2 url from discord https://discord.com/oauth2/authorize?client_id=1116352238667960392&response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fauth&scope=identify
7 replies