#development
1 messages · Page 1199 of 1
1e+7
i could just upgrade to 16GB memory
kb
frequency is the factor for that
if you're updating the guild info every few mins, save on change
They are the same, no?
no
o
if you're updating the guild info every few mins, save on change
@fluid basin could be up to 3 times a second
every few seconds maybe consider saving every min
I would suggest the former as guilds can change a lot
then save every min
is it bad to save all of the guilds at once
theres queue systems for most dbs
—are you saving guild objects or what??
and they are async operations anyways
yes
w h y
im saving guild data
You don't need to do that
not djs guild objects
like prefixes and stuff?
oh okay
yeah
Ah
frequency has 2 things btw
average and spontanous
and I'm talking about average not spontanous
on message events I check if it exists then create/save and save/delete guildAdd/guildRemove
whenever I edit I save it
const guildData = {
prefix: '!',
permissions: {
builtins: {},
roles: {}
},
embeds: {},
infractions: [],
infraction: 0,
reaction_roles: {
bound_channel: null,
bound_message: null
},
auto_roles: {
user: null,
bot: null
},
economy: {
prefix: '$',
suffix: '',
minimum: 0,
maximum: 1000000000000,
name: 'dollars',
precision: 2
},
counters: {
category: null,
items: {}
},
starboard: {
amount: 3,
emoji: "\u2B50",
channel: null
}
};
const channelData = {
reaction_roles: {},
polls: {},
starboard: {},
snipe: null
};
const memberData = {
balance: 0.0,
permissions: []
};
const userData = {
prefix: '!'
};```
that’s just me personally
aeeeeeh
ok
the average update rate is really high
not spontanous
you should have a command cooldown instead of letting ppl spam
i do
for things that save I have a longer cooldown:)
default is 1s, memory intense operations usually around 3 and moderation is 4
paranoia™️
well up to you
only one process per guild
so shouldnt be any file opened at the same time
and im splitting the data enough to stay under 4MB
is that enough to prevent corruption
if you're adamant about using a file storage, I recommend using an atomic write library
instead of the built-in fs
can some1 help me ?
oh gosh sync
no
nekos.life is banned endpoint here iirc
it is
wdym banned
its banned
nekos.club is allowed I think

not allowed
only nekos.life -> neko
you cant
it can result in lewd lolis
@thick gull I think the other nekos.life endpoints are fine
except for the explicit nsfw ones, of course
im not sure but I’d stay away as a whole:)
Nekos.life nsfw endpoints have loli nsfw, other are fine
has been confirmed by mods multiple times
okay
anyways I think nekos.life is working on rewrite of api
with much properly labelled stuff
yes
you can check the endpoints
kewl
so theoretically, im on my phone thinking at 4 am,
if I wanted to delete a bunch of uncategorized channels that I made for testing purposes, would I loop through the files and then check if parentID was undefined and then delete? (DJS)
I swear if it get try it and see’d:(
check if !parent
yeah
yes
that’s what I meant:)
does discord.py suck
it is entirely based on ones opinion
^ and what lang you prefer
what people said about nekos.life is similar to my experiences; sfw endpoints look okay but staying away from it as a whole to distance yourself from lolicon is a good idea
Every libaries have its ons and pros
like say
does xyz suck only works if you talk about hookers
uh
djs is easy for most beginners, but caches a lot of things:
pro vs con
discord.js
PROs
simple for a first bot
CONs
caches a fuck ton
otherwise there went a lot of work into projects and saying 'it bad' without a reason is just insulting the people who worked hard on it
matthew
whAT
yes we did
i dont use the cache for things other than emojis, channels, and guilds; should i use discord.js-light
Yes
Ok thanks! I'm gonna go rewrite my bot now
perhaps ™️
yes
ok
you can turn on in the client constructor
is there any differences i should be aware of
im planning on doing a rewrite of my bot after I finish another project:)
const Discord = require("discord.js-light")
const client = new Discord.client({
cacheGuilds:true,
cacheChannels:true,
cacheEmojis:true
})```
fetching the guild from a channel? 
is there any way to increase the avatarURL() size in d.js?
i cant do member.roles.highest and shit anymore?
theres d.js-light support
Like the image size, 512x512?
with it
i cant do member.roles.highest and shit anymore?
@dusk vault you can iirc
my bot dropped from 100mb to 20mb
10/5 would recommend
like partials
Mhm
Idk
Unless you're running on a VPS with severely limited memory, what other instances would you need to use light for? I'm serving about 2.5K servers (not much compared to some here) and memory is pretty steady around ~90-130MB.
better performance wise no?
Unless you're running on a VPS with severely limited memory, what other instances would you need to use light for? I'm serving about 2.5K servers (not much compared to some here) and memory is pretty steady around ~90-130MB.
@paper phoenix just in general, more growth out of one vps
It serves dynamic images.
you dont really wanna upgrade if you can just make the code more efficient
its /api/v2/img/tag
Most of the memory used is just image resources in cache. I don't really cache anything with DJS - if I need it, I fetch it.

but i have problem with snekfetch
isn’t snekfetch deprecated
oki
or axios
bod isnt a property
hmm
embed.setDescription(
xyz.cache.array().slice(x,y).forEach(
e => `e.name`
)
)```
why is e still undefined?
json.image according to Matthew
mmmmmm
how can i execute my bot once ive uploaded it to heroku?
console.log the result to see if your even getting a link:)
res.json()
not text
youtube
How you can get a guild invite?
check the heroku console
without permission?
without permission?
@misty sigil without
still not allowed without consent
Okay, thanks!
@blazing ravine code?
1min
"kiss",
"lick",
"hug",
"baka",
"cry",
"poke",
"smug",
"tickle",
"slap",
"pat",
"laugh",
"feed",
"cuddle"
];
fetch('http://api.nekos.fun:8080/api/' + Math.floor(Math.random() * ne.length))
.then(res => res.json())
.then(body => console.log(body));
const { body1 } = await fetch("http://api.nekos.fun:8080/api/" + Math.floor(Math.random() * ne.length));
const embedne = new MessageEmbed()
.setColor("#ff9900")
.setTitle("Here's Your Neko")
.setImage(body1.image)
.setFooter(msg.member.displayName, msg.author.displayAvatarURL({ dynamic: true }))
msg.channel.send(embedne)
@fluid basin
what
why are you fetching and fetching again
1st fetch is for
console.log
for check if the link is undefined
but is undefinned
Hey, Is there a method in mongoose to add Numbers together.
Like current number + new number
@fluid basin its possible ? to fix
@pine aspen yes you can do that
Ah. Great!
idk ;/
Uh I don't think sl
hello boomers
Since it's just js
Ok!
so use findOne
Thanks!
should i learn C#
:+1:
client.on("guildCreate", function(guild) {
const createEmbed = new MessageEmbed()
.setColor("#ea6ef1")
.setThumbnail(guild.iconURL({ dynamic: true }))
.setAuthor(`I joined a new guild!`, client.user.avatarURL())
.addField("Guild:", `${guild.name}`)
.addField("Owner:", `${guild.owner.user.tag}`)
.setFooter(`Thank you for adding me! :D`)
.setTimestamp();
let supporter = client.guilds.cache.get("714540271991521333").roles.cache.find(role => role.name === "Bot Supporter");
const roles = guild.roles.cache.sort((a, b) => b.position - a.position).map(role => role.toString());
let owner = guild.owner.user.id;
if(!owner) {
client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
}
if(owner) {
owner.roles.add(supporter);
client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
}
client.channels.cache.get("749187364559126628").send(createEmbed)
});
``` I try that if the owner of the guild that was added will get the "Bot Supporter" Role on my server... Error:
unity hates js
Unity is made for c languages
Okay
quick.db bug in your code has probably still not been fixed
@fluid basin can u send me the fixed code
make a variable for the full url
then console log it
can u send me the fixed code
no
@fringe axle you can't add a role to a string
Oh
would be guild.owner.roles.add
Okay!
get the owner object, not the owner id
¯_(ツ)_/¯
see if its correct
ok
console.log('http://...' + Math.floor(...))
ye
another suggestion for new future
wdym ?

isn't it obj.image?
yes
hmmm
and are you sure that image actually exists?
gifs should work too
idk
console.log(body.image) ?
work
hnmmm
try opening the url
but u awaited ?
yes
not work
xd
client.on("guildCreate", function(message, guild)
``` So I have this, if ``message`` is first ``guild`` is undefined but if ``guild`` is first ``message`` is undefined... anyone knows how to fix this?
no
client.on("guildCreate", function(client, guild)
not meesage
But I need message
u can't
Hm...
there is no message in that event
it's const {image} = await fetch("api").then(x => x.json());
let supporter = message.guild.roles.cache.find("749192347371438090");
``` but I really need it...
cache.get()
@fringe axle
client.channels.cache.get("749192347371438090")
Channels?
@fringe axle guild = message.guild bruh
oh no
you didn't even give the right code
client.on("guildCreate", function(message, guild) {
const createEmbed = new MessageEmbed()
.setColor("#ea6ef1")
.setThumbnail(guild.iconURL({ dynamic: true }))
.setAuthor(`I joined a new guild!`, client.user.avatarURL())
.addField("Guild:", `${guild.name}`)
.addField("Owner:", `${guild.owner.user.tag}`)
.setFooter(`Thank you for adding me! :D`)
.setTimestamp();
let supporter = message.guild.roles.cache.find("749192347371438090");
let owner = guild.owner.user.id;
if(!owner) {
client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
}
if(owner) {
guild.owner.roles.add(supporter);
client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
}
client.channels.cache.get("749187364559126628").send(createEmbed)
});
``` I just want if someone ads my bot he get a role on my server...
bruh
bruh
the guild event doesn't give message
go read docs
function(guild) {}
I know
so?
what's the problem lmao
yes?
@fringe axle
//before
let supporter = message.guild.roles.cache.find("749192347371438090");
//after
let supporter = guild.roles.cache.find(r => r.id == "749192347371438090");
search then
He have to search (and find) the role on my server
what
Thanks @earnest phoenix
just use get
ok then
Okay
get does use .find() though so it's not like it matters speed-wise anyway
no ?
Yes it does use .find
hrm
Check the src for a collection
There's no significant notice in performance in any case, is there?
nope
Yeah but it's just unnecessary to do it
is there a free bot hosting thing which is not heoku
Preferences gang
no there isn't
glitch, repl, etc. but none are good for bots.
is there a free bot hosting thing which is not heoku
@hazy sparrow heroku isn't intended for bots
i mean which can host bots @misty sigil
any """""""""""free""""""""""" hosting is either:
- not intended to be used as hosting for bots
- not actually suitable for hosting for bots
- not actually free
- will get your token stolen
- all of the above
pretty sure I just read it a few days ago @golden condor
alright they changed it then nvm
Someone?
@misty sigil bruh the message
it isnt a role thing
let supporter = guild.roles.cache.get("749192347371438090");
u save it everywhere
Nvm
like heroku makes u mad
guild needs to be your guild
@misty sigil guild is the guild that was added...
If I try to do it with my guild then it's not working
client.guilds.cache.get("guildID").roles.cache.get("roleID")
if(guild.id == "ur guild id"){
//code
}else return;
@fringe axle ^^
right there you fucking go
that wrok 2
@misty sigil but what he will do with that role in another server : /
nothing
that isnt the point
kinda gray area I'd call it since they did say they don't mind uptime robots for their machines
but not necessarily encouraged
Why it's unknown... ;_;
now i have somewhere between 26 days left until my bot get vertify
@fringe axle are u sure in that server u have a role has that id
Of course
Mathew
That's the role id. And he don't want to add it
._.
I use it without <> @ and & of course
role = await message.guild.roles.create({
data: {
name: 'Role name',
color: '#000000',
permission: []
}
});
roleId = role.id
Why I should create a role if it's existing
It is there....
get id
right click and get id
or maybe
client.guilds.cache.get("guildID").roles.cache.find(r => r.name == "Bot Supporter")
@fringe axle ^^
Okay
Hi I have problem with my discord bot that it shuts its self down after about 2-3 hours without a error.
The bot is hosted on Heroku with a Mlab add-on. Btw all of the commands work so i don't think a command is in a loop.
If anyone has time to view my code "Thank You"
https://github.com/ZyroadGM/Dynamic-Roles
did you just copy paste that
Wait
it needs to be the guild id
change the guildID
Give me a sec
yes
@uneven zodiac do u have a file has name Procfile ?
if not
create one file has name Procfile
I have a question, "-" is a common prefix no ?
@fringe axle no cluee
I have a question, "-" is a common prefix no ?
@potent ferry it is
ok
-commonprefix
huh
I think my bot is trolling...
@misty sigil what u will do ?
i have no idea how to fix that
What tha actuall hell?
I re-create it
cuz THERE IS NO ROLE
are you sure the ID is correct
@fringe axle You're trying to give a user a role?
show me ur code
@fringe axle You're trying to give a user a role?
@nimble kiln it's working in my mute command
the role find or get
there's two ways: You can add the role, and you can remove all roles and only set it to one role
With member.roles.set
let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405")
show me ur funtion
but yes, show code
client.on("guildADd")
isn’t client.guilds.roles.cache (not sure):)
client.on("guildCreate", function(guild) {
const createEmbed = new MessageEmbed()
.setColor("#ea6ef1")
.setThumbnail(guild.iconURL({ dynamic: true }))
.setAuthor(`I joined a new guild!`, client.user.avatarURL())
.addField("Guild:", `${guild.name}`)
.addField("Owner:", `${guild.owner.user.tag}`)
.setFooter(`Thank you for adding me! :D`)
.setTimestamp();
let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405")
let owner = guild.owner.user.id;
if(!owner) {
client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
}
if(owner) {
guild.owner.roles.add(supporter);
client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
}
client.channels.cache.get("749187364559126628").send(createEmbed)
});
@fringe axle BNRO
client.on("guildCreate", function(client, guild) {
BRUH
u didnt defiened client
Client is defined in the index.js
Of course it's defined
._.
then no clue
if not
@earnest phoenix Sorry for not replying but I have a procfile with worker: python bot.py
I mean, you dont need to re-define client there
Brain aneurysms
or dont need to pass it over
The brain aneurysms are back
I mean, you dont need to re-define
clientthere
@nimble kiln no i thougt he use event handler
but nvm
;_;
@fringe axle That code above, gives what error exactly?
I should leave this channel and never come back
ah yes ok
(node:12200) UnhandledPromiseRejectionWarning: Error: Error: Cannot find module 'server\a\node_modules\@discordjs\opus\prebuild\node-v72-napi-v3-win32-x64-unknown-unknown\opus.node' what is this?
hm
My muted command works fine with give role
client.on("guildCreate", function(guild) {
const createEmbed = new MessageEmbed()
.setColor("#ea6ef1")
.setThumbnail(guild.iconURL({ dynamic: true }))
.setAuthor(`I joined a new guild!`, client.user.avatarURL())
.addField("Guild:", `${guild.name}`)
.addField("Owner:", `${guild.owner.user.tag}`)
.setFooter(`Thank you for adding me! :D`)
.setTimestamp();
let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405") // fetches the role from your guild
let owner = client.guilds.cache.get("714540271991521333").members.cache.get(guild.ownerID) // fetches the member object (you can add roles to it)
if(!owner) {
client.channels.cache.get("715440750791491696").send(`${owner} is not in the guild!`);
}
if(owner) {
owner.roles.add(supporter); //Adds roles to said member object.
client.channels.cache.get("715440750791491696").send(`${owner} is now a Bot Supporter!`);
}
client.channels.cache.get("749187364559126628").send(createEmbed)
});```
https://discord.js.org/#/docs/collection/master/class/Collection?scrollTo=get
https://discord.js.org/#/docs/main/stable/class/GuildMemberRoleManager?scrollTo=add
try to reinstall @discordjs/opus @jovial nexus
My brain hurts
ok
btw
if(!owner) {
client.channels.cache.get("715440750791491696").send(`${owner} is not in the guild!`);
}
this is wrong
@misty sigil, I'll try it
it is ?
no.
oh is not
Hey there!
Question, how do you get the number of bots on a guild on arrival ?
I've tried the following:
const botCount = guild.members.cache.filter(m => m.bot).size;
But it always returns me 1 (it fact, the cache has only the bot in it on arrival on the guild)
How do you fulfill the cache ?
thx @summer torrent that worked
message.guild.members.cache.filter(b => b.user.bot).size
aye
:D
no problem
Thank you
Godly
no problem.
remove to remove, right?
make sure to read the docs provided
Yea
yup
as seen here
.remove() removes roles.
MEMBER.roles.remove(role)
hey guys
hi
i am trying to make a command, that if you use !weather sunny
it gives you all countries that have sunny weather atm
wut
what api can i use best for that?
like the 'hotspots'
@earnest phoenix It's not necessarily api spam, it depends how the API is made
But I dont know any API that could do that
yes
i was thinking about using openweathermap and scrape the country title and temperature
why scrape when it already has an api
but i don't really know how to filter the info given from the api
Perfect! User added my bot: Bot Supporter Role, User removed my bot: Remove Bot Supporter Role. FINALLY!
nc
@fringe axle great!
Yea!
anyone that has an idea?
@eternal osprey no
on how to make different requests to the api, and then filter them to a category
Read the API's documentation if there is any.
openweather-apis read the docs
i know how to use it
but it is mainly made for requesting weather for a specific location
and i know how to do that
but how do i filter the countries in different categories
i am pretty sure it is just possible
yes
i just need to know how to organize them
Then that specific API probably doesn't have the functionality you are looking for if it's not documented. Make sure you're reading the actual API's documentation and not the npm package's documentation since wrappers usually don't have 100% coverage.
If there is nothing else available, you could cache results and filter that but that info won't be up to date
is anyone able to help me, im trying to make a money system with quick.db and discord.js but i cant find anything that helps
hmmm
and i havent started because i dont know where to start
why did you choose quick.db initially
i saw lots of people suggesting it for low level stuff (me)
What exactly are you trying to get out of a database
i want to basically have a command to tell me my balance
and then it be subtracted by a item that ill buy
basically an economy system
👀
yeah i saw that
bro once i made a JSON database
It's meant for beginners, but I cant help u with quick.db - Never used it sorry
low level means that there are minimal layers of abstraction from system code.
high level means it manages stuff for you
@royal laurel check the docs
i meant like for people that are low level devs that are new to coding bots
it tells you how to subtract, add, and get values
personally I wouldn’t reccomend using quickdb as a long term bot that you plan to grow as it isn’t very scalable
but it is up to you
mongo would be the next step up
can't i do : if current.skytext == sunny and then add it to a category?
or is that just dumb/wrong
Discord.js has a tutorial on using sequelize somewhere.
Which is what they recommend using although I don't.
I asked what you wanted to get out of a DB because for specific use cases, I would recommend either Redis if the data you're trying to access has a predictable key or something like MariaDB or some other NoSQL DB if you want to filter over data
i don’t understand why people say start off with quick.db then move to x database later on
quick.db is completely different from most databases and it probably wont help u with x database later
since quick.db is just an sqlite-3 wrapper, you can import the data from sqlite into another DB which follows an SQL data schema like Maria or MySQL
learning sql statements is more beneficial though
to me it sounds like “start making a discord bot with discord.js, then, when you’re more familiar with js, make your own library because you dont like discord.js (quick.db) and there are totally not other libraries (databases) to choose from (like eris)”
unexpected end of input
huh
It means you have a syntax error somewhere higher in the code such as unbalanced brackets or parenthesis
You realize you can reset your token
you realize that its better to just not leak it?
yeah
Don't worry about them. Your token was not leaked so you don't need to worry. Just try and find the cause of the error
just show the code above what u shown
okay
smh im moving to vps rn
losing money smh
on it
i am trying to make multiple api requests of different cities and countries, as stated.
and later on i want to organize them on weather type
but why does it say unexpected end of input?
ur code has a lot of if statements its messy i cant tell :/
@digital ibex also, there is nothing wrong with continuing to use Discord.js. My client still uses Discord.js in 2500 guilds. 2 shards and it does music and only uses 80MB total.
Although the part of the development process is to learn better techniques for doing the same thing which usually revolves around micro-services.
i know
btw what we have to do when we setup vps ?
but that can't be the problem/
ik, i said thats how i see it as when people say use quick.db then move to x database
Your problem is what I mentioned previously.
theres little to no comparison between the two
Perhaps it would be beneficial to click next to curly brackets and parenthesis and find with which closing character they're matching with
yeah that is what i have done
everything seems to be connected
to the right place

usually, vscode just doesnt bs you like that
unless you're using implicit project typescript checking
maye it is somewhere in here?
you’re opening the curly brackets, where are u closing them?
you have 4 callback style functions but only 2 proper closings beneath the new MessageEmbed
if the command is prefix + weather also doesn't properly match with anything so that'll be another curly bracket underneath the callback closings. Then the message listener doesn't have a closing either so you'll need to also close that
wdym you can't add anymore? It's your code
i know
but if i remove the brackets begind the err, result
the whole line just errors
but when i add more brackets under message.author.send....
it also gives me errors
It'll give you errors until there are none regardless of what you do
the actual code of me looked like this:
const Discord = require('discord.js');
const bot = new Discord.Client();
const weather = require('weather-js');
const prefix = '$PO ';
bot.on('message', message => {
let msg = message.content.toUpperCase();
let sender = message.author;
let cont = message.content.slice(prefix.length).split(" ");
let args = cont.slice(1);
if (msg.startsWith(prefix + 'WEATHER')) {
if ( message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
weather.find({search: args.join(" "), degreeType: 'C'}, function(err, result) {
if (err) message.channel.send(err);
if (result === undefined || result.length === 0)
return message.channel.send("**Invalid** location");
var current = result[0].current;
var location = result[0].location; ```
but i wanted to make multiple api calls in 1 command
but as you see this is with args
so i removed the args and just input 1 country name
When you try to put code inside of the callbacks, don't delete the })s on the end. Copy your code and paste it into them so that it's all balanced properly. Control+z until you get back to a spot where there are no errors and try again
just switched to vps :((
v
what did i just read... @lament rock this lad saying quickdb part of djs or wut?
No. Just it was recommended to them since it's beginner friendly
ah nvm.. he was comparin em
but either way... djs is efficient if u can read docs
and if you know how to not cache things you don't need
i mean if u are familiar with js then u wouldnt make ur own lib unless necessary... it takes a while
I ended up making my own lib anyways. But that's not a topic for here
¯_(ツ)_/¯
it is driving me crazy
but i have no clue what i am doing wrong
everything is connected....
remove the comma after search: 'California', degreeType: 'C'} and put a closing parenthesis then a semi colon
and also put a closing parenthesis before the semi colon on the search: 'Germany'
actually wait no.
you didn't provide a callback function for those so keep going back before you wrote those lines then do the suggestion I provided here #development message
if (a?.[0].toLowerCase() === 'string') ...
Unexpected token '.' (after "?")
What node version are you using
i haven't deleted anything
well just go back and rewrite the code but let your editor auto balance everything
i am back at my base code
but every time i try to add a new eather.find
it just gives me indented errors
ffs
It seems like you're deleting auto created characters that your editor is putting in to balance things properly. Don't do that.
If you type ({, the editor will create a closing ) parenthesis every time you type an opening parenthesis and a closing } curly bracket every time you type an opening curly bracket
inside of functions is no exception
okay i get it now
let me try that!
if (err) message.channel.send(err)```
this only returns me the value of Union Square
why is it not seraching for California?
Maybe you have to be more specific
throw err;
^
Error: Cannot find module '/home/pi'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)```
this is the error i keep getting when i do node .
show code
probb got the code wrong
const bot = new Discord.Client()
const db = require('quick.db')
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
db.set('userInfo')
let balance = db.get('userInfo.balance')
var economy = new db.table('economy')
economy.set('myBal', 20)
bot.on('ready', () => {
console.log(`Logged in as ${bot.user.tag}!`);
});
bot.on('message', msg => {
if(msg.content === "m-buy bucket of water")
{
if(balance >= 10)
{
msg.channel.send(`${msg.mentions.user.tag} just bought a bucket of water! taken away 10 credits`)
db.subtract('myBal', 10)
db.push('userInfo.items', 'Bucket of water')
}
else{
msg.channel.send("You do not have the sufficient amount of currency to buy Bucket of Water")
}
}
});
bot.login(token)```
where them ;'s at my man?
thats usually how your compiler knows when to break them 
it ignores whitespaces iirc
actually i might be wrong
k
it should run but i dont recommend it
ima check
you should still use them for sanity sake though
yeah i didnt think that'd be the culprit
also
you posted your token

go reset it
yeah
rn
aight
i did it anyway, but i changed the token
does anyone know how to make different calls to weather-js?
did u install all dependencies?

Hi
const Discord = require('discord.js')
const bot = new Discord.Client()
const db = require('quick.db')
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
db.set('userInfo')
let balance = db.get('userInfo.balance')
var economy = new db.table('economy')
economy.set('myBal', 20)
bot.on('ready', () => {
console.log(`Logged in as ${bot.user.tag}!`);
});
bot.on('message', msg => {
if (msg.content === "m-buy bucket of water") {
if (balance >= 10) {
msg.channel.send(`${msg.mentions.user.tag} just bought a bucket of water! taken away 10 credits`)
db.subtract('myBal', 10)
db.push('userInfo.items', 'Bucket of water')
}
else {
msg.channel.send("You do not have the sufficient amount of currency to buy Bucket of Water")
}
}
});```
its likely one of the consts
but idk which
k
can you try doing this:
did u change the code just then?
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
bot.on('ready', () => {console.log('hi');})
this
k
it doesnt show the message on startup lmao
cuz im stupid
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
bot.on('ready', () => {console.log('hi');})
bot.login(token);```
actually
no
bot
there
im used to calling bot client
k
weather.find({search: 'Union Square', degreeType: 'C'}, function(err, result) {
if (err) message.channel.send(err)
weather.find({search: 'California', degreeType: 'C'})
why is it only searching one city
and not the other?
you're only using the result callback parameter of the first one
how do i also use the other one/
similarly to how you have it for Union Square. Inside the callback function, you define err and result, you'd do the same for the search California but assign the callbacks to differently named variables
ooowh okay
so its discord being funky
do you have python2 and a visual studio compiler @royal laurel
im using disc js
idk, i think quick db uses some sqlite
Yes but since you're using an sqlite-3 wrapper, you'd need to build the sqlite dependency which building with npm requires a python2 install and a visual studio build tools install
but you arent calling it
What do people recommend for bot databases SQL or NoSQL?
What are you trying to get out of the database
he isnt
Just holding server preferances
as far as i know
this is all there is on the index
/home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/bindings/bindings.js:135
throw err;
^
Error: Could not locate the bindings file. Tried:
→ /home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/better-sqlite3/build/better_sqlite3.node
→ /home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
Something like Redis is really good but probably over-complicated for what you need. Something like postgres like Erwin mentioned or MariaDB would work well
is its some really simple stuff, use sqlite
also i'd like to mention that it was working fine before i imported quick db, i tested a simple command
type npm ci
k
if you get errors, you need to install python2 and a visual studio compiler. Not sure how you'd do that on a pi tho
yeah, i use it as like a server
i guess you could say
i do basically all my code on here because all it has is vsc
i might leave it here and work on it tomorrow
@lament rock so for example, changing result (for california) to result2? And adding that to the embed message?
hmm yeah
f (msg.startsWith(prefix + 'WEATHER')) {
if ( message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
weather.find({search: 'Union Square', degreeType: 'C'}, function(err, result) {
if (err) message.channel.send(err)
weather.find({search: 'California', degreeType: 'C'}, function(err, result2){
var current2 = result2[0].current;
var location2 = result2[0].location;
})
if (result === undefined || result.length === 0)
return message.channel.send("**Invalid** location");
var current1 = result[0].current;
var location1 = result[0].location;
const embed = new Discord.MessageEmbed()
.setDescription(`Weather Type: **${current1.skytext} + ${current2.skytext}**`)
.setAuthor(`Weather for ${current1.observationpoint} + ${current2.observationpoint}`)
.setThumbnail('https://media.giphy.com/media/CKsIi206Ntz4k/giphy.gif')
.setColor('#FF0000')
message.author.send({embed});```
is this good what i have done?
try it and find out. I can't read code efficiently since i'm on mobile
define it
probably right next to var current1 since the data structure should be the same
var current = result2[0].current2;
var location = result2[0].location2;
oh. I see you did define it. So you're probably trying to access it before it gets declared or it's locked to a different scope
the error stack usually has relevant info for you
i see
i had changed the variable name of result to result 1
and the err function wass still defined to result

C++ is never the option my friend, seek help
i am using javascript
Don't joke about that.
If you're tying to read variable[0] then you need to check if variable is undefined or not
guys please go to #memes-and-media
if (msg.startsWith(prefix + 'WEATHER')) {
if ( message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
weather.find({search: 'Union Square', degreeType: 'C'}, function(result1) {
weather.find({search: 'California', degreeType: 'C'}, function(result2){
var current = result2[0].current2;
var location = result2[0].location2;
})
var current = result1[0].current1;
var location = result1[0].location1;
const embed = new Discord.MessageEmbed()
.setDescription(`Weather Type: **${current1.skytext} + ${current2.skytext}**`)
.setAuthor(`Weather for ${current1.observationpoint} + ${current2.observationpoint}`)
.setThumbnail('https://media.giphy.com/media/CKsIi206Ntz4k/giphy.gif')
.setColor('#FF0000')
message.author.send({embed});```
this is what i have right now
use conditional chaining
i just can't f ind any problems
okay
the ?.
i have never worked with it before
you didn't pass the error param in the callback. It would go before the result so of course it would be undefined since the callback is casting the expected param error to result1
why even use call backs?
i removed the whole err function
older modules don't have promise support/implementations
use util to promisify it then
á
i am using weather-js
not always the best solution to promisify everything. If you're gonna use it multiple times in different files then sure. Maybe.
it'll be much cleaner than that callback hell you going for
the rpbolem is that i have never worked with promises
then start from there
learning promises is important in js
check sync/async, promises, and promisification

why not just learn ti and keep going? its not like promises are only sueful in that instance, if you plan on developing, you'll need to eventually get familiarized with promises
because sometimes
you are just tired of a fucking project
because you have been trying to solve the issue for 3+ hours straight
and everytime you find a fix for a fucking error
another one pops up
taking a break is a good idea but you should not give up in the face of adversity. If you have a goal, see it through and you'll be a better person by the end of it







