#development
1 messages · Page 167 of 1
ohh okay
Adding slashcommand support to all of my current commands

( knowing that I used msg.channel.send for all of them, and slashcommands wants a response )
( and I still want my "old" commands to msg.channel.send )
interaction.reply
so
i have both
i got 2 folders for slashcommands and commands
i didn't wanted that
Hm?
I didn't wanted to have 2 folders
const { Message, ChatInputCommandInteraction } = require("discord.js");
async function send(context, content){
if(context.constructor.name === Message.name)
return context.channel.send(content);
else if(context.constructor.name === ChatInputCommandInteraction.name)
return context.reply(content);
else
throw new Error("context is not a message or command interaction");
}
I just went for a, what I call, "repliesHandler"
Ah.
I'd recommend checking if context is an instance of the Message and ChatInputCommandInteraction classes using the instanceof keyword (technically an operator), because many other classes may have the same name
You're welcome
new annoying task unlocked : handle arguments in "sub commands"
pov you're too lazy but that makes you a good dev
// function to convert commands to slash commands, skip if already slash commands
function convertToSlashCommands(arr) {
let newArr = [];
for (const entry of arr) {
let data;
if (!entry.data)
data = {
name: entry.name,
description: entry.description.en,
};
else data = entry.data.toJSON();
newArr.push(data);
}
return newArr;
}
That… doesn’t make any sense
ignore that my brain is sleep deprived
Inner of that loop could be replaced with a one liner tho
hell no, i test locally, if it works i push to main/master
can somone send help https://wakatime.com/@0x7d8
I spent around 16.2% time of the year coding
nice
there is some, but they are mostly different things
arraybuffer = raw data, no methods to read/write
typedarrays = read/write byte data to/from an arraybuffer
dataview = read/write numerical data to/from an arraybuffer
textencoder/textdecoder = read/write string data to/from an arraybuffer
nodejs buffer = basically typedarray+dataview+textencoder+textdecoder
typedarrays and dataview is usually faster than buffer, but for strings, buffer is usually faster than textencoder/textdecoder
mhm okay
what do you think about how im redesigning my lib?
import { Cookie, Server, Channel } from "rjweb-server"
import { Runtime } from "@rjweb/runtime-bun"
const server = new Server(Runtime, {
port: 8000,
version: true
})
const chatChannel = new Channel<string>(),
history: string[] = []
chatChannel.listen((message) => {
history.push(message)
})
server.path('/', (path) => path
.static('./public', {
rewriteHtml: true
})
.path('api', (path) => path
.path('messages', (path) => path
.http('GET', '/last', (http) => http
.onRequest((ctr) => {
ctr.print({ success: true, message: chatChannel.last() })
})
)
.http('GET', '/history', (http) => http
.onRequest((ctr) => {
ctr.print({
success: true,
history
})
})
)
)
.ws<{ username: string }>('/', (ws) => ws
.onConnect((ctr) => {
ctr["@"].username = ctr.queries.get('username', 'Anonymous')
ctr.subscribe(chatChannel)
})
.onMessage((ctr) => {
chatChannel.send(`${ctr["@"].username}: ${ctr.rawMessage()}`)
})
)
)
)```
this is how I want it to look (and am about 40% done), should I keep it like this? (just a code example)
reading this gave me a headache
what is your lib about
webserver
ooo damn pog
very impressive
damn those commit messages https://github.com/0x7d8/NPM_WEB-SERVER/commits/main
I had that style for minecraft plugin development and just continued it
I dont like it anymore
i thought it was automated at first
looks good but it can easily get messy imo
I mean the other way of defining route is through file based routing, so you have a file for a route / multiple routes and the path gets inferred from the file location
i hate it how you have to .http(..., ..., cb => cb.onRequest(x => ...))
like why not just .http(..., ..., x => ...)
what is context for
this but inferred with initial values, I dont know if Ill keep that https://fs.rjns.de/v/qeHstGdssGFMyOjrOz
but yeah I could add a shortcut too for this
looks overly complicated
imo
I use it for authentication, because theres a special method on a path that lets you validate the request before continuing to the handlers, I just set stuff like ctr["@"].user to user infos so I know the authenticated user easily in every handler
is this @ a special key assigned by the lib
looks weird
eh I wanted something short
yeah but you dont have to make things short for your lib users
im sure they are fine with typing seven characters
this is how an old route file looked https://fs.rjns.de/v/BgfllKKXiKWxtSdViD
a bit unintuitive to make your users use ["@"] all the time, no?
is it?
yes
I mean you could just import your stuff too
just doing ctr.whatever = 1234 should work too, just isnt automatically typed
oh alright
but a bit weird to use it as an example in your docs
would you be happy with this
nah
nah, this lib is made for customization
but not to the point of object attribute names
I mean you can already do that with middlewares anyway
my point is you should prioritize simplicity over complexity
if you want simplicity use express 🤷🏾♂️
fairs
I mean I originally made the lib to be a backend for my apis
which always end up complex
so I added a ton of stuff to help with that
oh btw, what is the Runtime for?
its so the server can run on bun, node (with uws or http) and deno
theres no way I can do that in the same package without injections
I mean sure
technically all support the http lib
but its shit
on bun I use Bun.serve
on node I use custom uWebsockets.js
on deno I use Deno.serve
why not just use node's APIs since i'm sure bun and deno support them to an extent
alright
i used to make my library portable to deno and bun too but as the hype died down i was like fuck it 
main reason is so that people can (if they want) have a completely custom low-level http server and still same features / apis
at this point just go libless if you want low-level 
this is how the runtime that was imported looks
import { version as packageVersion } from "package.json"
export const version: string = packageVersion
import { Implementation, ImplementationHandleRecord } from "rjweb-server"
import { HttpContext } from "@/contexts/http"
import { Server } from "bun"
export class Runtime extends Implementation {
private server: Server | null = null
public port(): number {
return this.server?.port ?? 0
}
public start(): Promise<void> {
return new Promise((resolve) => {
this.server = Bun.serve({
port: this.options.port,
fetch: () => undefined,
websocket: {
message: () => undefined
}
})
resolve()
})
}
public stop(): void {
this.server!.stop(true)
this.server = null
}
public handle<Type extends keyof ImplementationHandleRecord>(type: Type, fn: (context: ImplementationHandleRecord[Type]) => any): void {
if (!this.server) return
switch (type) {
case "http": {
this.server.reload({
async fetch(request) {
const context = new HttpContext(request, this)
await Promise.resolve(fn(context))
return new Response(context.responseContent, context.responseInit)
}
})
}
}
}
public wsPublish(id: number, data: ArrayBuffer): void {
this.server!.publish(id.toString(), data)
}
}```
nah
using separate webservers for deno and bun is very smart
but you could add some autodetection
so the user doesnt need to specify the runtime
const platform = typeof Bun === 'undefined' ? typeof Deno === 'undefined' ? 'node' : 'deno' : 'bun' 🧌
reason I dont do this is (1) to just allow users to use their own runtimes
(2) because stuff like the nodejs uws runtime is 100mb
wdym by that
why would you create your own runtime
what about it
idk if someone wants to make one that works on the edge
or that uses the nginx api
yeah, use that by default and give the user an option to override it
its good to have customizability, but its also good to have smart defaults in place that makes the initial setup easier for the user
also why is uws 100mb wtf
I include the binaries because building them in a build script never works as intended
making html emails is fun ngl
thicc
thats a lot of js
what does it depend on
yeah but how can it be so big
binaries for each platform and 3 node versions
c++ moment
Why are you using uWebsockets anyway?
frfr
ws > *
I like the api alot more (and the fact that its faster)
why care about size when its blazingly fast
Technically it's not really faster, I'm not sure how it differs in terms of API, what does it provide that ws doesn't?
its written in c++
💯
so idk native speed or something
What does that have to do with C++?
it can be a problem when you use node-gyp
Rust produces binaries much larger than C++, if that was your initial argument
pub/sub and manual backpressure handling is what I can tell from the surface, havent ever looked at the ws api in detail
Pre-built binaries exist, plus pretty much everyone has one installed anyways, Clang, GCC, ICC, DPC++, MSVC/CL, etc etc
It's also very easy to install as well
imo i like napi-rs' approach to installing better
not everyone does, especially considering a lot of people use windows
Just because it is written in C++ does not necessarily mean it's faster
It all depends on the implementation
pretty much, even if they don't, they can very easily install one
Or simply make pre-built binaries, nothing hard/complex
making pre-built binaries for lots of OSes and architectures ain't easy
i just like that napi-rs does all of this for you
CI/CD is a thing, and whatever you're doing, the packager manager will first attempt to look for pre-built binaries and download them, if not, build from source
You can also easily do that with node-gyp
how
Cross-compilation is a thing, all you do is to define the target OS and architecture
Through environment variables, or use node-pre-gyp
Most people don't use pub/sub when using websockets (there is pubsub-ws for that), for manual backpressure, I'm pretty sure you can do it in ws but not entirely sure, I don't think you need it in particular
just convert my old commands into slash if there is no data property already set
description have multiple language support
you could just download the correct binary when needed, no need to bundle them all in your package
yeah like
a lot of people do worry about package size on npm
they may not want to download a package that big
why dont you just make uws an optional dependency?
isnt it anyway the way im doing it sir
for the user to turn it on, they need to install it themselves
Is there a way to have to choose between these two options ? and not have them both
on the slashcommandbuilder
the only way is using subcommands
which shows up as if it were two separate commands
/help category
/help command
so i just push 2 seperated slashcommandbuilder into my app ?
no, because they're under the same one command
a subcommand is counted as command option
isn't there a function to add a subcommand for the builder?
or something like that
yup, found it, thanks !
there is no doc for SlashCommandBuilder tho https://old.discordjs.dev/#/docs/discord.js/main/search?query=SlashCommandBuilder
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
it's in the builders package, you were looking at the main package
Trying to dynamically map choices to stringoption (from slashcommandbuilder)
Tells me that they don't want an array
Am I missing missing somethin ?
const categories = [
"chatbot",
"all",
"fun",
"interactions",
"configurations",
"mic",
]
...
// slash command builder...
option
.setName("category")
.setDescription("Category to get help from")
.addChoices(categories.map((category) => ({name:category, value:category})))
.setRequired(false),
0,
ValidationError: Expected the value to not be an array
... {
validator: 's.object(T)',
given: [
{ name: 'chatbot', value: 'chatbot' },
{ name: 'all', value: 'all' },
{ name: 'fun', value: 'fun' },
{ name: 'interactions', value: 'interactions' },
{ name: 'configurations', value: 'configurations' },
{ name: 'mic', value: 'mic' }
]
you need to spread your array
.addChoices(...categories.map((category) => ({name:category, value:category})))
oow... thanks 
@quartz kindle lets say I want to replace all e, a, o and x in a string. would for .. of each char be faster than String.prototype.replace with a regex like /e|a|o|x/g
Even if it was wouldn’t this be an optimization of like .00001 ms
Also iirc string.replace is linear time
So O(n) which is the same as looping over each char
you're not factoring in regex compile times and such, it's probably pretty optimized anyways but a traditional loop is almost always faster than a regex for anything
it's probably a tiny difference though so it likely doesn't matter
my bot knows I'm breaking every part of him, calling for help
(resolved btw)

it would for very small strings possibly, but for larger strings no
iterating char by char is very slow once you go past 15-20 iterations
also one replace with regex should be faster than multiple replaces with one letter each
hey anyone know how to draw gifs on node canvas?
you need a gif encoder/decoder
and then use discord attachment to send it? i noticed webp works but its not showing on the embed
so like the goal is to draw it on top of another image
a gif is basically multiple images in one file
so you need to decode it and get all the frames
then pick one frame to draw on canvas
worth to note, there's an extra step that's normalizing the frames and (possibly) unoptimizing them
more like i want to add the gif on top of an image so like it sits in the bg and gif on top, im looking into some encoders 
cuz the frames aren't guaranteed to be the same dimension as the gif
yeah thats why a decoder is needed, the gif format is not as straight forward
the decoder should take care of that
do you want the final result to be an image, or a gif?
a gif, but i learnt webp can also load animations, so like at the end i have something like canvas.createjpegstream() or png stream ig?
if you want the final result to be animated, then you need to encode it back into a gif
webp can be animated yeah, but discord doesn't support it
so you have to decode the animation and get frames, for each frame you draw the bg + frame on canvas then save the canvas as the new frame
once done use the encoder to put all the new frames togther again into a new gif file
damn i have to draw the bg on each frame? isnt there an easier way like, if you use canvas context draw image multiple times it keeps adding layers, so i thought maybe i'll add animation on top of those?
i have a transparent bg gif,
png can also be animated right
that's the only way
yes, but not for discord
also a little thing to note, remember ur limited to 254+1 colors for gif
the +1 being color 0, which is transparent
the more detailed an element is, the less colors u get to use on the final image
this is even worse if you have semi-transparent elements
ic
canvas cannot "undraw" something
what you can do tho is having two canvases
one will have the bg drawn
then for each frame you create another canvas, and copy the bg from the bg canvas
copying from canvas to canvas is much faster than drawing from image to canvas
i assume the gif encoder will take care of the copying
you can also test what is faster, to create a new canvas or to erase it by drawing a rectangle
so two canvases, one with the bg, another for the frame, then erase frame, copy bg, draw new frame, erase frame, copy bg, draw new frame, etc..
Hi
hi just a nice developing related question
how would you fork a package, modify it, and then test it in another project or sorts
publish it to e.g your own npm org?
what do people do
npm link
i'd just install it directly from github
no need to publish anywhere
npm i githubusername/packagename
oo
i didnt know you could do this when i was starting out so i published all my things to npm 💀
is that why npm is full of shit libs?
singlehandedly ruined the ecosystem
smh
inb4 npm package names start being bought and sold like domain names
with people hoarding all 2-3 letter names for money
hopefully not 💀
though i would imagine it would be similar to githubs username system
if an accounts inactive for a while you can request to claim the username
or if theres a good reason to have a package name and its not being occupied by anything useful

What's a feature in bot? Like that differs from commands
@upbeat forge please dont ghost ping
sry for that kindly check dm
will check in a bit
I finally fixed my bad compression https://fs.rjns.de/v/TDyJZsOnZMLqLyYhzc
now I just need to finish decompress for binary
no
cool stuff
using RLE and lookup tables?
im just doing something that I think works
hold on Ill send it when I fix my bad decompression
xD
a feature can either be a significant command that is itself considered a feature
or a set of commands associated to one feature
Would tickets be considered a feature?
if you're referring to tickets to something like creating a way to setup a ticket channel, have a command or a button to create a ticket
then yes something like that is considered a feature
Oh ok, ty!
ok nvm my compressor is broken
ok its layer 8 issue
works with split = 4 fine
const startByteSplit = Buffer.from([ 0x69, 0x68, 0x67, 0x69 ]),
endByteSplit = Buffer.from([ 0x69, 0x69, 0x67, 0x68, 0x69 ])
export async function compressFileBin(content: Buffer, splits: number, callback?: (progress: Progress) => any) {
const outStart: Buffer[] = [], outEnd: Buffer[] = []
const total = Math.ceil(content.byteLength / splits)
const mapping = new Map<string, Buffer>()
for (let i = 0; i < content.byteLength; i += splits) {
const bytes = content.subarray(i, i + splits)
mapping.set(bytes.toString('hex'), bytes)
outStart.push(Buffer.from([ mapping.size - 1 ]))
callback({
text: `Processing Bytes ${i}-${i + splits}`,
current: Math.floor(i / splits),
from: total
})
}
let i = 0
for (const [ _, value ] of mapping) {
outEnd.push(Buffer.from([ i, ...value.values() ]))
i++
}
return Buffer.concat([ Buffer.from([ splits ]), startByteSplit, ...outStart, endByteSplit, ...outEnd ])
}
export async function decompressFileBin(content: Buffer, callback?: (progress: Progress) => any) {
const splits = content[0], tempBytes: number[] = [], mapping = new Map<number, Buffer>()
let rawContent: Buffer
for (let i = 1 + startByteSplit.byteLength; i < content.byteLength; i++) {
if (endByteSplit.every((value, index) => content[i + index] === value)) {
rawContent = Buffer.from(tempBytes)
tempBytes.length = 0
break
}
tempBytes.push(content[i])
}
for (let i = 1 + startByteSplit.byteLength + rawContent.byteLength + endByteSplit.byteLength; i < content.byteLength; i += 1 + splits) {
const bytes = content.subarray(i + 1, i + 1 + splits)
mapping.set(content[i], bytes)
}
for (const byte of rawContent) {
tempBytes.push(...mapping.get(byte).values())
}
return Buffer.from(tempBytes)
}```
ok it still breaks on images
m
how does the compression process work
the code is in front of you sir
it just looks at each {splits} bytes, adds their hex value to a map as key and their values as value, decompress just reverses that
ye
^.
it breaks alot though
if ur using the hash as a key it'll ofc break as identical segments will overwrite eachother
but then how'd you uncompress it?
as ur not storing the repeat count nor positions
I am
where
?
that's not what I meant, besides I dont know what to look at in that image
from what i understand, that will only work while you have less than 256 keys
consider lol abc lol
ye
how would you uncompress it to that instead of lol lol abc
so the compression efficiency relies entirely with how compatible the split size is with the size of repeating data in the file
basically
i mean, its a good attempt, but its not very good for general purpose usage, one needs to know how the data looks like before compressing it
ur attempting lzma basically, but with size limit
ye I just remembered this project today and that kuuhaku told me to try it with binary (it was fully text based before)
I remember it yes
its the same concept I had with text
also
from a performance standpoint its pretty terrible xDDD
was it like 13ms to compress that txt?
from a working standpoint it is too
if u want to make a compressor, u could check how lzma is implemented https://7-zip.org/sdk.html
for the entire roundtrip, yes
read and write is included
I mean I could make this use streams but not like ill ever use this project for something anyway
how if I for example load 64k bytes at a time
64k is still very small
id only use streams when you're at 1mb+
streaming doesnt make anything faster, its just a way to split the job into chunks so the user can save them more efficiently
otherwise streaming actually makes the job itself slower, since it has more work to do
should I try compressing a 10gb file with the current state
gimme a split number
23
nodejs trolling https://fs.rjns.de/v/cDFWLlzWmpFjqgnkoz
xDDD
ok Ill do 1gb
your current code needs the entire file in memory right?
ye
so it will use several gb of memory to perform that
should be fine as long as node survives it
xD
pretty good
smhsmh
⚡ [BAD COMPRESS]: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░░░░ 1m39s Processing Bytes 915380289-915380312
<--- Last few GCs --->
[1587285:0x5d25320] 98701 ms: Mark-Compact 4049.9 (4130.9) -> 4035.2 (4132.1) MB, 1654.43 / 0.00 ms (average mu = 0.130, current d
[1587285:0x5d25320] 99942 ms: Mark-Compact 4051.1 (4132.1) -> 4036.3 (4133.1) MB, 1219.77 / 0.00 ms (average mu = 0.084, current d
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xc7d530 node::Abort() [node]
2: 0xb638e8 [node]
3: 0xe8ee70 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
4: 0xe8f157 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
5: 0x10a07c5 [node]
6: 0x10a0d54 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
7: 0x10b7c44 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, cha]
8: 0x10b845c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallback]
9: 0x108e761 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::Allocat]
10: 0x108f8f5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::Alloca]
11: 0x106ce66 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::intern]
12: 0x14c7c36 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x7fe3df699ef6
Aborted (core dumped)```
.-/+oossssoo+/-.
`:+ssssssssssssssssss+:`
-+ssssssssssssssssssyyssss+-
.ossssssssssssssssssdMMMNysssso.
/ssssssssssshdmmNNmmyNMMMMhssssss/
+ssssssssshmydMMMMMMMNddddyssssssss+
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/
.ssssssssdMMMNhsssssssssshNMMMdssssssss.
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ vscode@DE-01
ossyNMMMNyMMhsssssssssssssshmmmhssssssso ------------
ossyNMMMNyMMhsssssssssssssshmmmhssssssso OS: Ubuntu 22.04.3 LTS x86_64
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Host: KVM/QEMU (Standard PC (Q35 + ICH9, 2009) pc-q35-7.2)
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Kernel: 5.15.0-84-generic
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Uptime: 7 days, 1 hour, 59 mins
+sssssssssdmydMMMMMMMMddddyssssssss+ Packages: 769 (dpkg), 4 (snap)
/ssssssssssshdmNNNNmyNMMMMhssssss/ Shell: bash 5.1.16
.ossssssssssssssssssdMMMNysssso. Terminal: node
-+sssssssssssssssssyyyssss+- CPU: Intel i9-9900K (10) @ 3.599GHz
`:+ssssssssssssssssss+:` Memory: 19655MiB / 52204MiB
.-/+oossssoo+/-.
```
it would probably be possible to compress that file to like 500bytes
its just zeroes
xD
theorically, the maximum possible compression for 1gb of zeroes is 5-6 bytes, and its very easy to make
but of course, that would only work with a very specific compression method, and not a general purpose one
cant you theoretically do something like telling a decompressor to just repeat sections of bytes?
such as :
00 00 00 00 f3 fb c3 55
to
00 04 f3 fb c3 55
04 being the indicator of length of hexadecimal sections
though there would need to be some sort of indication that the decompressor should read that as such
thats exactly what most algorithms do
RLE = run length encoding
most compression algorithms implement a form of RLE together with other methods like lookup tables
why not just use something like zlib
because thats not fun
so you love pain
yes
i used to work with buffers a lot in the past and the process is definitely not fun 
probably some sort of lookup table
thats what i would do
speak for yourself, i like working with buffers, they are fun
ArrayBuffers are pain
i like them xD
JS bit-shifting operators are pain
binary arrays are fun
yeah that part of js is utter crap, but you can always use the math method instead of them
thats what i do to shift numbers bigger than 32bit
i wonder if there is a convenient npm package for that 
I think tim made one
insane
lmao yup
One message removed from a suspended account.
One message removed from a suspended account.
oh no its a c# dev
run

One message removed from a suspended account.
One message removed from a suspended account.
yes
Ew rust
Don’t you dare slander rust like that
One message removed from a suspended account.
One message removed from a suspended account.
wdym he's right
the rust game is bad
he's a certified karat dev 
People so mad about C#, a great language tho
discord.errors.HTTPException: 429 Too Many Requests (error code: 30046): Maximum number of edits to messages older than 1 hour reached.
Is this new?
nope you got ratelimited
Aye, but hasn't happeneed in 8 months, so was curious
likely many users using the same command in the same channel
also remember message sends/edits share the same ratelimit
It specifies older than 1 hour tho
still
Im just confused as i've not had this issue eveer before, and the bot isn't being used and more or less then it has since 8 months ago. Idk why it's only happening now
because users
also, it's dangerous that you hit a 429 at all, most reputable libraries would have an internal bucket
and the bot isn't being used and more or less then it has before
did you check if it wasn't added to a botfarm?
Nope, i'll try change it anyway, but 99.9% sure I didntt
those are the only possible reasons for that error
a - many users using commands that edit a message in the same channel at once
b - automatic message editing snowballing
c - token leak
Where is the error triggering? That should give you an idea
SyntaxError: Cannot use import statement outside a module
???
{
"compilerOptions": {
"target": "ES6",
"outDir": "./build",
"moduleResolution": "node",
"rootDir": "./src",
"resolveJsonModule": true,
"downlevelIteration": true,
"module": "CommonJS",
"skipLibCheck": true
},
"exclude": ["node_modules"],
"include": ["src/**/*.json", "src/**/*"],
}
import * as fs from "fs";
import * as path from "path";
function main() {
let file = process.argv.slice(5)[0];
fs.readFile(path.join(), console.log);
}
main();
index file
it's weird cuz my other project has the exact same settings and there it works
try checking your package.json
maybe u accidentally declared it as a module
although it shouldn't be a problem if TS transpiled it to require()
but I'm guessing it doesn't if you look inside your dist folder?
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node ./src/index.ts -e ts --dev main.vig"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.8.1"
},
"dependencies": {
"typescript": "^5.2.2"
}
}
Uh why not tsc && node dist/index.js
Since this is a basic configuration, take a look at https://m.youtube.com/watch?v=H91aqUHn8sE
Learn how to setup Node.js with TypeScript while supporting native ES modules. Use the new NodeNext option to easily interop between CommonJS and ES modules in the same project.
Full Lesson and Source Code https://fireship.io/lessons/typescript-nodejs-setup/
same error
Easy to follow and usually doesn’t cause many issues
Yeah it depends on your setup, I usually name it dist
and this too
yeah no, I didn't save my package.json. Now it works
well I copied it from my bot where i used nodemon
guess it's late and forgot I should've changed that too
Nahh the real crime is using whatsapp for that kinda stuff 😂
better than our team that insists on skype
mine is on discord 
lucky mf /j
discord would literally fit like a glove for us, but they refuse because reasons
I'd like to get the core team in discord
But implementation team will prolly cry about it
why?
Cuz they suck

Implementation team is so fkn lazy i swear
We do more customization for them than the clients
my entire team is lazy
honestly? somewhat my exact case
our database triggers and ERP are built around not letting the support team fck up the client's database
A developer should always try for every edge case or hire people to test their program to see how they can break it
Yes we have lots of those too
They make the job easier
But sometimes report random shot
Shit
I mean, we could use user accounts for the support team instead of root access (database), but they also refuse to setup it
Reminds me of this
In 1985, a state-of-the-art radiation therapy device called the THERAC-25 started blasting holes through patients' bodies, leading to the world’s first death by radiation treatment overdose. It killed two more people before anyone knew what was going wrong. Why?
💪 JOIN [THE FACILITY] for members-only live streams, behind-the-scenes posts, and t...
Right!!!!!
we could also not use a damn archaic database in a EoL release
but they also refuse to update
They wanted to run the project on docker containers on their machine while requesting realtime updates within 30 seconds
What database do you folks use?
we're managing to get them to update it to at least the LTS release after 3 years of discussion
firebird 💀
WHAT
FIREBIRD
bruh what fucking companies are u even in
No fucking way
Lol
lmao yes, we tried to convince the head to switch to postgres or any other decent database
but they think migrating would be more work than it's worth
btw we cant use functions because the database doesn't support them
I started migrating from aws to gcloud within 2 weeks of joining
Reminds me of my current issue with prisma and goland
We are using a very outdated version of prisma
So we are completely switching up
Prisma works with firebird?
No that was abt my case
oh yeah
"""Firebird technology has been in use for 30 years, which makes it a very mature and stable product."""
i forgot theres a lot of people here
Golang
Its mature
It has manners
also firebird: the only decent DBM is written in delphi and only added support for window functions in version 3
you cant even fathom how hard it is to have row_number() but without that function
I haven't done it yet so don't attack me for it but is it a bad thing if I was to make an owner only command to make an invite to a server its in. This would be used for bug reports or when I detect bad use of the bot (trying to break the bot on purpose) or sum like that?
If you dont disclose that in your privacy policy that you might do that, then yes
yes its bad
if you do declare that, you aight
There's no concrete answer and others might have different answers but from my perspective, if the staff of the server you're joining to knows that you'll join then there shouldn't be a problem, otherwise it's bad
Also yeah, better to explicitly mention that in your Privacy Policy
Alright thanks. Just was checking to see if possible before I do anything like that

Is there a proper way to fetch data from an API and convert it into a list of model objects in dart @lyric mountain? I'm using this right now but it's obviously not going to work since it doesn't know how to serialize into a Category object by default right? ```dart
late Future<List<Category>> _future;
Future<List<Category>> fetchCategories() async {
var data = await http.get(Uri.parse('http://10.0.2.2:8080/categories'));
if (data.statusCode == 200) {
return List.from(jsonDecode(data.body)['data']);
} else {
throw Exception('Failed to load menu categories');
}
}
@override
void initState() {
super.initState();
_future = fetchCategories();
}
Sample response: ```json
{
"status": 200,
"message": "success",
"data": [
{
"id": "CWEFCTHAZ723G",
"name": "A - Category 1",
"items": [
"Q636YGQ4B1NKA",
"9GGQYZEHEEN10"
]
}
]
}
Found this, I suppose it should work fine ```dart
var list = List.from(jsonDecode(data.body)['data']);
var newList = list.map((x) => Category.fromJson(x)).toList();
return newList;
jsonDecode returns a variant type, u can simply jsonDecode() as List
Yeah but I'm not sure if that'll work to do jsonDecode() as List<ModelObject>
maybe it does, never tried
I hate docker and ufw
well I dont hate themselves
but I hate trying to make both work
The new chatgpt devs are amazing
I have something very similar to this. He is working on a big project but knows nothing about scaling
Ben is a fivehead
is that the software error that caused a medical machine to give 3x the lethal dose of radiation to 6 people, only having one casualty?
Yes
therac-25 i remember reading about that
Though it goes into a lot more detail than the others
sad thing was it went through two software errors, i think the third one they found the original (albeit not the root cause) problem. first one was a race condition that went unnoticed during development and review. if a user misstyped the character, the machine would default but the safety system would fail to catch up. the second error was arithmetic overflow which was the machine exceeding memory
Yep, this is why you thoroughly test software before going live
And hire people to test it to see how they can break it
Ong 💀😭
When a user selects something from a select menu can I remove the selection? So it goes back to the place holder
yep
lemme grab the code rq
await interaction.update({ });```
then js await interaction.followUp({ content: "hi" }); to reply after
Alright it works, thank you!
Hey there, can anyone help with how to embed our website on the bot page?
Yep
Ah, it just didn't work in the preview
is it possible to just edit the css custom properties from topgg?
I guess
But you can't edit it too much
Like everything related to ads can't be changed
for (const guild of client.guilds.cache.values()) {
console.log(`we in ${guild.name}`)
}
Why is guild.name undefined for all guilds my bot is in
do i need these?
client.guild.cache.map(Guild => { ${Guild.name} })
try that
const guildNames = client.guilds.cache.map(guild => guild.name);
console.log(guildNames);
you're running that before the bot is ready
i put it inside
client.once('ready', async () => {
///
})
and even surrounded it with a setTimeout(..., 4000 ) inside the client.once('ready')
show your client options
uncomment that
👍
is there a way to sell apps on the app directory or is it still in alpha/beta?
in the US, yes
but thats for subscriptions on bots only, i.e. premium
discord takes a huge cut though, it is so not worth it at the moment
Hello I'm new in nextJs, I get this error:
⨯ TypeError: Invalid value for schema path `id`, got value "null"
at Schema.add (C:\my-data\dbl\node_modules\mongoose\lib\schema.js:680:13)
at new Schema (C:\my-data\dbl\node_modules\mongoose\lib\schema.js:137:10)
at eval (webpack-internal:///./src/app/model/botsDb.js:7:16)
at ./src/app/model/botsDb.js (C:\my-data\dbl\.next\server\pages\add\bot.js:55:1)
at __webpack_require__ (C:\my-data\dbl\.next\server\webpack-runtime.js:33:42)
at eval (webpack-internal:///./pages/add/bot/index.js:19:75)
at ./pages/add/bot/index.js (C:\my-data\dbl\.next\server\pages\add\bot.js:33:1)
at __webpack_require__ (C:\my-data\dbl\.next\server\webpack-runtime.js:33:42)
at eval (webpack-internal:///./node_modules/next/dist/build/webpack/loaders/next-route-loader/index.js?kind=PAGES&page=%2Fadd%2Fbot&preferredRegion=&absolutePagePath=.%2Fpages%5Cadd%5Cbot%5Cindex.js&absoluteAppPath=private-next-pages%2F_app&absoluteDocumentPath=private-next-pages%2F_document&middlewareConfigBase64=e30%3D!:24:81)
at ./node_modules/next/dist/build/webpack/loaders/next-route-loader/index.js?kind=PAGES&page=%2Fadd%2Fbot&preferredRegion=&absolutePagePath=.%2Fpages%5Cadd%5Cbot%5Cindex.js&absoluteAppPath=private-next-pages%2F_app&absoluteDocumentPath=private-next-pages%2F_document&middlewareConfigBase64=e30%3D! (C:\my-data\dbl\.next\server\pages\add\bot.js:22:1)
at __webpack_require__ (C:\my-data\dbl\.next\server\webpack-runtime.js:33:42)
at __webpack_exec__ (C:\my-data\dbl\.next\server\pages\add\bot.js:227:39)
at C:\my-data\dbl\.next\server\pages\add\bot.js:228:104
at __webpack_require__.X (C:\my-data\dbl\.next\server\webpack-runtime.js:116:21)
at C:\my-data\dbl\.next\server\pages\add\bot.js:228:47 {
page: '/beta/auth'
}
even tho i have just imported schema but havent accessed it
import schema from '@/app/model/botsDb';
Show your src/app/model/botsDb.js file
import mongoose from 'mongoose';
const schema = new mongoose.Schema({
id: null,
data: {
user: {
id: null,
botName: null,
avatar: null,
prefix: null,
serverCount: 0,
shardCound: 0,
},
webInfo: {
title: null,
shortDes: null,
longDes: null,
inviteUrl: null,
supportServer: null,
website: null,
github: null,
tags: [],
owners: [],
votes: 0,
webhoook: {
url: null,
pass: null,
},
}
},
token: null,
aproved: false,
});
const Model = mongoose.model('bots', schema);
export default Model;
if i do id: String still same error
i havent accessed schema yet but just imported
You can't use null as a schema type, the permitted schema types are listed here
I used String to but same error
Then you're most likely not saving the file, if you're saving it, show the new error that you get
send error
Does anyone know how to get VSC to output “Segmentation Fault” when running C++ using CMake? Instead of outputting when I segfault, the program just stops entirely and outputs nothing, and it’s really fucking annoying
Never thought I’d be asking to see a segfault, but here I am
thats windows segfault for you 
welcome to the real world of C++
jokes aside try this https://youtu.be/2GgtLFYJhxc
In this video we explore a classic problem which puzzles many. And then explore how to debug its segmentation fault using three methods
o VSCode debugging
o Using core file and gdb
o Valgrind
@wheat mesa
I think it's just the way that windows handles it
I'm capable of debugging it, it's just annoying that I don't even see any output whatsoever
even just seeing like "program exited with code -127892348762348763247823648732658325498734698217346659783426" would be more useful
i'm sure that's possible with vscode
if not then try debuggers like gdb
Is there a doc somewhere that explains how to make a subscription for the bot or how to make it premium?
Nm I found it! Thanks for letting me know! They finally released it!
doesn't mean you should use it
Premium features? Ewww
no
not included

6% + 30%
- any transaction fees
Disadvantages of free hosting
Depends on what you mean by "cheap". For some people $1 is cheap, for others it's $20
With what?
Describe your problem here
my first bot
i cant develop it
i need really serious help bout that
@deft wolf
can you help me?
Maybe if you gave more details. "I can't start it" doesn't give me any leverage since I don't know what programming language you're using
C:\Users\Administrator\Desktop\Örnek Bot>node index.js
node:internal/modules/cjs/loader:1051
throw err;
^
Error: Cannot find module 'C:\Users\Administrator\Desktop\Örnek Bot\index.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
at Module._load (node:internal/modules/cjs/loader:901:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_ma
in:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.8.0
C:\Users\Administrator\Desktop\Örnek Bot>
i got this error
and i am using js
There is apparently no index.js file there
seems like it can't find the main module which is the file index.js
what they said
but i already did npm i index.js
that's not the point
Like discord.js
can i share screen to you?
so the problem is, in the file path, it can't find that index.js file
creeper can you come to dm?
C:\Users\Administrator\DesktopÖrnek Bot\ index.js isn't found in that file path
check your dm
you need to make an index.js file in your director
type ls and show us what it prints to the console
ls works on windows?
i dont think so
please do node index.js
npm i is an installer, not an initializer
i cant use vsc in windows 2012 r2
can you come to dm?
bro
just create an index.js file
if you use node <file> and the file doesn't exist it can't do much right
what is nodemon
with start.bat
a runtime watcher (reruns the scripts when source file changes)
it never does that
i can show you
at least in my case, it doesn't
i have to explicitly start admin shell via start menu
why is index.js a folder
translate the whole phrase
open the cmd on here
unless i can't see that well
regardless, you should find a way to de-escalate the permissions
let me search it
is index.js a folder or a file?
also index.js should be a file
on that screen
you created it as a folder, so node index.js won't start
i did it now .js
removed folder and
ye
because index.js is supposed to be a file, node index.js is looking for the file index.js in your bot's folder. it won't use a folder
let me start it again
it always starting with administrator
not starting
@civic scroll
for now though
don't do nodemon
just node
also
what is the code of index.js
i need show my screen
@civic scroll dm
here have a problem
and i cant add you
just screenshot the code
huh
yeah
'nodemon index.js'
i deleted nodemon and did node
oh
yeah
yeah
literally paste the code in here
no prob
i opened
var fs = require('fs'),
path = require('path');
var exports = module.exports = function(dir, options) {
var modules = {};
options = merge(options || {}, {
lazy: true
});
fs.readdirSync(dir).forEach(function(filename) {
// filter index and dotfiles
if (filename !== 'index.js' && filename[0] !== '.') {
var moduleName = path.basename(filename, path.extname(filename));
var modulePath = path.join(dir, moduleName);
// lazy load
if (options.lazy) {
Object.defineProperty(modules, moduleName, {
get: function() {
return require(modulePath);
}
});
} else {
modules[moduleName] = require(modulePath);
}
}
});
return modules;
};
function merge(obj, src) {
for (var key in src) {
if (src.hasOwnProperty(key) && obj[key] === undefined) {
obj[key] = src[key];
}
}
return obj;
}
now like that
path = require('path');
var exports = module.exports = function(dir, options) {
var modules = {};
options = merge(options || {}, {
lazy: true
});
fs.readdirSync(dir).forEach(function(filename) {
// filter index and dotfiles
if (filename !== 'index.js' && filename[0] !== '.') {
var moduleName = path.basename(filename, path.extname(filename));
var modulePath = path.join(dir, moduleName);
// lazy load
if (options.lazy) {
Object.defineProperty(modules, moduleName, {
get: function() {
return require(modulePath);
}
});
} else {
modules[moduleName] = require(modulePath);
}
}
});
return modules;
};
function merge(obj, src) {
for (var key in src) {
if (src.hasOwnProperty(key) && obj[key] === undefined) {
obj[key] = src[key];
}
}
return obj;
}``` made it easier to read
what should i do to var
did you... copy-pasted this code from somewhere
i'd recommend you rewrite the bot from scratch
that way you will understand what the code does
using existing code won't help
also i'd recommend you update the vps to latest version of windows or install linux, if possible
since it's easier to get access to latest technologies
'provides a function for loading all modules in a given directory into an object'
that won't do them any good
they still won't understand it
fair
how did you do it
'''
C:\Users\Administrator\Desktop\discordJS-V14-main>node index.js
(node:6500) ExperimentalWarning: stream/web is an experimental feature. This fea
ture could change at any time
(Use node --trace-warnings ... to show where the warning was created)
token
'''
@grim aspen
no not single quotes
backticks
C:\Users\Administrator\Desktop\discordJS-V14-main>node index.js
(node:6500) ExperimentalWarning: stream/web is an experimental feature. This fea
ture could change at any time
(Use node --trace-warnings ... to show where the warning was created)
token```
like that
dude how
Ok are you on windows
yeah
what keyboard layout do you have? US?
turkish qwerty keyboard
` here, copy this
`
copy this
and then put 3 at the front and 3 at the back
but it looks like its right next to the 1 key on your keyboard
Just paste six times
to the left
some keyboards are diff
(node:6500) ExperimentalWarning: stream/web is an experimental feature. This fea
ture could change at any time
(Use node --trace-warnings ... to show where the warning was created)
token```
okey did
There we go
for example backtick isn't above tab for me
what is this error
right there
it's right to P
understood
yes thats why i asked what layout they have
what should i do now?
it's just a warning
it's not an error
it's a warning that stream/web could change at any update or break dependant code entirely
if the bot isn't online then it's another issue entirely
i mean, do you get any other errors?
nah only that
ok github gist
pastebin removed on my country
whatever
kuuhaku dm
...
Never had ads on pastebin tbh
adblocker likely
i mean does it really matter what they use? github gist, hastebin, pastebin, it's all the same in the end
kuuhaku r u coming to my stream?
Yoo
let me send what i using
i send
paste trades code space for ads, the other 2 options focus on making code actually readable
I assume u did change config.js before starting right?
yeah i put my bot token to token and prefix to .
ok, just checking
are you sure you dont have any other errors
@rustic nova
hold on
they said it wasn't coming online
yes
not that it wasn't responding
if it isn't enabled you wont be able to login
because their code uses it
i am not using vsc
that... has nothing to do with vsc
^ did you?
i am not using vsc
dont think ur understanding
i will reset token
those two lines cannot exist if they aren't enabled on discord dev panel
bot's token
why're you logging the token
let me open
why're you console.logging the token tho
either remove those lines or enable the intent on dev panel
i did
did enable them?
yw, but do note that you wont be able to use them after being approved by discord
unless you find an actual reason to use them
the message content shit is the dumbest thing discord ever did
honestly, I do see their point
?
@lyric mountain
i did whatever you say
but
when i open the bot
works like 1 min
and its closing
They were speaking turkish
If you close the terminal, your bot will turn off
terminal is closing automaticlly
C:\Users\Administrator\Desktop\discordJS-V14-main>node index.js
(node:6900) ExperimentalWarning: stream/web is an experimental feature. This fea
ture could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
?????????????????? SuperVisor#9244 Bot Online!```
says this
and terminal closing
I see it
hi iam new to here
what should i do?
You need to find the reason why your terminal is closing automatically
@earnest phoenix use command it shows you
says this
node --trace-warnings
ngl thats never worked for me 😦
it’s works for me
When I do the command it shows nothing which is weird
you have a circular dependency
what is that mean?
file A depends on file B that depends on file A
but well, it's hard to give any concrete answer without seeing the actual post-crash log
what is folder name for errors?
instead of running the bot directly, open a command prompt and call the script from inside it
this will prevent the terminal from closing after exiting
node index.js is the command
and please indent your files
having everything aligned to the left isn't readable
how to indent
...what?
i cant index
What is that
indent is simply
function abc(param) {
if (param == something) {
doThing();
}
}
doing this
function abc(param) {
if (param == something) {
doThing();
}
}
from this
to this
where sohuld i paste it
it's not something you install
you dont paste anything, you just press this
to align things
sigh ok, let's ignore the indentation thing for a moment
what did i walk into
open a terminal through win + R an then type cmd
did
yes
then type node index.js
it'll execute the code and then exit, as normal
BUT the terminal wont close this time
so you can simply show what appeared on the terminal
so we can know the crash cause
^
at C:\Users\Administrator\Desktop\discordJS-V14-main\events\ready.js:17:27
at Array.forEach (<anonymous>)
at C:\Users\Administrator\Desktop\discordJS-V14-main\events\ready.js:14:7
at FSReqCallback.oncomplete (node:fs:188:23)
C:\Users\Administrator\Desktop\discordJS-V14-main>```
@lyric mountain
there it is
Now go to 'events/ready.js' and show us what's on line 14
likely on this line
Oh, ok