#development
1 messages ¡ Page 2059 of 1
I use BDScript because it's meant for discord entirely and it's very easy and simple to learn and read it. It's still coding, structured different from the usual type
I think the opposite, it's too abstracted to me, also "meant for discord entirely" applies for pretty much any discord library
no woo, it's not lang wars, we're just politely discussing
bdscript to me feels like combining...
oh crap im participating in lang wars

but bd script is combining the complexity of a real programming language with the limitations of scratch.
That's fine if that's what you want, but its not ideal.
I have nothing against who uses too, but I think it abstract so much that it starts to reverse the complexity level while decreasing the freedom
I agree. I feel like BDScript should be Turing complete (no shortcuts) and that would highly increase freedom possibly
me not really understanding any of xkcd's crap:
the problem i have with BDScript is what does it use under the hood?
JavaScript I think
because most of these things use other discord libraries under the hood anyway
and you have no control over what its actually doing
WDYM no control
you dont know how it processes events, how it caches data, cant configure caching for tweaking ram usage, etc
the functions you write are not your own
this is a bdscript error isnt it?
https://i.imgur.com/MT3ZXTQ.png
it writes them for you, and you cant always trust it
From my experience with BDFD, yes it is
True
BDScript has a $deletecommand function
every bot ive ever used on bdscript gives that error at some point during testing, 99% of users wont know how to solve it.
does bdscript have a method of preventing those errors and having your own error handler?
A typical bot will say "I dont have xyz permission to use that command"
A user typically will know how to solve that, if you cant use your own error handlers on bdscript thats a huge limitation.
Am I wrong in thinking most "devs" who use BDFD 100% use the if (command = blah blah blah) way of coding
wait can you self host a bot using bdscript?
or is it exclusive for their app platform?
No clue, only ever seen it hosted from their platform
ik some botmakers allow u to host the bot in the app, but requires u to periodically open it to keep alive (and see ads)
đ
How can I convert a complex object into normal object?
Input:
PermissionOverwrites {
id: '987662252725395476',
type: 'role',
deny: Permissions { bitfield: 2048n },
allow: Permissions { bitfield: 0n }
}
Expected Output:
{
id: '987662252725395476',
type: 'role',
deny: Permissions { bitfield: 2048n },
allow: Permissions { bitfield: 0n }
}
I'm trying to save permissionOverwrites of the channel to the database (mongoose). When I save the Input to the database I only get the id of the role/user
well yes you can't save Permissions
you can map all keys to a new object
your "expected output" is exactly the same as the top example btw
you just need to generalize Permissions
{ ...deny }
const overwrites = {
id: permissionOverwrites.id
type: permissionOverwrites.type
deny: permissionOverwrites.deny.bitfield
allow: permissionOverwrites.allow.bitfield
}
if mongo supports bigint
he probably wants to keep structure
Thank you
so bitfield would be inside an object
I got it
it would be an object without meaning
because bitfield is rarely ever accessed directly
you usually access it through Permissions methods
which are lost
so either way you will likely want to recreate it after retrieving
mongoobj.deny = new Permissions(mongoobj.deny)
yet another typescript fuckery i just found out
if i do js exports.BLA = require(...) or module.exports = { BLA: require(...) } in a js file, then typescript auto generated types will do this: ```ts
export var BLA = typeof import(...)
which works fine, but any types that are defined inside the file cannot be accessed from another file, it seems to only export the type of the value itself
but
if i simply change my js file to this ```js
const BLA = require(...)
exports.BLA = BLA
or
module.exports = { BLA }
then typescript auto generated types becomes this:js
export { BLA }
import BLA = require(...)
any idea what i can do?
main router
twitch router
home
dashboard
...
youtube router
home
dashboard
...
this is my main purpose
Probably a good idea to open an issue at https://github.com/microsoft/TypeScript about it
Also 666 contributors 
SEE? TYPESCRIPT IS FROM HELL

so this is how i ended up documenting eventemitter events with jsdoc
which makes tsc generate this: ```ts
on: ((event: "event", callback: (data: ShardEvent) => void) => this) & ((event: "debug", callback: (data: string) => void) => this) & ((event: "close", callback: (data?: Error | undefined) => void) => this) & ((event: "ready", callback: (data: ShardReady) => void) => this) & ((event: "resumed", callback: (data: ShardResumed) => void) => this);
ugly af but it works
unfortunately there seems to be no way to use jsdoc to generate this instead ```ts
on(event: "event", callback: (data: ShardEvent) => void): this
on(event: "debug", callback: (data: string) => void): this
on(event: "close", callback: (data?: Error) => void): this
on(event: "ready", callback: (data: ShardReady) => void): this
on(event: "resumed", callback: (data: ShardResumed) => void): this
rip
and i also got the same "cant tell you why" response from oracle đ
but this time my new card isnt banned
rip
idk what could be causing it
maybe the email?
or it is indeed an AI that detects if a person is just gonna use it for free trial
seems like it
not the only one having these problems
Steal someoneâs identity and use them for your server
quick question: how do I check if the interaction user/member have higher role than bot?
Create seperate role "level" variables and then compare bot level to user level
Using BDScript you can use something like $isAdmin or $isMod
very funny waffle
its a shame but oh well what can you do
Heâs not using BDScript thankfully
BDScript isn't really that bad, it's just meant for less experienced users.
I believe thereâs a property called manageable on the Member object, try using that to compare
i'll probably try out contabo very soon, tho not happy about the "one time setup fee" probably just a tactic to get you to commit to a long term plan and not constantly stop paying then start paying again
Agree to disagree
Fair enough however I still believe d.js is harder than BDScript
BDFD is absolutely terrible for doing any sort of customizable behavior
djs is probably one of the easiest libraries out there; it holds your hand every step of the way
BDScript is easy, looking into d.js it looks easy but a pain in the ass to set up.
and you have to understand JavaScript fairly
I learned BDScript in 30 seconds however d.js is a different story
what looks better?
Second one looks way cleaner
yeah
its a pain that it needs to have all those extra parenthesis lel
now time to refactor this
its harder yes, no question about that
but like
djs is like driving a car
bdscript is like having an ai drive for you
^^^
and in my opinion, driving myself is way more awesomer
And safe
not really
I have no motivation to learn coding, I'm forcing myself to learn it in college
I only learn it if ez
What's that forwarded to? "And safe"?
well if thats how you feel about coding, then yeah its probably not for you
How so? Driving yourself is way safer than an AI driving for you 
yea I'm going to a subject where I have to learn it I just don't have motivation to learn one on my own
AI isn't perfect, it can always have more flaws than a human being, so it's tend to have more issues in those ways honestly
Nah I'd rather AI drive the car than a random human being I don't know
this
Humans aren't perfect either, but definitely way better than AIs in thinking in sensibility, although who knows; since AIs are growing better and smarter maybe they'll one day surpass even in such tasks
the biggest flaw in any system is a human, i strongly believe that if all cars were driven by an AI, accidents would drastically go down
you're an ai and you're about to collide with two people but you can swerve and only hit one person, who you pickin and why
thing is humans can react instanty to any given situation, an ai's reactions are much more limited and highly depends on its performance, programming and training data
Exactly
Exactly! Especially is all ai were connected and shared future movements, crashes would be extremely rare
^^
it cant react to a situation it never seen before and has no training for
It does though
It can't
AI is trained for crashes
It detects obstacles and figures out a good path
It's not blind
It's not about crashes nor anything as such, the matter are things it has never seen before, nor has been trained for
it can also detect ghosts in a cemetery and birds as people
and all kinds of weird quirks
It has seen crashes. It will draw a safe path or stop.
We're not talking about crashes
but anyway going back to bdscript
bdscript is not even an ai
so that comparison is not even fair
Well what wouldn't it see?
AIs aren't trained for literally everything, so it's likely for it to encounter something, or a situation/scenario it has never seen before, nor has it been trained for; which can just leave the AI wondering and probably just be extremely confused
What though???
It's not specific, for example; let's consider an AI playing some simple game which tasks the player with shooting enemies, but now it reaches to a point where the whole scenario changes where you have to collect items, and not shoot anybody, it won't be able to do it because it was never trained for it
I'm not just talking about the AI driving cars, any type of AI
And you train an AI to be able to drive, it doesn't get the ability and the thinking sense to do so without any training
Yea it's supposed to be trained
avalanche, snow, fog, hurricane, tornado, deer, donkey, horse duck, dogs, cats, fish raining from the sky, tree falling, sinkhole, fissure, spikes/nails on the floor, ice/slippery road, fire, lava, ???, profit
Then you train it for that.
x doubt
Lmao
Main Router (http://localhost:5000/)
Home (
http://localhost:5000/home)
Profile (http://localhost:5000/profile)
Twitch Router (http://localhost:5000/twitch/)Events (
http://localhost:5000/twitch/events)
Dashboard (http://localhost:5000/twitch/dashboard)
... (http://localhost:5000/twitch/...)
YouTube Router (http://localhost:5000/youtube/)
Events (http://localhost:5000/youtube/events)
Dashboard (http://localhost:5000/youtube/dashboard)
... (http://localhost:5000/youtube/...)
How can I make 2 routers nested in this way? (React)
I never underatood your project.What are you trying to do?
actually what i'm trying to do is chatbot that will work on twitch and youtube
I am making a web dashboard for these and logically I should put the twitch settings and youtube settings on different pages.
ex:
To go twitch settings...
(http://localhost:5000/twitch/settings)
To go youtube settings...
(http://localhost:5000/youtube/settings)
do you have any idea how i can do it?
Comment on videos from discord?
what
so post discord screen view as a live stream
What lmao
user: !discord
bot: blablbal
what
đ
WDYM for live streams lmaoo
you don't understand what i'm trying to do
Do you know moobot?
no
oh ok
I believe there is twitch API libraries out there
user: !discord
bot: discordurl
Unless thatâs not your issue
no i already made them
this is what i'm trying to do
Yea how does that relate to a reply
You asked what I was trying to do and I answered
Iâm not very good with react router, I mostly use nextjs whenever I get the chance
How does that code make a reply
Looking back at the original question, @rigid maple never asked anything about how to do a chatbot. @hollow anchor you were the one that turned it into that, he was just originally asking about how to set up react router to work with his routes
yea?
yes
what's you guys opinion on Rust and V
rust is mid dont know about V
you mean this? https://vlang.io/
Rust is great idk what V is
Mhm
This feels a little biased lmao
Who in their right mind is building compilers from the source?
lmao idk
You only build a compilier once on release
my current code App.jsx;
it demonstrates the simplicity and straight forwardness of the lang i guess?
its sintax is basically golang
but in a low level C-like environment
So what's you guy's opinion? I've heard some good stuff about it other then that.
havent heard of it before, but from their website looks like a cool project
Would you use?
it literally just looks like go on crack
so would you
no
why not what's wrong with it
Lol v lang impressed me
I don't see how it is worth learning it over something like rust
Seems like a python with C performance
would you use it
If you wanna use it go for it
Maybe
it isn't an inherently bad looking language, but I don't have a need for a language like that so personally I wouldn't learn it and use it
What's the worst lang? (Not assembly, binary etc)
Bdscript
BASIC
Brainfuck
I have a feeling waffle would love V
No not really

Just looks like a more obscure rust to me
oMG hOw dAarEe yoU it IsmDB BeSTTT laNGUAAGGEEE i OXIY YOU MADDE33 memeee cryy ALAAAAA PyTHON SnaKE YUMMyyy
Looks like if rust and go had a baby
All I say to people who say that is, I can fuck ur entire python program up with an indent
Python with bracesđĽ˛
It's Turing complete and uh it's painful. Really painful. Hello world in brainfuck:
+++++ +++++ initialize counter (cell #0) to 10 [ use loop to set the next four cells to 70/100/30/10 > +++++ ++ add 7 to cell #1 > +++++ +++++ add 10 to cell #2 > +++ add 3 to cell #3 > + add 1 to cell #4 <<<< - decrement counter (cell #0) ] > ++ . print 'H' > + . print 'e' +++++ ++ . print 'l' . print 'l' +++ . print 'o' > ++ . print ' ' << +++++ +++++ +++++ . print 'W' > . print 'o' +++ . print 'r' ----- - . print 'l' ----- --- . print 'd' > + . print '!' > . print '\n
Itâs an esolang
Of course itâs going to be shitty
Hence why I donât believe itâs fair to ask what the worst lang is
came accross this on a redit post about Vlang
The author has a history of making extravagant claims about what the language can do but either refusing to provide evidence or making empty promises to provide it later.
How about I rephrase.
What's the worst language to write "hello world" in
INTERCAL
false I think
You seem like a vlang enthusiast
intercal hello world wow
Not really
That has nothing on JSFuck
console.log("Hello, World") translates to over 7000 characters
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Holy shit
Doesn't even work there is an error in the jsfuck
curiously enough, jsfuck is extremely easy to program with, but since it auto-obscures itself it's a one-way lang
Minecrart in JSFuck 
no can't even convince me it is easy
it is dummy easy lul
nope
like, it's literally js but you deal with ascii and booleans instead of text
![] is true, !![] is false
![]+[] is "true", !![]+[] is "false"
basically is encapsulates the value in a string
i have a html file that uses external js
i get it via return res.status(201).send(fs.readFileSync(__dirname + "/tech.html"));
and type it let html = document.getElementsByTagName("html").item(0).innerHTML = await response.text()
with this method but it doesnt get external javascirpt file how can i fix it ?
with that, u have letters t, r, u, e, f, a, l, s to play with
hello world in jsfuck
by using +[] u get 0
I dont remember how u increment it tho
but after that, u can build a sentence using those letters + index access
u keep going until u manage to write eval()
when u get eval u can just run those sentences
obviously at that point u have more than 5k lines of code
it's really fun to write in jsfuck, the only issue is that comment is a must
else u cannot stop coding else u'll forget later
afaik the only way to execute scripts like that is to use this method
var wrap = document.createElement('div');
var scr = document.createElement('script');
scr.src = scriptUrl;
scr.type = 'text/javascript';
wrap.appendChild(scr);
document.body.appendChild(wrap);
I feel like i am fucking up so bad rn with this rust lib
I have never used lifetimes so my understanding is extremely vague
dolbayob
Show how youâre using them
I'm scared cause you will laugh at me 
Show
#[derive(Deserialize)]
struct APIImageResult<'a> {
link: &'a str,
}
struct Animality<'a> {
key: &'a str
}
impl<'a> Animality<'a> {
pub fn new(key: &'a str) -> Self {
Self {
key
}
}
#[tokio::main]
pub async fn fetchRandomImage(animal: &'a str) -> APIResult<'a> {
let resp = reqwest::get(base + "/image" + animal)
.await?
.json::<APIImageResult<'a>>()
.await?;
APIResult {
link: resp.link,
name: animal,
}
}
}
So like I read up on lifetimes but they still confuse me
I just know that the lifetime can't outlive what it is being used for
You should probably not be used a string slice in that struct
Probably best to use a String
I see
All lifetimes are is labels that tell the compiler to not drop certain variables when they go out of scope so long as the lifetime is valid
Also I am curious new returns a Animality right but how coem I can't then use fetchRandomImage after making a new one
this is invalid cause it doesn't seem like fetchRandomImage is a thing
Because thatâs not how you call a function
Oh?
You do animality.fetchRandomImage()
I see
The :: syntax is only for âstaticâ functions
Ah
And the reason using a . Wonât work for you right here is because in your fetchRandomImage function you donât make a &self parameter
In the function
yea I just did that
Also in the function, you donât need the animal parameter to have that lifetime
Since all you need it for is building the request url, it does not need to live for as long as the entire struct
You wouldnât be able to compile without it so yeah
it needs to live for as long as the animality struct is being used
Basically if you are storing a reference in a struct at all, itâll need a lifetime
gotcha
you are best â¤ď¸
I am trying to figure out now how to add headers to my reqwest
reqwest uwu
figured it out
Wait so should i be able to use the self param I made in the function to get the key?
Hi all, hope you are all feeling well đ I have a little question. Does someone understand why this line does not work (it is in my Client.on("ready") so I only have Client arg :
Client.guild.fetch(servID).members.unban(id)
Thank you in advance đ
I do not have any error message neither bot crash...
well, there's several reasons why this does not work
Client.guildis not a thing. It'sClient.guildsClient.guilds.fetch(id)returns a promise, so you would need to do(await Client.guilds.fetch(id)).members.unban(id)- This isn't a reason why it doesn't work, but you should rename
Clienttoclient, discord.js has a class namedClientthat you may accidentally call functions from somehow instead of calling functions from the instance of it that you created
the await does not work in this case, however I put async before my client args
and the user seems to stay banned
I'm not quite sure what to tell you if you don't show any code or say how it doesn't work
ÂŻ_(ă)_/ÂŻ
Yes sure I will share it đ
const Discord = require('discord.js');
const infactive = require('../infactive.json')
const fs = require('fs')
var cron = require('node-cron')
module.exports = async(client) =>
{
console.log("The bot is now operationnal.");
client.user.setStatus("online");
let number = Math.floor(Math.random() * 2);;
if(number == 0)
client.user.setActivity(client.guilds.cache.size + ' servers | !invite', { type: 'WATCHING' });
else
client.user.setActivity(client.users.cache.size + ' users | !invite', { type: 'WATCHING' });
var task = cron.schedule('* * * * *', () => {
const exp = Date.now()
for(let servID in infactive)
{
for(let infID in infactive[servID])
{
if(infactive[servID][infID][2] == "Tempban" && infactive[servID][infID][1] < exp)
{
console.log("Tempban")
await client.guilds.fetch(servID).members.unban(infactive[servID][infID][0])
delete infactive[servID][infID]
fs.writeFile("./infactive.json", JSON.stringify(infactive, null, 4), (err) => {});
}
else if(infactive[servID][infID][2] == "Tempmute")
{
console.log("Tempmute")
delete infactive[servID][infID]
fs.writeFile("./infactive.json", JSON.stringify(infactive, null, 4), (err) => {});
}
}
}
});
task.start()
}
oh boy
the error with the await : ```await client.guilds.fetch(servID).members.unban(infactive[servID][infID][0])
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
well, I did say to do (await client.guilds.fetch(id)).members.unban(id), not await client.guilds.fetch(id).members.unban(id)
i'm sure I'm making a stupid mistake
I tried it too
I retry
And the reason your async isn't working is because your cronjob isn't marked as async
Also please please please please do not use JSON like this
Use a proper database
It's not definitive don't worry
One message removed from a suspended account.
One message removed from a suspended account.
The user stay banned đ˘
I don't know why đ˘
I still don't really know how to help you with that information
I do not have any error message so it's complicated đ
the likelihood is that it is not being executed
try debugging, see if you ever reach that statement
I'll try, ty
how can i find with an element in an object using mongo?
actual object:
lottery: {
autoLottery: Boolean,
totalBoughtTickets: Number,
totalEarnings: Number
}
attempt that didnt work:
const userProfiles = await usersDB.find({ lottery: { autoLottery: true } });
You need to use { where: { key: value } }
isnt that what i did in my failed attempt above
I don't see where anywhere
The where operation is actually the default

Is the lottery object nested inside something else?
Does the user schema have lottery on it?
no and yes
Is it return undefined?
Is it possible no data meets those conditions?
Does it return anything if you search with false?
Mind to show your full user schema?
here is my schema:
const users = mongoose.Schema({
userID: String,
xp: Number,
inventory: Array,
work: String,
pet: String,
balance: Object,
cooldowns: Object,
streaks: Object,
statistics: Object,
premium: Object,
marriage: Object,
lottery: Object,
banned: Object
});
Is it possible you can't search an object's properties for the schema since it's an unknown structure?
honestly im not sure, im recoding my bot and im trying to clean up the db cuz i literally had everything in the schema without any objects so ive never tried something like this thats why im asking here im not even sure if its possible or not
but i tried the only thing that makes sense to me
I don't think MongoDB/Mongoose cares about the defined object structure when doing a find operation
Try to see if the lottery property even exists in such documents
yeah it is https://shot.rip/8mn
Try { $exists: { lottery: true } } instead of the web UI
uhh i dont think im using it ruight
so am i supposed to use it like this?
await usersDB.find({ $exists: { lottery: true } });
That's correct
i get this back:
MongoError: unknown top level operator: $exists. If you have a field name that starts with a '$' symbol, consider using $getField or $setField.
What the hell
Ah I remembered that the usage is swapped
Try { lottery: { $exists: true } }
You can
yeah that worked, it brouight back all the documents
Then your first find operation should've worked, can you expand the lottery property in the web UI and show us the object?
i tried false originally
but tried true and also didnt work
then i sent it here
That's pretty strange, what version of Mongoose are you using?
{'lottery.autoLottery':true}
try this as query
Oh yeah that's the correct format
well that works
thank you
im so confused tho { lottery: { autoLottery: true } } should work
Its a exact match with your query
Nested field checks require binding, which that format achieves
yeah i know but i meant like it should work in that format too
oh alright
thank you guys for your help
No problem
also is there a way to see if an array doesnt have an element
im trying to bascdiallty check if they have autolottery is on and they dont have a lottery ticket in their inventory
@quartz kindle just a random thought i think you can understand
the bot luca just checks if a message is a single full stop and deletes it if it is
think of the wasted clock cycles and electricity from checking every single message
Absolutely, you can use the positional placeholder as .$. and check for the properties
'array.$.foo': { bar: true }
i dont understand what to place "bar" with
or do i not?
i tried this but it didnt return any data even tho it matches:
const userProfiles = await usersDB.find({ 'lottery.autoLottery': true, 'inventory.$.lotteryTicket': { bar: true } });
Oh that's just a placeholder, you can replace { bar: true } with the value of the lotteryTicket property you want to check for
I saw, it's awesome
but 'lotteryTicket' is just a string inside the array not a property
Uh, does the array contain objects that has a lotteryTicket property or are you just checking if the array includes a string?
yeah im trying to check if the array 'inventory' includes a string 'lotteryTicket'
so inventory looks like:
inventory = ['lotteryTicket', 'laptop']
etc
Oh I see, then you can just do { 'inventory.$': 'lotteryTicket' }
wouldnt that return it if they have the lotteryTicket
im trying to make it so it returns ppl who dont have lotteryTicket
Then you can do
{
inventory: {
$nin: ['lotteryTicket']
}
}
$in to check if it contains the value, $nin to check if it doesn't contain the value
ty so much your an actual life saver
does anyone know React ?
Just ask your question, or present the problem; someone that knows about it will probably answer

Main Router (http://localhost:5000/)
Home (
http://localhost:5000/home)
Profile (http://localhost:5000/profile)
Twitch Router (http://localhost:5000/twitch/)Events (
http://localhost:5000/twitch/events)
Dashboard (http://localhost:5000/twitch/dashboard)
... (http://localhost:5000/twitch/...)
YouTube Router (http://localhost:5000/youtube/)
Events (http://localhost:5000/youtube/events)
Dashboard (http://localhost:5000/youtube/dashboard)
... (http://localhost:5000/youtube/...)
How can I make 2 routers nested in this way? (React)
https://www.robinwieruch.de/react-router-nested-routes/ this can probably answer that
thank you very much this is what i have been looking for for days
bro did what took him days đ
doesnt every single bot do that? lmao
at least those that still dont use slash commands
but for minute purposes đ
baguette
buttery
lets say i have a array like
[1:Name, 2:Name, 3:Name]
How would i be able to access only the Name value of each, such that i can put them into a new array like:
[Name, Name, Name]
do you mean this? [{ 1: Name }, { 2: Name }, { 3: Name }]
or this? ["1:Name", "2:Name", "3:Name"]
this
oh ty that works
also how would i modify this so it prints like
JohnV50,
Lxphere```
I tried \n but it looks horrible
for reference this is how the array is being mapped
oh right
ty
the .join doesnt work
wait one sec
yeah still nothin
also if i try joining it throws a array.sort is not a function
Show how you're doing
const shuffled = array.sort(() => 0.5 - Math.random());```
alr
more typescript shenanigans, both session and sequence exist or neither does ```ts
type stuff = ({
session: string,
sequence: number,
} | {}) & {
token: string,
intents: number,
id?: number,
total?: number,
...
}
wtf are you doing tim
more cool stuff ```ts
type stuff = ({
total: number,
ids?: number[]
} | {
ids: number[]
}) & {
token: string,
intents: number,
...
}
if total exists, ids is optional, if total doesnt exist, ids is required
đ
works now ty
You are fucking with types more than I have
in my entire career of using ts
lmao
rewrite tiny discord in actual ts ;)
no :^)
whey not?
basically i agree with everything this guy said https://gils-blog.tayar.org/posts/jsdoc-typings-all-the-benefits-none-of-the-drawbacks/
still prefer to use a dynamically typed lang
just found a weird js quirk
you can actually spread null because its an object lel
only works in objects, not in arrays
how can i make it so a user (d.discordUser) can only be picked once. i am making a thing where you can have two entries for a better chance at being picked, but it most of the times it sends duplicates
You'd likely have to store the already picked people in something like a Set and if the set already includes the picked user pick again
if your data is a primitive like strings, you can use a Set
that is my idea anyway
otherwise you need an object of ids
đ
it is all strings
ever used a Set before?
its similar to a Map but also similar to an array
it doesnt allow duplicates to exist
const a = new Set();
a.add("wiefpwiejpgiwejpg");
a.add("43409jt0394j039");
a.forEach(...);
It also isn't a k,v it is only a v
if i switched my array mapping
to a set
would the sorting work
in other words are you still able to sort a set
Sets cannot be sorted, so you have to convert it to an array first
you can do so using [...a] or Array.from(a)
you can spread a set?
i did this
mainData.add(data.map(d => "<@" + d.DiscordID + ">" + ":" + d.RobloxUser))```
that would add the array itself into the Set
o
not the individual array items
you can use the spread operator
mainData.add(...data.map(d => ))
then the same to convert it back to array [...mainData]
ahh
so this wont result in duplicates?
i remember using that trick a while ago for something
so you can even do a one liner: [...new Set(data.map(d => ""))].sort()
the Set automatically eliminates duplicates
hmm well
i think that kinda defeats the purpose of two entries
maybe i can create a set after its shuffled?
one sec
yeah that works, i just made a set after its been shuffled, thus a user has a higher chance if they have 2 entries
đ
Tim do u know anything abt monte carlo or card game ai?
nop
im trying to loop through the rblxusers and update a DB value of it
for (rbxusers in Array.from(rblxuser)) {
console.log(rbxusers)
let user = await users.findOne({ RobloxUser: rbxusers})
console.log(user)
await user.updateOne({ Event1Picked: true})
}```
not sure how for .. in loops work
what's the client.api endpoint refer to?
Just so you know the Array.from is redundant, rblxuser is already an array
oh right
also where is this error coming from? ERROR Unhandled rejection: TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream. ```js
if (dynamicFormat) {
await fetch(baseUrl).then((res) => {
format = res.headers.get("content-type") === "image/gif" ? ".gif" : .${defaultFormat};
return null;
});
}
What youâre probably looking for is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of btw
The for...of statement creates a loop iterating over
iterable objects,
including: built-in String, Array,
array-like objects (e.g., arguments
or NodeList), TypedArray, Map,
Set, and user-defined iterables. It invokes a custom iteration hook with
statements to be executed for the value of each distinct property of the object.
Whatâs the stacktrace? You sure itâs coming from that line?
kk will look into it ty
it doesn't say which line is from, which is weird enough by itself
const attachment = new MessageAttachment(baseUrl + format + query, `${member.user.username}-banner.${format}`);
``` may also be from this line
Youâre probably trying to construct some form of media that doesnât allow null
I do check for null though
Yeah thatâs where itâs probably coming from most likely
Give me a minute to look at the docs rq
I'm converting the users banner to a URL then trying to put it as a message attachment
it works if the user has a URL and it does check for null so the error somehow happens anyway
So the docs donât have a MessageAttachment class, I assume youâre working with a slightly older branch or something of djs?
const { baseUrl, format, query } = await getUserBannerUrl(member.user.id, { size: 1024 });
``` I'm using a function, and in that function there is an if check that returns a message if the user doesn't have a banner
Nevermind I found the docs for it
it does
it's the same as MessageEmbed
I was looking at main branch and not 13.8
ah
well do you know why is it giving the error?
djs v14 is changing a bunch of shit like normal
What exactly is baseUrl and query
there can be multiple documents for this search, how can i make it so that each doc updates
The error says youâre not passing it something it can work with
base URL is the url itself, query is the ?= part, so you can set a custom size for example
so e.g: there's two docs with RobloxUser as Bob, and rn it only updates 1 out of 2 documents
but I have a return statement that checks if the user has a banner, so the function shouldn't execute fully
the error happens because it fails but that's why I included the check that breaks the script
Try logging what baseUrl + format + query is before you construct the message attachment
they're either undefined or null
Huh
if the user doesn't have a banner of course
(mongoose v5 btw)
^ donât just assume the values of things, thatâs the point of logging
if (!user.banner) return message.channel.send("This user has no banner");
``` I have this statement to return the function in case it happens, it succesfully sends but still gives me an error
I'm not assuming, I'm setting them myself
Again, log them.
The error is happening because something is wrong with what youâre giving it
i did try users.find and that would return two docs, im unsure on how to update both docs at the same time, i only know abt updateOne lol
yeah but it shouldn't since I'm returning the statement mid function, it doesn't make sense why rest of the code would execute
log. it.
Just because it shouldnât doesnât mean it doesnât
Lol
After all if we were able to successfully process code in our heads, nobody would ever need help c:
You need my help but not for programming
hows ur physic engine coming along
I somehow managed to break the code
Havenât worked on it in a bit
đ¤Ł
Icic
Been taking a break
bump
Yea I wrote my first lib in rust
I saw
It is indeed a start
Iâve yet to do async rust yet, youâre already ahead of me on that
So
Lifetimes are a weird syntax, but youâll understand them eventually
Itâs to ensure that there are no dangling pointers in your code
I'll show you an example of why you need them rq hold on
kk
// Say you have a struct that stores a reference to a string
struct MyStruct {
some_field: &str,
}
fn main() {
// Then you have something like so:
let var: MyStruct;
{
// Make a &str variable
let my_string_ref = "Hello, world!";
// Assign said reference to the struct
var = MyStruct { some_field: my_string_ref };
} // my_string_ref dropped here (Bad!)
// Uh oh!
println!("{}", var.my_string_ref);
// my_string_ref was dropped, and its data no longer exists
// However, the struct also had the same reference
// Therefore the reference in the struct is no longer valid, and it would be very bad
// To access said field, since it points to memory we no longer own
}
So the compiler makes you do this: ```rs
struct MyStruct<'a> {
some_field: &'a str // anything assigned to some_field will live for as long as the MyStruct instance lives for
}
It's ensuring that you cannot fuck up and access undefined memory, which usually causes segfaults
average javascript fan vs average typescript enjoyer
if (dynamicFormat)
checkFormat = await fetch(baseUrl);
const format = checkFormat.res.headers.get("content-type") === "image/gif" ? ".gif" : `.${defaultFormat}`;
``` is that not a proper way to fetch? đ¤Ł
says headers is undefined
depends on what fetch is
fetch is node fetch you dingus misty
How the fuck am I supposed to know that waffle
it could of been some fucked up shit knowing this guys code
not nice
checkFormat is a Response object
that fixed the error
should I make this into a npm package?
no
it is super easy to form a banner
some people might not wanna bother to create a function to form a banner
đ
Ah yes npm, the land of 10 billion sub dependencies
Why are you even fetching
to check for the format
but why
so gif banners are gif and jpg banners are jpg
but the hashes can tell you that
can't you just use webp for both
all gif hashes start with a_
pretty sure you can represent both as webp
well I didn't know that
fetching here is a bit redundant
this is why you READ THE DOCS
it is now, but it wasn't before since I didn't know that
ÂŻ_(ă)_/ÂŻ
it was always redundant whether you knew it or not
still
then how else would you find out the format?
without that
by not caring about the format and just using webp đ
without this either
it doesn't matter if it doesn't have it cause it does
wat
you are like talking to a brick wall
but... why
except brick walls are smarter
it's easier to just use it
I'm not entirely sure if it works, but if it does then you don't have to waste another request
it should work
I know, I'm not trying to say it doesn't
webp is the typical format discord uses in the app for all types of things iirc
gifs, png and jpeg
you just say it's redudant, I know that but it wasn't before since I didn't know about the hashing nor remembered that webps go both ways
just cause you don't know something doesn't make it not redundant
but whatever use what you need
đ¤ đż
đŞ
Funny enough, discord doesn't use gif unless you send a gif
Discord uses apng instead
mm
Also yes, webp > png/jpeg
If only I could find out why the lib I'm using doesn't work with fractional compression
I wonder what the limit of compression is before you start losing quality entirely
Well, anything above 0% compression on lossy formats
For jpeg it's around 15 copies before you start to notice the degradation (at 20% compression)
I see
Tho I hate the fact that I got used to noticing jpeg artifacts on images, too much time handling images does this
It's a grid-like degradation, somewhat a pixelation or smth
I notice a lot of apps like instagram and shit, if you post too high quality of an image they will compress it and then it looks like shit
For sure
I wonder if there would be a way to fix that though
ofc you wanna compress it so it doesn't take as much space but there has to be a way to counteract such a loss of quality
Well, for most people 20% jpeg compression is not really noticeable
Heck you could throw 70% and I bet nobody would notice
Did u try to zoom into google images? They're nasty af
But for some, it stands out like a sore thumb
U could use a lossless format, or go hardcore and jump straight to bitmap
I just feel bad for people who post their high quality art on instagram or pintrest and shit
I've seen a before and after of their art and it looks horrid on the platform
bitmap?
I assume bitmap does the opposite of what you'd want when talking about compression?
Well, bitmap cannot be compressed at all afaik
If u want to preserve original quality, bitmap is the go
Or .raw, but that's for digital cameras
with the standard 24bit per pixel formats, a 1000x1000 image would take 3mb
make a discord clone or smth
uncompressed
That is a lot less than what I thought it'd take
with transparency, its 4mb
32 bit per pixel
full quality png's use that format i believe
but there are a billion different pixel formats out there
Here's an example regarding jpeg degradation I keep around just because
You probably can't see a difference, but put that in an editing software and zoom into the right image
It's nasty, and it becomes evident if u attempt to do image processing on it
Been there, suffered with jpeg for that reason
the right image does look a bit weird to me ngl
jpg's compression format is pretty crazy
it uses a bunch of prediction techniques to try to guess the neighbouring pixels
Jpeg compresses itself every time it's replicated
and only actually stores key pixels every now and then
It's funny because u can tell if something has a long repost history from how deepfried it is
Would someone be able to help me with nginx config, I just want to redirect my node application on lets say port "5000" to port 80 with a pem and a key to go to cloudflare with the full encryption setting
Also is anyone elses discord being abit slow today?
for full encryption you need your own ssl, you can use certbot or something
then setup nginx as a reverse proxy
Yeah withcloudflare I have my ssl cert
(or 443 with ssl)
Oh yeah, I was just talking from my node app prespective
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html; (im not sure about here)
# index index.html index.htm;
# }
#}```
location / {
proxy_pass localhost:5000;
}
Those configs feel weird, mine has like 2 ssl configs
U also need to have a 80 -> 443 redirection so the user doesn't get security warnings
yeah
this is what i use for port 80
server {
server_name _;
listen 80 default_server reuseport;
listen [::]:80 default_server reuseport;
return 444;
}
server {
server_name DOMAINNAME.com
listen 80;
listen [::]:80;
location ^~ /.well-known/acme-challenge/ {
root /root/nginx;
}
location / {
return 308 https://$host$request_uri;
}
}
This is mine
this is weird
so something like this? ```js
server {
server_name _;
listen 80 default_server reuseport;
listen [::]:80 default_server reuseport;
return 444;
}
server {
server_name aaaaa.gq
listen 80;
listen [::]:80;
location / {
return proxy_pass:localhost:5000
}
}```
is this socket.io?
Ive never used nginx or socket.io before so idk if this is a config for it
I'm trying to figure out how to get the cloudflare certificates onto blank.gq.crt etc, but its in 2 seperate files
I found this on the documentation, pretty hard to understand
CF cert is the third line below ssl on on my image
The two above are the public and private keys
somethin like this? ```
server {
listen 80;
listen [::]:80;
server_name insignia.gq;
return 302 https://$server_name$request_uri;
}
server {
server_name insignia.gq
listen 443 ssl;
listen [::]:443 ssl;
#ssl on
ssl_certficate: /src/insignia.gq.pem;
ssl_certificate_key: /src/insignia.gq.key;
ssl_client_certificate /src/insignia.gq.pem;
ssl_verify_client on;
location / {
return proxy_pass:localhost:5000
}
}```
just remove the hashtag to turn ssl on?
ssl on is not a configuration, its really just a comment
you also dont need client certificate
just certificate and certificate key
Okay
also no return on proxy_pass
Ill change that and ill try to start the server on port 5000
and proxy_pass should have a space after it
not a :
same with certificates
all nginx options use spaces to separate key and value
server {
listen 80;
listen [::]:80 default_server reuseport;
server_name insignia.gq;
return 302 https://$server_name$request_uri;
}
server {
server_name insignia.gq
listen 443 ssl;
listen [::]:443 ssl;
#ssl on
ssl_certficate /src/insignia.gq.pem;
ssl_certificate_key /src/insignia.gq.key;
ssl_verify_client on;
location / {
proxy_pass localhost:5000
}
}```
I was used to making objects and minecraft configs ;-;
shouldnt need client verify either
and afaik nginx doesnt support relative paths, so you have to specify the cert paths from the root dir
Im on windows though
you're using nginx on windows?
so I gotta go from the C drive or something
Yes at the moment while im developing it
Im moving it over to a ubuntu server when I host the website 24/7
okay
also, did you port forward your routers and firewalls?
alright
It may be an issue on the ubuntu machine though
haven't tried to host a website on it yet
usually they have ports open for webservers by default
the problem with home windows is usually the router, which isnt an issue in a vps
so this should work? should I put quotes because the space in the path
ssl_certficate D:\Coding\slash commands\certinsignia.gq.pem;
ssl_certificate_key D:\Coding\slash commands\certinsignia.gq.key;
location / {```
D:\Coding/slash commands/certinsignia.gq.key```
and yes quotes would work
Ill just do "\\"
windows is a weirdo for using \ for paths
indeed
it's the entire reason there are libs to convert between both path standards
it's annoying af
they themselves regretted it so much they decided to go back on it
unfortunately it was too late, and they had to support both
meh
For some reason the webserver isn't completing requests
http://localhost:5000/ works
it may be the firewall
tried localhost:80 ?
says refused to connect
probably because you only accept requests using your domain name
maybe try removing the server name for testing
just comment it out?
does nginx reload config automatically or do I gotta end the process n start again
nope it isn't working
hmm try enabling logs
and see whats going on
idk much about nginx on windows tho
on your main nginx.conf file you should have logging options
these? error_log logs/error.log; pid logs/nginx.pid;
I see this in error.log
2022/06/23 00:04:21 [emerg] 6188#5076: "server" directive is not allowed here in D:\Coding\slash commands\nginx/conf/nginx.conf:4```
that means your config is invalid
should have given an error when starting/restarting nginx tho
this is my full config just to make sure. wait maybe its because theres no semicolon on the proxy_pass localhost:5000
like that? ```
error_log logs/error.log;
pid logs/nginx.pid;
server {
listen 80;
listen [::]:80;
server_name server_name _;
return 302 https://$server_name$request_uri;
}
server {
server_name server_name _;
listen 443 ssl http2;
listen [::]:443 ssl http2;
#ssl on
ssl_certficate "D:\\Coding/slash commands/certinsignia.gq.pem";
ssl_certificate_key "D:\\Coding/slash commands/certinsignia.gq.key";
location / {
proxy_pass localhost:5000;
}
}```
and do I need to forward port 443 and 80?
thats nginx.conf?
yep
thats explains it then
the root nginx.conf is usually not recommended to be edited directly, nginx has a system of sites_enabled and sites_available, where you put your site's own conf files to avoid messing with the main file
but if you wanna use the main file, it needs to start with an http block
http {
server {
...
}
}
google some nginx config generators, there are many
and error_log will still be before http {
okay
Okay and thats the only error I have
unknown directive "ssl_certficate" in D:\Coding\slash commands\nginx/conf/nginx.conf:19```
so I guess i shouldn't use the quotations?
wait I figured it out im pretty sure
its this line having issues
ssl_certficate "D:\\Coding/slash commands/cert/insignia.gq.pem";```
Im gonna look at this more tomorrow and look around online
@quartz kindle you helped me with the enmap before, do you have any idea how to edit an existing enmap?
I'm not aware of all the functions it has, but basically I tried to get the already existing warn and edit the reason```js
const storage = warnstorage.get("5QRk3");
warnstorage.set("5QRk3", JSON.stringify(storage).replace(storage[3], "test reason"));
it kinda works but it breaks the way it's saved
relax, I just thought tim might know
I mean you can delete and then reset with different values
I have to save the values I'm not changing tho
you are already storing them in a variable are you not?
as long as the scope doesn't end you still have access to those values
nope, warnstorage.get returns an enmap
yeah I want to edit the value I want to change from that enmap
but I can't replace the string unless I stringify it first
đ¤
but if I stringify it the way it's saved gets wonky and it breaks my entire warn system
not while it's saving, they occur when I try accessing it, cause instead of an enmap, the map gets converted into a string and it looks something like this
"[value1, 2, 3]"
You seem to be able to update a specific location in the enmap with set
as long as you know the index of the thing you wanna update you just use enmap.set('WhateverYouCalledItOriginally', 'newValue', indexOfWhatYouWannaUpdate)
https://enmap.evie.dev/api/#enmapsetkey-val-path--enmap as gotten from the docs example
The complete and unadultered API documentation for every single method and property accessible in Enmap.
yes cause you don't read docs
I did read them a couple times just didn't pay too much attention
it has, it's so much simpler than what I was doing
works perfectly
// Lets check if the Id exists before trying to replace it. And also save the variable for later.
const checkValidity = warnstorage.get(warnID);
if (!checkValidity) return message.channel.send("This ID does not exist in our database.");
// And lastly, update our warn. "2" is the position of our reason, so that's the value we need to replace. And set does that for us.
warnstorage.set(warnID, reason, 2);
// And lastly confirm it with a nice, informative embed.
const warningsEmbed = new MessageEmbed();
warningsEmbed.setTitle(`Z3RO Warn System (ID: ${warnID})`);
warningsEmbed.addField("Updated Reason", `${checkValidity[2]} -> ${reason}`);
warningsEmbed.setColor(commandColor);
//And send
return message.channel.send({embeds: [warningsEmbed]});
``` basically all I had to do
Why my other command replaced by current used command?
Why are you
What is the point of you doing if(message.client.commands.get(commandName)) and then doing the same inside the if statement body
still havent updating my code
also you are checking if there is no command inside the if statement while that if statement is checking for the command
so it is redundant
I wanna rewrite my old connect4 and tictactoe games
how should I do it?
I used reactions back then but idk if that still works
sounds like pain
believe it or not this was the only way to do that back in 2020 đ¤Ł
enmap users realising its just a simple sqlite database with json support
When I used +result without any given args[0] the image 1 will be the result. But when I give command name then it will go to image 2
I remodified my code xd
I just dont understand, instead of copy the file, it replaced by the current used command
args[0] is probably the name of the command being ran and not the one you are trying to reload
after running +reload test3 then it replaced with another function
if (!command) {
return message.channel.send(`There is no command with name or alias ${name}`)
} else if (command || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(name))) {
this here why
đ
you can group that together with the command variable and just do if(!command)
const command = message.client.commands.get(name) || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(name));
if (!command) {
return message.channel.send(`There is no command with name or alias ${name}`)
} else {
also the only way I see you replacing it with the reload command is args[0] is the reload command name and not the command you wanna reload
so log args and check it's indexes
ah still the same
Log.
wait
Args
let me
should i do
name.command
?
lemme try
nvm
lmao
i think ive found the solution, its bec of for it only look for the command that im using
woah as if I didn't say that
confused asf my bad
I'm starting to get confused on why the span is returning white?
https://cdn.hamoodihajjiri.com/6uYPMuDcTN
what's the problem?
when I'm open http://localhost:5000/twitch/dashboard/channel I see white screen but
when I'm open http://localhost:5000/twitch I see error page (404)
Each component has its own router.
any1 know why i getting that ** .name** is undefined?
so this code should log when someone update channel name, but instead it give this error
and this just started happening...why? IDK
channel.old and channel.new both are undefined
so can't read value channel.old.name and channel.new.name
Turns out you're doing the entire thing wrong
It should be like
client.on("channelUpdate", (oldChannel, newChannel) => { ... }
ahh tnx man
And I don't understand why you're using an async function when you'll end up using callbacks
I don't see /twitch route
I don't understand why /twitch/dashboard/channel is working either
Unless you have another router running at /twitch/dashboard
//outside the guildmember event:
let timer;
//inside the guildmember event:
timer = await setInterval(function () {
memberchannel.setName(`Totale Members--> ${number}`)
}, 10000);
}```this code is inside my guildmemberadd event. Would it start a new interval each time someone joins or is there a way to make it only activate once?
Would it start a new interval each time someone joins ?
Yes (probably)
yeah that would result to an api rate limit after 10 joins lmao
how can i fix that
define a new variable at root level (Outside guildMemberAdd
i will just bind it to a command
owh
so like: the above snippet?
this TWDashboard router file:
let members = 0;
let abrakadabra;
client.on("guildMemberAdd", member => {
if(abrakadabra){
member = //number
} else {
member = number
abrakadabra = setTimeout((0 => {
memberchannel.setName(`Totale Members--> ${members}`)
// Not numbers
// I'm not sure if it'll work as i intended but it doesn't hurt to try
}, 69420)
}
}
I can't understand why it's not working
you don't have any /twitch route
you have /twitch/dashboard
/twitch/dashboard/channel
and everything else
the problem is already /twitch/dashboard/channel not working
wait what is the members variable?
What does it do
member count
oowhhh
Does /twitch/dashboard need the /twitch router to work?
//outside the guildmember event:
let timer;
//inside the guildmember event:
timer = await setInterval(function () {
memberchannel.setName(`Totale Members--> ${number}`)
}, 10000);
}```isn't it essentially the same as this snippet tho
If one member keeps joining every 10 seconds it'll never fire
like never
?
my goal is to show Channel file inside TWDashboard folder at /twitch/dashboard/channel

