#development
1 messages · Page 1569 of 1
i recognize the name, wheres it from 🤔
node-canvas
OH
agreed ^^
@gilded olive i just lost all respect for you. After explicitly stating i didnt want people blatently copying the stuff i made, you went out of your way to make a package that does EXACTLY what i worked to do. Thanks
wut, where
dude its just a joke 🤣🤣
i dont think its funny at all
same ascii that i do for my bots, same presence, ya trying to blatently plagiarise what i do?
yikes
wait is it just the ascii art or the whole package?
I mean... is it OS?
the whole package is built to literally do the same thing im doing
he went out of this way to build a shitty package ontop of this
ew
I mean again... If its Open source with a OSS licenses then
Most licenses let you do that with crediting the original author
if its not licensed then 
low key though this only a little python script
hardly worth getting upset about
pretty much do whatever you want
pretty much do what ever but the repo's must use the MIT license and credit the author
i guess that's fine to me
you could go one of the anti-cloud licenses just to fuck the cloud companies 
like mongo went and did
kekw
the repos dont need to use MIT
they just need to have a copy of my MIT somewhere in their code
Just make your repo un-licensed so no one can use it 
xD
big brain
profit 
though im guessing npm will have some sort of protection for that
not that it'd stand any legal ground in the first place cuz i mean you uploaded
nah I always use that ascii
sorry
I can delete it if you want, it dosent even do what yours does
,its really meant to just use it easily
you ever feel like somone is padding their github profile
lmao
theres more
xD

cool, but we dont care
i mean sure but excuse me mama this is #development
um ok
Hmmmm 
Thanks 
HA

private/private orgs are where these are used
yeah i doubt to a level where its actually worth putting them on 
i hate people with over the top profiles like god just say you want to work for FAANG
lmao yes
then again when ever i see a repo that padded its usually a "well i used it like once" type thing
"Oh boys im a core maintainer for Python cuz i did a commit" 
like, "dude are you a programming god? you can code in ALL of these languages and use ALL of these technologies!"
"what's the point in learning to code if there are people out there who know absolutely everything there is to coding"
im testing some website stuff but uh
it doesnt upload onto the web
and yes its a static web
sometimes it takes a while
ive never heard of that
what exactly do i do ?
the only thing i know about website config is CNAME
wait im searching for something
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
these IPs
add them as A records
all in one or seperately
for each one, leave the name in blank and set the ip to the target
separated
then you gotta add the CNAME thing
the website.github.io domain
ah
wait you mean the CNAME file or the record?
but i think github adds it when you set the domain anyways
same issue
hmm idk
They are all langs I learn and want to become prof in, so i put them there
very descriptive
I mean
yeah the dude who made that issue was
well lets say they defo wernt a github user often
especially after we closed their original issue saying to go to the support server

well for it to be secure between you and cloudflare it still takes work on your behalf using TLS
need to set up SSL on your given server
with a given cert and key file as a bare minimum
time for google™️
You know you're lib started to become thicc when this is the smallest amount of internal imports 
const sendAcceptOrDecline = await Promise.all([playerOne.send(AcceptOrDeclineOne), playerTwo.send(AcceptOrDeclineTwo)]) how can i add a reaction to both?
can someone help me with express passport
i login successfuly
and if i were to make another callback in "/discord/redirect" then i would be able to access req.user
however i redirect to the test route and somehow req.user is undefined
and yes
i do have these stuff
I never thought I would see the day.
https://github.com/itsMatoosh/ESKETIT-Language-Parser
No question no help
.....
How the f*** do I even shutdown my app after the implemented sharding, I just terminate with ctrl+c but it obivously shuts just one shard or idk, the logs just keep poppin
one option is to close it with task manager(all node-js apps) or htop and send a SIGKILL signal to all of em' @smoky herald
found a way, but I have absolutely no idea what I'm doing anymore tbh, I just feel like ever since I started to deal with that sharding thing my app just keeps breaking more and more
I've been using https://anonfiles.com/docs/api ...
let form = new FormData();
let stats = fs.statSync(zippath);
form.append('field-name', fs.createReadStream(zippath), { knownLength: stats.size });
let options = {
method: 'POST',
credentials: 'include',
body: form
}
let uploadFile = await fetch("https://api.anonfiles.com/upload", { ...options });
if (uploadFile.ok == true) {
res.send({
error: "none",
response: await uploadFile.json()
});
} else {
res.send({
error: "An error has occured when requesting anonfiles.",
response: await uploadFile.json()
});
}
but i keep getting
{
"status": false,
"error": {
"message": "No file chosen.",
"type": "ERROR_FILE_NOT_PROVIDED",
"code": 10
}
}
when i literally add the file... in the body
trust me, i know the pain


ask anyone here about what i fucked with in sharding, you'll have a giggle
I dunno if I wanna know how else I can fck it up xD
I honestly feel like reverting everything to non-sharded version and whatever happens at 2500 happens
I started getting random logs from dunno where, mongo errors of duplicate keys...
and it feels like each command goes to all shards or idk
!rank
yes !rank
like, my app is literally not running anymore, but the bot is still online @opal plank
I open the console and there is no screen to reconnect, but the bot still responds to commands
idk how you running them, but you should send SIGNSIGNAL to all of them via IPC
that sounds like magic to me 😖
let uploadFile = await fetch("https://api.anonfiles.com/upload", {
method: 'POST',
body: createReadStream(zippath)
});
if (uploadFile.ok == true) {
res.send({
error: "none",
response: await uploadFile.json()
});
} else {
res.send({
error: "An error has occured when requesting anonfiles.",
response: await uploadFile.json()
});
}
why does anonfiles still error me that im not uploading any files
(no console errors)
im just gonna shut the whole instance, fuck this
In quick.db, whats the new way of db.startsWith(...); ?
use .all() then Array.map()
will it work the same if I try to use the Array.map({ sort: '.data'})?
Ohh, is it possible to still implement a sorting method?
just a tip, append ?size=512 to the end of the url
if the lib doesn't do that already
Hey @pale vessel
Someone told me that you have your own api?
Can I get a link to that if it's true, Thanks
API for?
Image manipulation stuff

so i thought
What bot?

a
rMember.roles.add(role.id).catch(e => console.log(e.message));
If I would want to define an embed and send it if an error occures, would that be possible in the catch?
Yeah?
I’m not no pro at JavaScript but could you not just replace the console.log() with the embed your sending?
(e => send embed here)
You're missing a ) in that follow up for the record.

rMember.roles.add(role.id).catch(e => {
embedError.setDescription("lmao, error");
message.channel.send(embedError);
});
Can that work?
Try it and see
Is that not intentional?
Not JavaScript coder, 🤷♀️
What do you mean?
I don't like it to console log it.
I want it to send a message instead.
It's supposed to send an error when an error occurs, so it should work.
Ok.

let data = await db.all(`bal.${message.author.id}`) data = data.sort((a, b) => b.value.bal - a.value.bal); data = Promise.all(data.map(async (data, index) => { const user = await client.users.cache.fetch(data.key.split("."[2])).catch(() => null); if(user) { return { tag: user.tag, bal: data.value.bal, rank: index + 1 } } }));
Says cannot read property of bal of undefined
Im confused and its making my head hurt
This is meta.
what the fuck
How exactly can I use deleteMany()
on mongoose because it isn't deleting
What the hell
client.disc = discord
just require it in the file...
@blissful coral deleteMany() takes the same as findOne() or find() or findOneAndUpdate()
It isn't deleting many
easier to just call it.
@crimson vapor join test 1
:(
stream in bot devs ez
I am
how the fuck do i pass in discord if i destructure the discord require
nvm figured it out
wdym
yes
its 2pm for him
and? theres no rule to when you can sleep
yeah but no reason to sleep at 2 pm
there is
wdym
being bored and have nothing else to do
yes
PAIN
Ok, so I moved my events in to seperate files but I cannot get the user activity setter to work.
Literally just needed to pass in client
Nope, didn't work
TypeError: Cannot read property 'setActivity' of undefined.
const { green, red } = require('chalk');
module.exports = (client) => {
console.info(`${green('SUCESS')} Bot is now online`);
client.user.setActivity('chat.',
{
type: 'WATCHING',
}).then(console.log(`${green('SUCESS')} Set playing status`));
};
are you doing this in/after the ready event?
if you do it before, the user is not going to be set as you're not granted the data finished downloading
What?
read the error
whats wrong with config
nothing
you're just trying to use it before you say what it is
well, i don't know what you mean
imagine being in a room with a door, and there's an orange when you open that door
you cannot get the orange without opening the door first
that code needs to be executed in the ready event or after it
client.user is not available intil the bot is logged in and ready
whats wronggg withhh thattt
third time im telling you the same thing
there's even an analogy if you just ✨ read ✨
maybe config.json is outside the dir you are in?
or you have an src folder?
i had to debug path issues just to get my handlers to work
path issues would error out with module not found
yes
...which is the error they're not getting
i figured it out
they put config after the line in which config is called
@earnest phoenix put config at the top of the file
let data = await db.all(`bal.${message.author.id}`) data = data.sort((a, b) => b.value.bal - a.value.bal); data = Promise.all(data.map(async (data, index) => { const user = await client.users.cache.fetch(data.key.split("."[2])).catch(() => null); if(user) { return { tag: user.tag, bal: data.value.bal, rank: index + 1 } } }));
error: Cannot read property of bal of undefined
you should let them figure it themselves
ok
value is undefined, console.log any object from the data array and see the structure
i thought that was required either way because value was fetching it from the db?
🤷♂️
idk how to make a leaderboard in quick.db so im winging it tbh
when you console.log it you'll see the structure of your object
use the according properties
so do I just console.log(data); ?
now i get why your username is cry
data[0] (you need to grab the object, not the array)
if I log just data, will it show the entire thing (similar to logging client)?
yes
alright
depending on the size of the array it can just outright fill up your console buffer
Congrats, I made it all work!
@earnest phoenix It cant make jt past data = data.sort((a, b) => b.value.bal - a.value.bal); so it cant log it
uhm
ID*
that data structure is weird

you're not supposed to store it like that
thats how i always have
you should have an id property that's set to the user id
and then a bal property that has the balance
so your structure would look something like this
{
id: "snowflake",
bal: number
}
i heavily suggest redoing your structure like i mentioned above
...that's why i said redo
lol
that example was also js objects
i have no experience in other fields
not json
isn't that quick.db?
yes
and idk how to make it list data now
bc clearly theres data as shown
but it responded with no data hmm
go to #memes-and-media if you're going to shitpost
well what if i do .data after fetching the id as bal?
ima try it ig
Oh wait !! New error
Cannot read property of split of undefined
so the error has to do with this
const user = await client.users.cache.fetch(data.key.split("."[2])).catch(() => null);
if(user) {
return {
tag: user.tag,
bal: data.ID.bal,
rank: index + 1
}
}
i assume
Posted in #memes-and-media 👍
i dont have a data.key though in the array apparently, should i like, set the ‘key’ as message.author.id;?
@earnest phoenix what if i dont split it?
🤷♂️ your structure is a mess, i don't know what data.key is
i thought that is auto-set to author id
without splitting i get a error that states
"client.users.cache.fetch(...) is not a function"
That can be messing up my splitting then
if i was in your place, i would just drop it here and redo everything (about your database)
i spent so long on thisssss
idek how to redo my database
when they have 3+ values its sorts like that
guys i have completed this and its working but how do i can get there (i know i asked this million time lol )
i have made a help panel that edits itself just like carl bot docs but i dont know how to set the timeout
pls help
i might move to mongodb
congrats
--
URL - http://your.public.ip.address:5000/dblwebhook
Authorization - whatever config.AUTH_PASS returns
where i can get my public ip
The IP address of the machine your bot is on
i dont use rdp or vps
Do you host on your PC?
nope i use repl
k
Remove port from URL, set webhookPort to 8080
@slender thistle whta do i put in the AUTH_PASS
What does your config.AUTH_PASS return
@slender thistle like that
oh god
@slender thistle hello?
im haveing issues with the client.login with working with an external file
bin your code
ok
like that
??
🚶♂️ 🦽
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!'
client.once('ready', () => {
console.log('Your bot is online');
});
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
message.channel.send('pong!');
} else if (command === 'hello'){
message.channel.send('gday m8!')
}
});
client.login(process.env.TOKEN);
so i can at least read it
first off its .env
and also no spaces
it good you didn't also leak your token
🙂 im learning
args easy
im learning x73db
thats means nothing to me...
good database for small bots like mine
C:\Users\riley\Desktop\DiscordBot>node main
(node:15160) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (C:\Users\riley\Desktop\DiscordBot\node_modules\discord.js\src\client\Client.js:206:52)
at Object.<anonymous> (C:\Users\riley\Desktop\DiscordBot\main.js:24:8)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Command Promt Error
INVAILD TOKEN
can you read the error
its right tho
i can
r u sure u puted the token right?
i checkd it
errors don't lie
MAKE SURE ENV FILE IS .env
ITIS
OK
poooof
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
we can't see your bot smh
.-.
ik
just showing u ik where to go
TOKEN=ODAwMTE2
WELCOME TO THE SERVER WHERE PEOPLE DON'T EVEN UNDERSTAND THE WAY TOKENS WORK
BUT WANT TO CODE BOTS
that is in my .env
@earnest phoenix use https://npmjs.com/dotenv for require your values in .env
stop having a mental breakdown in the development channel
ok
?
do require('dotenv').token;
the more people who don't understand simple stuff, the more i have a mental breakdown
at the bottom on main.js?
at the top
you need dotenv package
i have
DO I REALLY NEED TO FUCKING EXPLAIN
and no, thats not how it works
some people are just dumb 🤷♂️ coding requires critical thinking, many of the "devs" are unable to do that
if ur self hosting why have a env anyway lol
i was told to do it
i at least understand errors
like module_not_found => path error
time to google
require('dotenv').config() - what do i put in config?? or leave it blank?
read the docs
^ this
it says early on
As early as possible in your application, require and configure dotenv.
require('dotenv').config()
so ima put it at the top
@slender thistle
put the config in it
🚶🏼 🦽
guys
can anyone see this pls?
Are you entering webhook settings for an approved bot?
no ||i thought i can lmaooooo||
Well there's your answer
but is the url right?
Yes
https://paste.mod.gg/wuhavobixi.js is that right
im waiting for my second bot to get accepted
Welcome to hell, number 10000000 in queue.
Your bot is 60% close to being reviewed. When your bot is accepted or declined you will receive a DM from Luca in our Discord server.
Please check the pins of the #support channel to learn when your bot will be approved.
I dont even want that bot anymore so ima delete it
@earnest phoenix
pls someone help
i hate it when
if (blah)
{
do stuff;
}
why bracket like that
im making fun of C# users haha funny
boo hoo
c# is quite powerful and versatile
i use it for quite literally everything but UI
node excels at UI
my some command not works and no error raised why ?

what
😭
i had a stkem readn stsgta
guys i have created a blacklist code i wondering how do i let the blacklisted member not using my commands
blocklist*
if you use a Command handler check if the message author is in your blocklist
nope i dont
python ?
the amount of messy formatting that screenshot has is causing me pain
then do it in your message handler
lol
also dont use var. var is deprecated, but still there to not break the internet
use let or const instead. let is mutable const is not
java != javascript
Screen of the error
!?
Take a screenshot of the error
He said no error???
ya
in terminal no error
😭
whats the problem !?
did you use some sort of command handler?
can you see if the command gets loaded on startup?
mine is python bro
py also got ways to log to console
how can i generate random number in minimum range - maximum range?
Math.random() * (max - min) + min
k ty
Is this the correct code for total roles that a user has?
message.member.roles.cache.size
Oh
Thanks
is that underscore roles?
Yes
ok
For server total roles message.guild._roles.length?
Server? Use roles.cache.size
usage of undocumented / private properties is not recommended
Yep server.OK
what abot user tags?
I mean Badges
message.author
Ok
@pale vessel Math.random() * (max - min) + min can you make example number?

Why not Math.ceil(Math.random() * 100);?
hmm I think you should Math.floor it
Can anyone help me make the bot send dm message to the user who voted for it in top.gg? 

Do you mean comparePositions()?
There is no role.compare
Ohk
for userinfo command
Iam asking
And one more doubt
I have only userinfo command for self.But i dont know what is the code for userinfo @user?
Use message.mentions.members.first()
Ok
That gets the first mentioned member
Oh
You should fallback to the author if no one is mentioned by using message.mentions.members.first() || message.author
Oh ok
Assign that to a variable and treat that as a member
Ok
Like that
Oh ok
and member.roles...
You want to get the amount of guilds the user's in? Not possible
Then how its possible?
Idk if it's possible using oauth2, but I've never dealt with it
Ok
you can do it via oauth2 yeah
oh ok
but you can't access all guilds just with the bot
kk
Who here knows dbd.js
ew
why did you want to use a wrapper?
so dumb
for beginners is maybe a easyer start but you give up on flexibility
if you begin with dbd.js you'll likely never learn anything useful as long as you're using it
maybe they notice the missing flexibility when they get better.
dbd.js is more confusing than brainfuck
its fine tbh, but its limiting, i think using commando would be the better alternative
but still not perfect
fight against sharding, day 3, anyone with some sharding experience I can occasionally annoy in DMs? 
whats the issue you're having?
anyone know if you can put limits on a input for a function in ts
something like arg: string[3] meaning it has 3 length
that would be cool
how do you recognize event blocks in js?
Hi
What do you mean by 'event blocks'
oh...
event blocking code is syncronous, so that's that
so anything that needs to wait is an event block?
Any loop is event blocking, for example
yeah. No code will execute until the loop is over
tf
so
what if i wanted the loop to complete
but dont want it to event block
something like
arr = []
loop // push to array
arr output
if i dont use that for(...) it wont push to array
the array will be empty
I'm not sure what you mean
lets say i have an empty array where i need to push some values in a loop
you will only notice event blocking if you are doing thousands of iterations
so this loop needs to complete before the output of the array is used
well
there are thousands of users
accessing this small loop
which is pretty much event blocks
ig?
1000 users -> for(10 iter)
The code after the foor loop will execute after the for loop is over, the array will always be not empty after the loop
but you just said for(..) is event blocks
so if there are 1000 users waiting for this loop
its pretty much gonna start to lag
it depends on how often you do that
how can we code decancer?
Nothing else can happen during the iteration , that's what you mean by event blocking, right
its very very inefficient to run 1k iterations on a command message
but its decent for a flushCache or something
const winAmount = Math.floor(Math.random() * 10) + how do i make this 20-30?
actually my question was what are event blocks.. are for loops the one ones??
i doubt for loops cause event blocks
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
const winAmount = randomNum(20,30)
will that do 20 - 30 yeh?
@cinder patio
I have an object holding an array of values in a json file. How can I have my program search through that array to find if a message sent by a user has any of those values?
it's a function which takes two parameters and gives you a number in between, as their names say you enter minimum number including first parameter and maximum number including max parameter
I'm pretty sure loops are considered blocking because they are syncronous, that means that nothing else can be executed while those loops are still running. If you keep your loops small and optimized, they shouldn't be an issue.
Any syncronous operation is blocking
1 + 1 is blocking
how long it takes to run it is a different question
bubble sort says hi
some one pls help me i delted the last bit of my code and dont know it...
client.login.Discord;
i tried to remake it...
what
then client.login part
i forgot how to make it
bruh
it's a function, call it with your bot's token as the first argument
ok so, here's a scenario, i need the loop to determine who's turn it is etc etc, but what if 2 - 3 users are accessing this.. and ofc the loop runs for 15 rounds but inside the loop there are delays of 1sec
it should run 2 separate funcs for 2 users
it should not do something like u1 loop still running and the u2 loop doesnt even start
It depends on how many iterations the loop is doing
How many iterations is the loop doing max
whats the command promt thing that makes the directory change?
cd?
any clue why, even if i send a message, the c.on("collect") event never triggers?
you need to return your filter
heck
either h => x == y or h => { return x == y; }
what to the shop?
nou
https://stackoverflow.com/questions/48082009/array-sort-is-not-working-correctly-in-javascript/48082262 @mellow kelp
interesting
bot.user.setStatus not working
bot.user.setPresence({activity: { name: test, type: "PLAYING"}, status: "idle"}); activity working but it didn't set status.
status sometimes doesnt work for no reason
And why i got it
I only used music
which they dont allow
._.
welcome to why music bots cost so much run :P
Bruhhh
buy a ipV6 subnet and shuffle the IPs
making a music bot is not worth it unless you invest cca 50 bucks a month for a minimal bot
making a music bot was easier back in the day when rythm and all other bots were new
they built their foundation and userbase on that and made money with that
and now they're able sustain their services with these new restrictions youtube put in place
newer bots cannot do that without a big investment
cri
also the main reason why i make a large circle around music bots.
you want to post your bot stats to the api?
Yeah wdym
how do i put someone profile pic on a website
like this https://top.gg/user/390690088348024843
using a library?
wym
discord.js, discord.py, anything like that?
ok i use js
um ok
yes
do you have the user info?
this right?
you gotta form a url like this: https://cdn.discordapp.com/avatar/<user-id>/<avatar property>.png
yeah that gives you access to the user info
tf do you need the email for
this is the url
you can change the extension to jpg, jpeg and webp
ok i will remove
yeah, that way you're granted support for animated avatars
without any preprocessing or some shit
extra pog

that it
yeah
is there a way to remove a document from a collection in mongoose if the keys match a certain value
or would you have to like find all the documents which match that value and delete them
Use deleteMany(filter)
didn't we have a deleteMany debate?
What debate?
so basically I would update it to be the new array and then deleteMany(<if some value matches this>)
Error: Players validation failed: elo: Cast to Number failed for value "NaN" at path "elo"``` what does this mean
code: let data = await db.all(`bal.${message.author.id}`) data = data.sort((a, b) => b.ID.bal - a.ID.bal); data = Promise.all(data.map(async (data, index) => { for(let i = 0; i < data.length; i++) { const user = await client.users.cache.fetch(data[i].ID.bal.split(".")[2]).catch(() => null); if(user) { return { tag: user.tag, bal: data.ID.bal, rank: index + 1 } } } })); if(!data.length) return message.reply('There is no data currently.') const page = functions.pages(data, 10, args[0] || 1) if(!page) return message.reply('That page does not exist!') let dcc = new discord.MessageEmbed() .setTitle(`Leaderboard for ${client.user.tag}.`) .setColor('GREEN') .setDescription(page.map(e=> `\`#${e.rank} | ${e.user} | ${e.bal}`)) message.reply(dcc) }
No error, just keeps saying No data found but I do have data
I can't understand RegEx, can someone tell me how to make one so I can replace every "time": value (JSON) to 300?
you want to REPLACE the word time with 300?
no, the value of "time"
there are multiple "time"s
you could use recursion to replace all the values with the key time in your object
well, first you would probably want to parse the json into a js object
you can make a function that loops through every key of the object, and changes the value to 300 if it's "time"
and if it finds a value that is another object, call the function on that object too
can't u just iterate over the json?
well yeah, if you don't have nested objects just do that
regex is actually a "replace this" thing
not "replace that"
if that makes sense
even if you have nested objects, all you need to do is iterate over those too
how do I do thaaaat
hey guys
o[firstmember].owner = targetMember.id; //Setting the owner ID
^
TypeError: Cannot set property 'owner' of undefined```
fs.writeFile("mons.json", JSON.stringify(o), e => {
//Handle error
o[firstmember].owner = targetMember.id; //Setting the owner ID
fs.writeFile("mons.json", JSON.stringify(o), e => {
o[targetMember.id].owner = firstmember; //Setting the owner ID
});
});
});
```
I'm trying to have my code go through an array and if the message has start with"owo" and a value from the array. The array is stored in a json file.
// Require fs
const fs = require('fs');
// Require Discord JS
const Discord = require('discord.js');
// Get the token from config.json
const { token, prefix, prefix2 } = require('./config.json');
// Create a new Discord Client and call it client
const client = new Discord.Client();
// Define Commands
client.commands = new Discord.Collection();
// Define commandFiles as the command folder. Then ignore all files in that folder that do not end with .js
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
const { list } = require('./owocommands.json');
// Say ready when online
client.once('ready', () => {
console.log('Ready!');
});
// When there is a message detected...
client.on('message', message => {
function check() {
return message.content === 'owo' + list || message.content === 'owo ' + list;
}
// If the message was made by a bot ignore it
if (message.author.bot) return;
const msg = message.content;
// Counting
if (msg === 'owo') {
if (list.every(check) === false) {
message.channel.send('That was a command');
return;
}
message.channel.send('That was not a command');
}
this is how the mons.json looks. I need the owner ids to be changed
im trying to deploy my site from github but
this happens when i try to add a CNAME
for github
unless i don't need to?
it already exists
you see, github is not a site hosting
Thats clodflare
anyone that could help me with the object transfer?
you're trying to set a cname for one that already exists
@sterile lantern have you tried reading the error message
do you own a domain?
I know, but still
yes
i do own it
but im using cloudfare's NS
what is your domain?
so your site can only be xxxx.codewindhq.net
?
or codewindhq.net
whatever u want to put there
xxxx is a placeholder
like, you could make api.codewindhq.net
afaik u cant
because codewindhq.net already exists
Could someone help?
it's yours
you need to set a dns for that domain
but you can't have an ip in github
How would you do deleteMany in mongoose so that you only delete it if the key x doesn't have a value
so like js await someSchema.deleteMany({ // if prefix is not here });
i think you can use $not
"test": \d+ replace with "test": 300
tyy
hey
can someone help me with changing the owner value in the object
fs.writeFileSync("./mons.json", JSON.stringify(o), e => {
//Handle error
if (mons[firstmember].currentMon.id == found){
mons[firstmember].owner = `${targetMember.id}`; //Setting the owner ID
}
if (mons[targetMember.id].currentMon.id == founds){
fs.writeFileSync("./mons.json", JSON.stringify(o), e => {
mons[targetMember.id].owner = `${firstmember}`; //Setting the owner ID
});
}
});```this is waht i have rn
did u know free host expect heroku?
glit ch
but it ain't like heroku]
Theyre all a shit as each other
don't
me too
you too what?
I didn't say that
Thats
Lmao sometimes translation randomness is amazing
lol
i don't like heroku
free deploy it's during for 1 month

like glitch
Takes a 5 piece ritual and chant
let's watch a video on yt
Lets not
oh ok
but... i doesn't need glitch for do that(?)
no
how do i loop through this object to search a element that has the same owner id
like, could anyone give me an example
first of all, please use this https://jsonlint.com
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
it is valid
{
"1721138": {
"ability": "Corrosion",
"iv": 88,
"stamina": 96,
"hp": 338,
"speed": 50,
"attack": 16,
"defense": 28,
"specialattack": 234,
"specialdefense": 307,
"id": 367,
"name": "Huntail",
"level": 18,
"catchChance": 0.8333333333333334,
"spawnId": 4236884,
"owner": "345138133429649408",
"catchTime": "01/18/2021 9:49 PM",
"nickname": ""
},
"1722312": {
"id": 713,
"name": "Avalugg",
"level": 14,
"iv": 11,
"hp": 132.6,
"speed": 46.84,
"attack": 160.76,
"defense": 246.52,
"specialattack": 67.32,
"specialdefense": 69.32,
"catchChance": 1,
"spawnId": 3466157,
"owner": "345138133429649408",
"catchTime": "01/19/2021 4:15 PM",
"nickname": ""
},
"1724437": {
"ability": "Turboblaze",
"iv": 43,
"stamina": 256,
"hp": 167,
"speed": 143,
"attack": 211,
"defense": 205,
"specialattack": 167,
"id": 170,
"name": "Chinchou",
"level": 32,
"catchChance": 0.46875,
"spawnId": 4108588,
"owner": "345138133429649408",
"catchTime": "01/15/2021 12:15 PM",
"nickname": ""
},```
something like this.
I need the owner key to be changed.
JSON Path Finder
or you have the owner id and you want to find the entry that has the owner id?
I'm trying to get it to say if the message is a command, the commands are listed under list, but I always get that the message is not a command:
function check() {
console.log(msg);
return 'owo' + list === msg.startsWith();
}
function check2() {
console.log(msg);
return 'owo ' + list === msg.startsWith();
}
// Counting code
// If the message startswith owo and is a command then do nothing.
if (list.every(check) === true || list.every(check2) === true) {
message.channel.send('That was a command');
return;
}
message.channel.send('That was not a command');
Can anyone with Javascript knowledge let me pick their brain via DM's for a minute?
oh forgot to mention, that's MongoDB
the picture is a document from the guildConfig collection
cheese.burger()
ok.then()
the sourcebin link
this.id also refers to guild id
so technically that filter obj should match that photo, right?
```let money = db.startsWith(bal.${message.author.id}, { sort: '.data' })
let content = "";
for (let i = 0; i < money.length; i++){
let user = client.users.cache.get(money[i].ID.split('.')[2]).tag
content += `${i+1}. ${user} - ${money[i].data} \n`;
}
const embed = new Discord.MessageEmbed()
.setTitle(**Global** Leaderboard)
.setDescription(${content})
.setColor("RANDOM")
.setTimestamp()
message.channel.send(embed);
}```
Issue: Returns the embed without the content being thte leaderboard
Package: Quick.db@7.0.0-b21
console.log content
let last1 = Object.values(mons).find(m => m.name === `${found.name}`)
fs.writeFileSync("./mons.json", JSON.stringify(mons), e =>{
//Handle error
last1.owner = `${targetMember.id}`; //Setting the owner ID
});
let last2 = Object.values(mons).find(m => m.name === `${founds.name}`)
fs.writeFileSync("./mons.json", JSON.stringify(mons), e => {
last2.owner = `${targetMember.id}`; //Setting the owner ID
});```does anyone know why it doesn't change the owner.ids?





