#development
1 messages · Page 1994 of 1
okay. tysm
ok so I need help with a beginner c++ program
i know how to generate a square but I cant figure out how to change the shape
and this is what I have so far
Circle can be expressed by a function of sin and cos
Triangle has many ways of achieving, and depends on what type of triangle
Easiest would be a right triangle
Pentagon I have no fckin idea how
Not with ascii
how and where am i getting that?
I dont got problem with the other ones, it's just the square. I need to print square that changes it's size based on the length provided by the user input
export const SQL_TABLE = `
CREATE TABLE IF NOT EXISTS Users(
userId TEXT NOT NULL PRIMARY KEY,
rice BIGINT DEFAULT 10000
);
CREATE TABLE IF NOT EXISTS Items (
itemId INT PRIMARY KEY,
userId TEXT,
name VARCHAR(21) NOT NULL,
description varchar(150),
value BIGINT DEFAULT 10,
rarity TEXT NOT NULL,
CONSTRAINT fk_user
FOREIGN KEY(userId)
REFERENCES Users(userId) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS Alliance (
allianceId INT PRIMARY KEY,
name VARCHAR(21) UNIQUE,
rice BIGINT DEFAULT 10000
);
CREATE TABLE IF NOT EXISTS Alliance_User(
userId TEXT,
allianceId INT,
CONSTRAINT fk_user
FOREIGN KEY(userId)
REFERENCES Users(userId) ON DELETE CASCADE,
CONSTRAINT fk_alliance
FOREIGN KEY(allianceId)
REFERENCES Alliance(allianceId)
);
`
Sorry for poor formatting.
But I read online that using ON DELETE CASCADE on a foreign key will delete that record as well when the parent record is deleted.
Do I have to use ON DELETE CASCADE on every table that makes a reference to the parent?
or you dont copy it right
Nah I copy it correctly cause it pastes correctly but when hitting send it comes out like that
Ooooh new typescript version allows code before super() in constructors
Interesting
Unless you don't use classes lol
I wonder if it will allow using this before super
It doesn't
😔
Code before super() was always a thing in javascript
but ts didn't allow it until now
How can I compile a single ts test file as sibling js file
I don't know why you'd want to but iirc you can just use the outFile option
sigling js file?
you could use ts-node
does ts node compile stuff?
you could also use the outFile compiler option
iirc that makes your entire ts project compile down into a single js file depending on the name u give it
that is not what I want
yes, I just want to compile a single ts file. Just want to convert some ts code to js equivalent. In node's env
What
do you got an issue
no
it's the naming
fuck_user
this sounded way more offensive then I meant it to
I highly recommend keeping your SQL schema changes inside migrations and not in source code
no
I am new to using raw sql so no idea what this means or how to do it
look up what migrations are
alright
it's a way of making changes to your database schema over time
there are tools that will "version" your database for you
Do you have any recommended tools?
it depends on what you're using
as in what dialect?
I use prisma as an ORM which has its own migration tool
if not you can use something like https://github.com/db-migrate/node-db-migrate
I am trying to step away from using orms personally
nothing wrong with orms rly
Well yea
just don't try to use an orm to solve every single problem
I just feel like I don't know what iis actually happening under the hood
fair point
I mainly used typeorm in the past
super complex
you don't need an orm, most js orms just save you writing things out and that's it
my raw queries are scary
nothing dangerous about it if you just use prepared statements
static async update(userId: string, data: Partial<UserData>, client: InteractionCommandClient) {
try {
let sqlQuery = `
UPDATE users
SET `
sqlQuery += Object
.entries(data)
.map(([key, value]) => `${key}=${value}`)
.join(', ')
sqlQuery += `
WHERE userId = $1
`
await client.pg.query(sqlQuery, [userId])
}catch (error: any) {
throw new ShogunError(error)
}
}
This is how I update things
raiden shogun????
hm?
yeah that's not a great idea
i don't work with sql
I feel like I should understand a reference here but sadly I dont sayuri
i saw my dad writing raw queries and it's a pain to watch
if you're gonna do this just use knex
I looked at knex it looked complex
tru
usually the idea behind "I'm gonna write raw sql" is that you keep things simple and don't do wacky abstractions like these
Do you just feed knex sql to create tables or how does tables work with knex?
because you're just making your own query builder at this point
fair point
but a strictly worse one
it's a way of building queries dynamically which is what you're trying to do at this point
you're essentially looking for
knex('users')
.where('userId', '=', userId)
.update(data)
wtf is this
Why does this look complex or is my tired brain just not comprehending htis right
this is just typescript
ye ik its ts
it's a way of adding your own types to knex
but I dont see the point of it
you dont see the point of types?
so you can get a typed object back when you query
it's declaration merging, you're injecting your own types inside "knex/types/tables"
otherwise you get back any for every query
I see
I might actually do that then since it would be nice getting typed data back
I will look into using knex then thanks
ye you're still writing raw sql just in a more convenient way
I hate how databases just give you a shitty DSL and absolutely nothing to back it up
Would I even need helper methods still if I am using knex?
Would it just be easier to do all the queries in the instance I am needing it
I would still use some kind of repository pattern
if you do inline database calls it becomes insanely difficult to make changes like swapping out database providers or doing logging. Learned that the hard way with topgg lol
I see
but also it's more work, so it's up to you
people still use knex?
I think it's a db driver
kind of like sequelize
lets you provide a driver and it manages the db stuff for you
except the layout is more functional than object orientated
Hey! I'm trying to make a discord login system in Svelte. I have not been successful, despite trying every possible way. Can you briefly summarize how I can do it?
front-end and back-end work on different ports
I found a svelte-kit about it, but I don't even know what it does or how to use it.
So svelte-kit provide a very easy to use layer over svelte for developing the frontend and doing things like SSR
the majority of the work will be done by the backend i.e all of the oauth flows
The only job your frontend is really doing is redirecting the user, storing the computed token and making requests with said token
Svelte-kit is like a package?
Svelte-kit is to svelte what NextJS is to React
For example, when I try to do this, I keep getting "TokenError: Invalid "code" in request." I get an error
okay, well that just means that the oauth code you've given to discord to exchange for an access token is invalid
codes are one use and come with an expiration of about 5 minutes
I'm really confused trying to do this
When I log the user in the back-end, it gives me the values (e.g. username, tag, guilds...)
but it gives an "invalid code" error in the front-end
Why are you making requests to discord from the frontend
I am confused. Should I enter the back-end port as the redirect_uri?
Or should I enter the front-end port?
I'm using translate, sorry
there is no such thing as front end port?
no, i can't do this, i'll quit
lmao
first world problems.... stripe had £90 off me this last month
Can someone help me update the syntax on this?
{"embeds": [{
"title" : "<<<{{Title}}>>>",
"url": "<<<{{PostURL}}>>>",
"thumbnail": {
"url": "<<<{{ImageURL}}>>>"},
"color": 2226949,
"author" : {
"name" : "/u/<<<{{Author}}>>>"},
"description" : "<<<{{Content}}>>>"},
"footer": {
"text": "/r/Amtrak | <<<{{PostedAt}}>>>"}
] }
Looks like you’re missing a } at the end of your array
But it’s like impossible to see on mobile

I see one bracket closing the footer but another one is missing closing the embed object
Well the embed is being closed, just early before the footer.
{
"embeds": [{
"title" : "<<<{{Title}}>>>",
"url": "<<<{{PostURL}}>>>",
"thumbnail": {
"url": "<<<{{ImageURL}}>>>"
},
"color": 2226949,
"author" : {
"name" : "/u/<<<{{Author}}>>>"
},
"description" : "<<<{{Content}}>>>",
"footer": {
"text": "/r/Amtrak | <<<{{PostedAt}}>>>"
}
]},
}
Still
I see one bracket closing the footer but another one is missing closing the embed object
Also wrong
Inside the array not outside
Well it doesn’t need to be a valid JSON format at all
Object keys can be passed without " quotes
I dont think this is a js object
It is
Ok, got it working again. But is there a way to get it to where if there's no image, the thumbnail url doesn't get used?
It was implied when this was discussed yesterday they are making an embed object direct 🤔
Yeah just referring to past discussions
The discussion I saw made no mention of how to get the webhook to skip over the thumbnail if None are present
Using what?
Python still?
I dont think json has that supported directly.
Ok, no big deal then
{
"embeds":
[
{
"title" : "<<<{{Title}}>>>",
"url": "<<<{{PostURL}}>>>",
"thumbnail":
{
"url": "<<<{{ImageURL}}>>>"
},
"color": 2226949,
"author":
{
"name": "/u/<<<{{Author}}>>>"
},
"description": "<<<{{Content}}>>>",
"footer":
{
"text": "/r/Amtrak | <<<{{PostedAt}}>>>"
}
}
]
}
oh lmao it is JSON?

fuck me then
Is there any guide on how to implement CSS to the bot page?
Do I even want to know what language that is in? 😂
By the way, dropping the thumbnail part 
just make it in Brainfuck it's alot more fun
When using an accurate indentation you will be able to see when missing brackets etc.
XD
And colors help too. Seeing it in just black and white doesn't help 😂
wdym, syntax highlighting?
Ye
hi
is there any way to this in shorter style ? or i need to write if statement for each one ?
wdym ?
if(guildData && guildData.BansChannelID && …
Oh I see you changed this
I was referring to yesterday lmao
To this:
well thats for more than 1 schema
now i have one schema
so i want if for example some one delete ban log channel bot change the BansChannelID to null and save it i want to know is there any way to do it shorter or i need to create if statement for each channel ?
if(guildData) {
if(guildData.BansChannelID === channel.id) { guildData.BansChannelID = null; }
if(guildData.ChannelsChannelID === channel.id) { guildData.ChannelsChannelID = null; }
if(guildData.EmojisChannelID === channel.id) { guildData.EmojisChannelID = null; }
guildData.save();
}
another option```js
if(guildData) {
const channels = ["BansChannelID", "ChannelsChannelID", "EmojisChannelID"];
for(const c of channels) {
if(guildData[c] === channel.id) {
guildData[c] = null;
}
}
guildData.save();
}
another option
if(guildData) {
["BansChannelID", "ChannelsChannelID", "EmojisChannelID"].forEach(c => {
if(guildData[c] === channel.id) {
guildData[c] = null;
}
});
guildData.save();
}
or if you wanna simply further
if(guildData) {
["Bans", "Channels", "Emojis"].forEach(c => {
if(guildData[`${c}ChannelID`] === channel.id) {
guildData[`${c}ChannelID`] = null;
}
});
guildData.save();
}
you would do this ```js
if(guildData) ["Bans", "Channels", "Emojis"].forEach(c => guildData[${c}ChannelID] === channel.id ? guildData[${c}ChannelID] = null : null) && guildData.save();
hi
ps: im using tailwind
which one do you suggest to do ??
cause https://sourceb.in/ErIsDdms7V this one is really messy

wtf
giant code, just to save data

show what code u got already
if you dont have any hidden channel not on that list, you can do this ```js
for(const k of Object.keys(guildData)) {
if(guildData[k] === channel.id) {
guildData[k] = null;
}
}
guildData.save();
well i know this isnt good code and im try to find better way 👀
i will send tthis
well there is just a little problem 😁
Yandere dev?
tim do you even use a formatter lol
nope i dont, whats your problem with it?
@marble juniper
I see
for all channels it do same thing except 1
if the channel was media channel 1/2/3 it will change thread option to null too
I just slap code into vsc and copy paste it here
nah
add an exception for those
no idea reading this rn
A couple of issues, Igor. You can use the object-* classes to fix the issue. Also, check out the w-* class.
amm but before the remove it whats your suggestion for those they are exact the same just different ids so users can set 3 different channel whats your idea about create a collection for those ?
for(const k of Object.keys(guildData)) {
if(guildData[k] === channel.id) {
guildData[k] = null;
if(k.startsWith("MediaChannelID")) {
guildData["MediaChannelThread" + k.slice(-1)] = null;
}
}
}
guildData.save();
You should rather use a class for that
creating a collection will allow more than 3 to be set
Or not define width in a grid at all. Unless of course, you wanna say fuck responsive behaviour.
so what about save mediachannel as an array like 3 array and each array become ['id'-'false/true'] and then splice it and check the second part as thread state instead of boolean and check id as channel id
God what complicated stuff are you doing
ok
do you have better idea ?
...you did the hardest ones but is struggling with the easiest?
MediaChannelID1: { type: String, default: null },
MediaChannelThread1: { type: Boolean, default: null },
instead of this...
why not js MediaChannels: { type: array, default: [] } and then add each channel as { id: string, thread: boolean }
i dont know 😂
tnx
so this way we dont need
if (k.startsWith("MediaChannelID")) {
guildData["MediaChannelThread" + k.slice(-1)] = null;
}
too
ye
but we cant use null for an array can we ?
you would need to do something like this instead ```js
if(k === "MediaChannels") {
guildData.MediaChannels = guildData.MediaChannels.filter(c => c.id !== channel.id);
}
or use splice with findIndex for better performance
but also, I'm using grid
guildData.splice(guildData.findIndex(x => x.id === channel.id),1)
wait i need to save all of media channels in MediaChannels ?
yes, that way you dont need to create ID1, ID2, ID3, etc
brb
The object-* class is for image elements.
well im back
so first lets do another one
i have 3 auto thread channel
if i save them as AutoThreadChannels
what should i do instead of this :
if ((guildData.autoThreadData1 && guildData.autoThreadData1 === message.channel.id) || (guildData.autoThreadData2 && guildData.autoThreadData2 === message.channel.id) || (guildData.autoThreadData3 && guildData.autoThreadData3 === message.channel.id)) {
if (message.channel.permissionsFor(message.guild.me).has(["VIEW_CHANNEL", "CREATE_PUBLIC_THREADS"])) {
await message.startThread({ name: `${message.member.displayName} Comments`, autoArchiveDuration: 1440 }).catch(() => null);
}
}
just for check...
if ((guildData.autoThreadData1 && guildData.autoThreadData1 === message.channel.id) || (guildData.autoThreadData2 && guildData.autoThreadData2 === message.channel.id) || (guildData.autoThreadData3 && guildData.autoThreadData3 === message.channel.id)) {
i want to check if message channel is one of the 3 auto threads...
I can't learn JavaScript
Then learn something different
Is there no way for you to restrict the type of the array elements
const channel = AutoThreadChannels.find(c => c.id === message.channel.id);
if(channel) {
...
}
hmm make sense
wdym ?
idk how your db works, but assuming it supports typescript types, you can do this as Klay suggested:
AutoThreadChannels: { type: Array<{ id: string, thread: boolean }>, default: [] }
you need to check how your db's typing works to make it properly
ig mongodb supports type script
One message removed from a suspended account.
no u
ammm
Tim
if (guildData.AutoThreadChannels.find(c => c.id === message.channel.id) && message.channel.permissionsFor(message.guild.me).has(["VIEW_CHANNEL", "CREATE_PUBLIC_THREADS"])) {
await message.startThread({ name: `${message.member.displayName} Comments`, autoArchiveDuration: 1440 }).catch(() => null);
}
i can do this for auto threads cause there is only one object in array and thats id
but for media channel there is 2 object
- id 2. thread state that return me a boolean
what should i do for that the code is something like this rn:
if (MediaChannel1) {
// Do This
if (MediaChannel1Boolean) {
// Do This too
}
}
And same for media channel 2 and 3 but if save all the data in 1 array how can i check both ?
const channel = MediaChannels.find(c => c.id === message.channel.id);
if(channel) {
...
if(channel.thread) {
...
}
}
ok tnx
How can i check if one of the servers overloading my client?
you can metric requests per minute per guild
if you store command logs, calculate the commands/minute ratio
maybe also add an arbitrary system where you weight commands/event handlers are having a certain impact against your bot's performance
can sort by usage and weight
Idk why but my bot has ping alot
And i couldnt find the which server caused that
not necessarily arbitrary, that's a nice idea since you can estimate the impact by grabbing the current cpu%/mem% before, during and after the command execution
Overload server was banned when this happened before
yeah. Just sending a message is no problem, but image manipulation is another thing
hi there is different choice for my log setup
i want for example if the choice was message set channel id for data.MessagesChannelID
const log = { 'Messages': 'MessagesChannelID', 'Join & Leave': 'JoinLeaveChannelID', 'Ban & UnBan': 'BansChannelID', 'Timeout & UnTimeout': 'TimeoutsChannelID', 'Kick': 'KicksChannelID', 'Voice State': 'VoicesChannelID', 'Member Roles': 'MemberRolesChannelID', 'Member Nickname': 'MemberNickNamesChannelID', 'Server info': 'ServerInfosChannelID', 'Server Channels': 'ChannelsChannelID', 'Server Threads': 'ThreadsChannelID', 'Server Roles': 'ServerRolesChannelID', 'Server Emojis': 'EmojisChannelID', 'Server Stickers': 'StickersChannelID' }
so i write this and log[logChoice] will return MessagesChannelID for Messages
but i need data.MessagesChannelID so what should i use ?? data.log[logChoice] or data[log[logChoice]] or something else ?
You either need an enum or a way to reverse K, V to V, K where V becomes K and K becomes V
assuming you understand K, V in { [key: K]: V }
You're trying to take the value the user sends and get they key of the Object right?
yes
Do you know what an enum is
i dont think so
It's Object where it has its original K, V pairs and also those pairs flipped on the same object
// not enum
{ 1: 2, 3: 4 }
// enum
{ 1: 2, 3: 4, 2: 1, 4: 3 }
data[log[logChoice]]
?
also the object after : should be in string or there is no different ?
const log = { 'Messages': 'MessagesChannelID' }
const log = { 'Messages': MessagesChannelID }
which one ?
without quotes its a variable
you said you wanted data.MessagesChannelID
yes
log[logChoice] return MessagesChannelID
then its correct
tnx
what is the problem in this case ?
thats called a dynamic key, you need to use [] for dynamic keys
{ a: 10, [variable]: 20 }
like this ?
yes
ok tnx
can i set boolean as null by default or i should set it false ?
if its boolean its boolean, it cannot be set to null
if you want to set it to null, you have to make it nullable/optional
I dont see why you'd wanna set a bool as null anyway
null is already a fasley value
well there is one reason
oh?
being dumb :^)
oh yea
for real though, in some cases one might want to differentiate it from being "unset"
I guess but I don't see where it would be important to do so.
If you don't want it to do something set it to false
ex: check if user has decided whether they want to attend an event or not
if unset, keep showing the prompt until they chose either interested on not interested
Ah yea
I am watching a Bitcoin in 100 seconds and it made 0 sense to me
my brain too smol
Learn the basics of Bitcoin ₿ in 100 seconds, then build your own blockchain from scratch with Node.js and TypeScript https://github.com/fireship-io/node-blockchain
Support the Cause
Send me some BTC: 13pEjpLf3taeezGkLpn2CMi2YNxaBF7rVZ
Sponsor me on Github for $1 https://github.com/codediodeio
References
How Bitcoin Works https://bitcoin....
lel
"bitcoin in 100 seconds"
checks video
13 minutes long
fucking clickbaits smh
Well no
He explains it in 100 seconds
but then goes in depth on how to make a very unsecure basic blockchain
lel
Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:ws
isnt ws built in
Message.author is a user object yeah
well
such a noob mistake
😭
i am a shitty coder
Misty is the epitome of a shitty coder
node doesn't have a built in ws package as far I know
;)
I just tried o import it as well and it did not work
Go back and fix your compiler before you talk
go back and fix some bitches
Sorry but I like being single rn
no bitches?
Aint got shit weighing me down that way
Well if she's the top and you're the bottom...
femdom
You know the shit
shut up

no, ws is a third party package
yes, both can be used to create your own ws
but none of us in the development chat are as smart as tim
except me 
If I make a Rest request and get an object of an item like f.e.:
{
"id": "123",
"price": "1.20",
"storage": "20"
}
And I render it. How can I make an onClick function which reduces the storage of the item by 1 + rerenders it?
new fav site https://just-read.it/
So say I have an array of items and I only want the first 5 how would I get that again?
nvm I think i would use slice
yessir
by render im assuming you mean react
Yess, Well I found a solution now by saving the rest response in a state and then just edit the json aka state
why can't we change bot usernames and pfps anymore
you can
lol
thats odd
i looked at the docs its refers to but its irrelevent
you can't even copy token anymore
2fa is stupid
not giving my phone number to discord
one data breach and boom every indian scammer under the sun has all my details
use some auth app then smh my head
they already have your email and password (if you potentially reuse those) though
which are pretty significant on their own
i mean i have like 5 emails and i dont care if one or two of those get leaked
though if I had to guess about not being able to update bot usernames and pfps, some idiot at discord introduced a bug and couldn't be bothered to fix it at the time so they slapped on the banner
probably
or some one made some bot that just created acounts and maxed out their bot count to make some massive botnet to crash discords backend or somthing
but you can do that with the modify current user endpoint already
no wait
yeah no
hey is anyone familiar/good with ubuntu 18.0.4 apache server and knows how to setup reverse proxys for virtual hosts? if so please DM me! 🙂
necessarily apache?
@atomic kindle is good at nginx
Hi!
If you'd post the query here, it'll be useful for people in the feature who might face the same issue.
Also, I can help you out if you're using Nginx.
im trying to make it so for my domain that api calls hit the local nodejs server
and i dont think its nginx
its an apache config file
but tbh idk, dont work with server config much
I have zero experience with Apache Servers, but if you'd like to achieve the same with Nginx; I can help.
Ok i will see if it can switch it to nginx
that's why I asked kekw
nginx is so much easier and straightforward to setup reverse proxy
Nginx isn't too bad. I prefer haproxy if I had the choice.
I mean, nginx certainly isn't perfect, we just all agree apache is a mess
IIRC, isn't haproxy a load balancer?
Yes, which is the same thing as a reverse proxy :)
If you need more than that, then nginx for sure.
At work we use haproxy for our ingress controller. Rock solid. Does one job and does it well.
Maybe around 75 vhosts / ingress routes.
Wow. I most certainly agree with you that haproxy is the best at what it does, but I didn't suggest it because the user seems to be looking for a simple solution for reverse proxying.
If the use case was enterprise level, then haproxy all the way.
Not to mention, haproxy's configuration can be a little intimidating to a first time user.
I have largely stopped using gateways like that now
Other than the occasional kong gateway, just easier to mount to cloudflare tunnels and just not worry about it 😅
Do you use kubernetes?
I think Google cloud has a similar protection product for their external load balancers (we use Google)
Nah
It is very very rare we run into situations where k8s actually makes sense and isn't just overcomplicating
I love it, but it's not needed in most cases
Fair enough. There is a lot of mental overhead with kubernetes.
It is only worth it if you have lots of different workloads and need the flexibility and resource management.
I mean even then, it's often easier to just not and use something more simple like just using more instances if on a cloud provider or just using docker swarm (which although im not a massive fan of, it's certainly good enough at replacing tasks that K8s would normal go e.g. multi-machine scaling) 😅
just because it doesn't take 1000+ lines of yaml to setup and maintain 
Haha yaml for days. Yep.
How should I make timed events that persist even after bot restarts. Should I use cron jobs that run on separate process from the bot or?
Put the jobs in a db with a field to mark them as completed or not, and the desired run time.
Using Cron or polling check for jobs that need running.
Mmm
I think I get what you mean
No idea what polling is tho
basically checking for data manually in an interval
instead of getting an event
so
const { AutoPoster } = require('topgg-autoposter')
const autoposter = AutoPoster(process.env.ggToken, client)
is enough ?
edited
client.Manager.updateVoiceState(data);
TypeError: Cannot read properties of undefined (reading 'updateVoiceState')
but why do i need to define it when i dont use it anywhere
If you don't want to use it afterwards, you can just remove the const autoposter. you will still need the initialiser. (AutoPoster(process.env.ggToken, client))
well my first code was this -.-
AutoPoster(process.env.ggToken, client)
so the whole code become this :
const { AutoPoster } = require('topgg-autoposter')
AutoPoster(process.env.ggToken, client)
Yeah

why cry ?
ia there any way to just send server counts and dont show shards ?
https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6 dpy is returning to life again!
danny start it again ?
read it
I just read it :o
Personally, I doubt Discord.py can do much to "fix" the ecosystem since many bots have already made the switch, so now developers have six libraries to pick from. It wouldn't be as big of a problem if the libraries weren't so similar and stated what they were good and not good at
:O
friends reaction
fetch(`http://api.brainshop.ai/get?bid=156057&key=26SY8BZqy2fJ3MAj&uid=1&msg=${encodeURIComponent(messageCreate.content)}`).then(res => res.json()).then(data => {
messageCreate.channel.send({ content: data.cnt})
FetchError: invalid json response body at http://api.brainshop.ai/get?bid=156057&key=26SY8BZqy2fJ3MAj&uid=1&msg=hi reason: Unexpected token S in JSON at position 0
at /home/runner/mika/node_modules/node-fetch/lib/index.js:273:32 {
type: 'invalid-json'
}
Whatever endpoint you hit did not contain valid JSON in its body
Also does that URL contain an API key
That's weird. It works when I run it.
if im not wrong, it returns json in text format
how about try JSON.parse(res.text())
ok
hi
method: 'post',
path: '/channels/948792913612132413/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
messageCreate.channel.send({ content: data.cnt})
Try logging what data is, since 50006 (the status code) means you sent no content
ok
But it is sent back as a string
lemme see
ah ic, you may try this as well ^
ig its only on embed
String(number) as works
Help !
somewhere you have something.bot but something is null
It's was working fine yesterday

I'm going to die when one thing goes right the other thing that workes will not
XD
yes and so was my pacemaker until someone replaced it with a remote
Hate it when that happens
you too
how do I get the length of a js collection?
(or how do I loop though the values of one)
@zinc fable
Welcome to life of developer where applications require constant maintenance and shit happens for seemingly no reason while everyone is trying to be the next big shot
.size
.forEach
etc
.length too
not for collection/map
js reason: Unexpected token S in JSON at position 0
well now you've heard one person :)
how do I check the length of an array collection
@_@
array and collection is a whole different thing
my console.log doesn't work
That's wack. Can you try this:
fetch(`http://api.brainshop.ai/get?bid=156057&key=26SY8BZqy2fJ3MAj&uid=1&msg=${encodeURIComponent(messageCreate.content)}`)
.then((res) => res.text())
.then(console.log)
This will log the response body from the URL as a string to your console.
ok
I was thinking of collections in general (https://en.wikipedia.org/wiki/Collection_(abstract_data_type)), so it's probably just on me.
wait, i tried this once and it works with json
SPAM
SPAM
ah
Yes, I tried it too (in the terminal and my browser), and it worked for me.
Which is weird.
Show spam
Ah
The server is probably sending you that back
You could look at the full response yourself by removing .then((res) => res.text())
But if I had to assume, you're getting rate limited, so you're not getting the JSON you should be getting.
I'd suggest using .catch to handle errors.
ok
Trying other languages like c# is weird where Array lengths are typically immutable. My brain is melting trying to filter and get Length of results satisfying a constraint

maybe just js is weird
Like, you can't do something like .Length = x/.SetLength(x), or are the arrays immutable in general?
idk this won't work messageCreate.channel.send({ content: data.cnt})
ok I have this html and js
<div>1</div>
<input name="test" class="replace-me" value="sus1"/>
<input name="test" class="replace-me" value="sus2"/>
<input name="test" class="replace-me" value="sus3"/>
<input name="test" class="replace-me" value="sus4"/>
<input name="test" class="replace-me" value="sus5"/>
<div>3</div>
<div onclick="remove()" class="button">Click me</div>```
```js
function change_to_text(old_element) {
var new_elemen = document.createElement("div");
new_elemen.appendChild(document.createTextNode(old_element.value));
old_element.parentNode.replaceChild(new_elemen, old_element);
}
function remove() {
var all_settings = document.getElementsByClassName('replace-me');
for (let setting of all_settings) {
change_to_text(setting)
}
}```
but clicking the button somehow only edits every second button, as shown in the screenshot
.then(data => { messageCreate.channel.send({ content: `${data.cnt}`})
it returns undefined
and it stop saying
(node:6250) DeprecationWarning: The message event is deprecated. Use messageCreate instead
(Use `node --trace-deprecation ...` to show where the warning was created)
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (/home/runner/mika/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/runner/mika/node_modules/discord.js/src/rest/RequestHandler.js:51:14) {
method: 'post',
path: '/channels/948792913612132413/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
I'd recommend you set it up as so:
fetch(...) // ... represents the URL to fetch. You'll get a response that'll be handled in the `.then` block.
.then((res) => res.json()) // Converts the response body to JSON
.then((data) => {
// Send the data to the channel. This is up to you
}).catch((err) => {
// Something went wrong (e.g. response body couldn't be parsed). Deal with the error however you feel like (send an error message to the channel, ignore, etc.)
});
Hii
ok
Don't var please
Just use collections
from the SPAM response, you might want to do if(!data.cnt) return
Arrays as in variable[] are supposed to be fixed-length
What’s the difference in var n let
@sudden geyser this error now
var is broken let isn't
Broken in what way?
there have been cases where using var can have scoping issues iirc
there are probably other reasons why var isn't widely used anymore
but I just know that is one people talk about the most it seems
Var gets hoisted
So pretty much they same things but var is outdated
using let is just prefered
it stays in the scope it is defined in
and doesn't cause those weird errros haku mentioned
Ion even use js anymore it sucked i was never able to make anything functional with it
On the other hand python (chef’s kiss)
that is a user error then
👁️👄👁️
python ain't all that ngl
It ain't
Python is great for scripting, specially when it involves IO
I find it easier plus you dont have to care about stupid semicolon;
But please don't make a big system out of it
you don't really have to worry about semicolons in js as well
unless you're making an anonymous async function ig
I didnt know discord bots were considered big system
it could become a big system
Oh holy compiler please forgive his sins
Js puts it actually
I was on my way to make a dope ass discord bot then someone reminded me that rapptaz abandoned the lib n now im pretty much stuck on which lib to use
any of the maintained forks ig
I am that someone kekw
The question is which fork is gonna last n which gonna get abandoned again
🤷♂️
it is already surprising someone kept a python discord lib going for that long ngl
sure go ahead
The most stable langs to code in are java, js, c/c++ and c#
Not while I'm sober
Go seems stable to
he just announced development is back
On god?
you betraying us?
God
did tim switch to py?
someone literally posted about it here like 30min ago
#development message
Ew you following up on py stuff? betrayer
mhm sure
Js now
Might aswell just wait for v2.0 then
why
Hoisting issues, scope-breaking variables
Weird issues popping out of nowhere
Search up on why var is bad if u want the whole thing
so what else should I use?
Let
@sudden geyser I got it and how I remove the Spam thing
Exactly same usage as var, but doesn't break randomly
Does pytorch use tons of cpu?
how I stop my spam system from muting people that spam in spam channel
make it ignore that channel
how
client.on("messageCreate", (message) => {
const anti = db.get(`antispam_${message.guild.id}`)
const spCh = db.get(`guild_${message.guild.id}_spCh`)
if(!anti)
if (message.channel.name = spCh) {
return;
}
db.add(`antispam_${message.guild.id}` , true)
antiSpam.message(message)
});
i'd change the ids against each other tbh
no
check what the channel the current message is being sent in
and compare that channel id against your anti spam channel id
if i matches don't anti spam if it doesn't continue on
if (message.channel.id === spCh) {
possibly might work
ok
Deep learning don’t know how much different that is tho
deep learning is machine learning
deep learning inside yo momma
avast deep clean
that was mean
successfully deep learning about the feminine gender requires a super computer

or just talk to women
...never mind, this is #development where the only chad is tim
All hail lord Tim
overlay or?
nvm
what
<div class="container">
<div class="sidebar"><div>
<div class="content"></div>
</div>
.container {
/* rules here */
display: inline;
}
.sidebar {
height: 100%;
width: {num}%
display: flex;
flex-direction: column; /* so the child els can lie vertically */
}
@hushed patrol add position: absolute to .sidebar if it's an overlay
hi
hi
```{language}
{content}
```
you need to include {} for content too?
no
ok tysm
please don't use divs for that
<body class="container">
<aside class="sidebar"></aside>
<main class="content"></main>
</body>
didn't know this existed
why do you have the container thingy
cause it is a container
duh
what is it for
Depending on the styles to it
it probably adds some needed stuff like possibly centering content or whatever
setting the size of the content that will go inside it
I don't think you need to put the aside inside the container because you can make it the container itself
<aside class="sidebar">
<header class="sidebar-header">
<h2>Sidebar</h2>
<button>Close</button>
</header>
<p>Content</p>
<!--- Optionally <footer> -->
</aside>
how do i fix that
No one help me
client.commands.get("Whatever is in here") may be undefined
@cobalt junco can help me
?
idk how to fix it
im CERTAIN i defined it
Please read the channel description. text Channel for chatting about development. If you have questions, ask the questions and wait for someone who can answer to help you. Do not ask to ask. Provide all possible information so people know what's up. Just saying "I get an error" doesn't give us enough information on your problem. Do not @mention people randomly.
Try check if it exists or not. You may make a mistake when setting the command inside the Collection
look (black is privacy and isnt related to my problem)
So it seems like whatever you are getting doesn't exist
so I would check if it exists first
Also you don't really have to do if statements here
Whats in your file with unmute cmd?
This isn't the issue currently
unmute or mute doesn't exist in the collection
so execute wont exist as a prop on it
oh wait ur right
What’s the difference in super computer n quantum computer?
quantum computers use a completely different computer architecture based on quantum physics
super computers are basically just very big computers
const url = await fetch("https://nekos.life/api/v2/img/Random_gif").then(res => res.json())
await messageCreate.channel.send({ content : `${url}`})
object Object
you saw nothing
kinda sus
Also dont use nekos.life
fair warning
why?
loli alert
oh ok
ye
ok
but tif you plan on using any nsfw ones dont
anyone
dark color :)
black grey or what?
how to make a switch which make it switch between dark and light mode?
xD confusing
await await
nothing
you don't need .json() with axios 
I dont even think they are using axios att this point
What would be the best way of completely archiving a website? A self-extracting archive or storing it on the fs?
yes
what an odd question
are you talking about archiving dynamic data or literally just a simple html website
A simple HTML would work as long as the snapshot of the website renders similarly to the actual website when the snapshot was captured.
Think about archive.org
oh that's what you mean
Yep.
we do need a better archive org alternative anyways because it's barely running on java
I've been pondering on this question for quite some time and thought about self-extracting websites but they're a pain to render on the client side and the size is a tragedy.
it gets a bit complicated
to preserve the html its pretty straight forward, just scrape it and store it somewhere
for css/js you need to probably go through the html and "crawl" the imports
this also matters for other pages
i have a question
w h a t
@mixin motion() {
@media not (prefers-reduced-motion) {
@content;
}
}
Error: expected "{".
╷
7 │ @media not (prefers-reduced-motion) {
│ ^
╵
style.scss 7:13 root stylesheet
Exactly. However, that's not one of the problems I face while conceptualizing the idea. It's the storage mechanism.
@civic scroll your chance to escape css jail
I'm 50 50 whether to store it as normal files or in a database
and enter sass jail
I think for this storing it as a normal file is the best way
So, store all of them as individual files? That can't be good for cycles.
and keeping an index of things in a database
cycles?
Although caring about cpu cycles is pretty pointless
for disks anyways
Can't help it...
and you shouldn't worry about that
seems like you can't include media in mixins
the operating systems generally do a good job caching disk data and other things
If your files are under 1MB you're probably better of storing in a db like postgres or scylla
I just keep thinking if there is a way to store all that crap as one but archiving it using the traditional mechanisms is meh.
you could but it would get complicated and very slow since you would have to decouple everything
you can but not doesn't work
boolean tags doesn't work
When accessing them? Yes, but I plan on keeping it in a cold storage.
you have to flip your css logic in this case
specialize your css for the reduced motion case, not the "not-reduced-motion" case
Now, that I think about it again, I think I'm better off not archiving them.
in my opinion you should store data in your file system as a folder, that way you don't need to worry about the import paths of scripts and css files because you've preserved the file structure
for the "cold storage" part i wouldn't really do anything since disk is generally very cheap nowadays but I'd opt in for compression i guess for the files, if you really want to get petty zip the pages up and decompress on demand
Uh huh. Yep.
Regarding the html content itself if you're trying to compress you might as well gzip/deflate it and serve it raw as gzipped content
...which is a bad idea
why? reduced motion is something you opt into
i want to make it so i can have the regular non harmful transitions always visible but the actual harmful ones are only displayed if the media query is met
always adding it and intentionally removing is bad because
- extra css
- extra sass for me to write
- the mixin doesn't know which properties to remove so it removes everything
This is how far I've come, I guess I'll go with storing data on the fs.
any reason i might be getting random 'missing access' (50001) errors when trying to call ```js
await channel.messages.fetch({limit:100});
Ghost ping 😡
guild is null
3|IdleMine | await adapter.create_interaction_response(
3|IdleMine | File "/usr/local/lib/python3.8/dist-packages/discord/webhook/async_.py", line 189, in request
3|IdleMine | raise NotFound(response, data)
3|IdleMine | discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
3|IdleMine | Executing <Task pending name='discord.py: on_message' coro=<Client._run_event() running at /usr/local/lib/python3.8/dist-packages/discord/client.py:351> wait_for=<Future pending cb=[shield.<locals>._outer_done_callback() at /usr/lib/python3.8/asyncio/tasks.py:902, <TaskWakeupMethWrapper object at 0x7fac5156a340>()] created at /usr/lib/python3.8/asyncio/base_events.py:422> created at /usr/lib/python3.8/asyncio/tasks.py:382> took 0.440 seconds
3|IdleMine | Traceback (most recent call last):
3|IdleMine | File "/root/main.py", line 4814, in <module>
3|IdleMine | loop.run_forever()
3|IdleMine | File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
3|IdleMine | self._run_once()
3|IdleMine | File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
3|IdleMine | event_list = self._selector.select(timeout)
3|IdleMine | File "/usr/lib/python3.8/selectors.py", line 468, in select
3|IdleMine | fd_event_list = self._selector.poll(timeout, max_ev)
3|IdleMine | KeyboardInterrupt```
anyone know whats going on here
python stack traces are so informative
it has been going off randomly for like a week now
and I got no clue why
I think that's a common issue when using interactions.
I don't know myself, but all I know is that Discord thinks the interaction no longer exists.
print(f"Sent message to {int(server["guildid"])}.")
what wrong with that
it gives me error
File "main.py", line 551
print(f"Sent message to {int(server["guildid"])}.")
^
SyntaxError: invalid syntax
Yeah, " inside "
mfs adding a gui to vim while i still dont know how to exit vim
What in the world is neovim?
think neonazis but vim
A code editor that's usually run in a terminal and relies more on commands from the user's keyboard
If you know Emacs, it's similar.
Neovim is an extension of Vim.
Is it like VSC that I can just download and run?
Sort of.
I've never seen it before, and looks really interesting.
It can be easy to install, but using it requires a strong learning curve.
Since the way you write code is turned upside down.
I'm signing up, where's the papers.
You do almost everything with your keyboard.
Rather than your mouse with a fancy GUI to click buttons
Didn't understand this much, but uhh.
Try it out and see, and you'll see what I mean
It's truly crazy
Personally, I'd like to eventually move to Neovim full time, but I have a hard time remembering the keys, so I stick with Sublime Text.
Which is close in simplicity
Well, learning it is not bad. I guess I'll see how it works.

You mean the thing on the top?
No
If you do have a configured neovim yes
but its heavly based on keyboard shortcuts
But it only works on unix based systems
so MacOS or Linux
Buttt since Windows added wsl
you should be able to use it
If you have a configured neovim what is neovim at that point
been rocking with the defaults except some awful color choices
nono ofc, Im just sayin its not like vsc
not “install and ready to go”
Thats what I like about neovim, vim and emacs
you choose how to configure
Sure you rather need to have some knowledge of vim lang or lua lang
but youll get the hang of it
mice make people slow especially coding and programming
Having certain keybindins to move to files instantly or move up and down
Would you be fine with getting rid of the mouse but retaining the keybindings editors provide, like Command + P to move to a file?
With Sublime Text, I still use my mouse a lot, but have increasingly used my keyboard for some operations and it's been very speedy (especially Shift + Control + M to select and expand selected braces for Lisps)
ah
Why would someone use “Command” or “Super” for software related stuff
I would use ctrl or alt
I think it depends on the environment
Mac users don't like using alt
But windows users do
it means windows button
Neovim and Emacs just throw out the environment for their own with HJKL and whatever
yea
I have been using neorg for the past couple months
Neovim org mode
Not as good as org mode
this is called super key
but Its been better than nothing
Indeed
there are very less built in commands that use super keys so some programs use that in order to prevent clashing with other shortcuts
unless you use linux ofc
wtf is ncmpcpp
SUPER + SHIFT + R to recompile xmonad
music player
Super to open up dmenu
ALT + P to open up my passwords dmenu
What exactly is Neorg? Is it trying to be a complete system?
There seems to be a lot imagining in their readme with no concrete def on what the project is
At least to me, an outsider
NEveR gOnna Give you up
your rick roll memes suck 
Its not better than org mode
but it does very well
Org mode in neovim

nice bro
how bout you
damnn
those are the clean balls
I need to have clean balls too
just havent tooketh to time
What the kentucky fried fuck is this conversion
#balls
do you have them
yes
Nope he doesn’t
i do
Proof 🤨
no ty
Jk
he
also its she*
Oh you don’t have it
i do
What
oh you don't have it
I am a bit confused
You like balls
what
Like football

ok lets stop now
Oh come on you said you love them
Umm
@oak cliff this chat is getting too ballin pls issue some mutes
didn't you say you ate a testicle
what


also keep conversation to

