#development
1 messages · Page 405 of 1
ah ok
Anyone knows why would msg.guild.owner.id be undefined whereas msg.guild.ownerID is not with discordjs
And only in this server
is msg.guild.owner undefined ?
msg.guild.owner is null if the owner is not cached
you can do msg.guild.fetchMember(msg.guild.ownerID) if you need to fetch the owner
hm ok, I guess that explains it
it obviously isn't fine 
So you are saying the token is wrong???????
or the way you gave it to d.js is wrong
Probably.
@earnest phoenix if you want the owner id just do msg.guild.ownerID lol
??
It wasn't me that needed it.
And I needed something else not that.
did you install an set up dotenv ?
same
wat are you using to host ur bot?
also i think you just need to do
process.env.GOOGLE_API
use https://www.npmjs.com/package/telk-music it is gud
tbh my npm module is actually pretty gud

@lament meteor maybe you should just add the other packages required for you module as dependencies so they don't need to install them one by one xD
@fluid basin gud idea i will
And maybe use a class for you index.js
also sorry but i ran out of ideas on the msgs
as my bot uses the default msgs
aka @rough quest
moosages?
you can customize the addsong msg, play and loop
and it still needs fixing
if the queue is too long it wont fit the embed and error
google it.
This maybe? https://developers.google.com/youtube/v3/getting-started
@earnest phoenix
how do i make the dbl webhook for voting send a message to a channel saying Thanks for voting {vote.user}!
what library @earnest phoenix
discord.js
dbl.webhook.on('vote', vote => {
bot.channels.get('440847560190722058').send(Thanks ${vote.user}! just voted for jensbot!);
}); i tried this but it didnt do anything
for the webhooks
it didnt send the message to the channel
dbl.webhook.on('ready', hook => {
console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path});
});
it did log that message ^
??
Check if you set the link correctly over at DBL
where
Yeah so for the url you put in the address of your server and the link from the console
And authorisation is the password you'll need to put in your DBL function
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
Then once its done you can test it out using the "Test" button on the bot page
?
its closing the picture choosing part but doesnt change the icon..
ok finally i got the discord webhook to change icon
https://discordapp.com/api/webhooks/*******/***** is my webhook link
so what do i do for doing the webhook now
@earnest phoenix no u
@fluid basin
? wot
Make sure also you have port forwarded the port
port forwarded? why..
should be <something>:<port>
im not gonna port forward my raspberry pi ;c
stupid api..
It is how webhooks work... unavoidable unless you don't use webhooks
Users vote for bot -> DBL sends a request to your server(webhook) -> you receive the webhook -> process vote
Like basically when you start the bot it gives you an url, yeah basically DBL will access that url and pass you vote information when someone has voted
I thought about adding support for my webhook service but it would probably get too much traffic

It'd probably get more traffic than I'm willing to pay out of pocket to support
why though
You mean why would it get too much traffic?
unless you're getting more than hundred votes a day
My webhook service
as meaning allowing DBL webhooks to go through my service, so anyone can set it up. So sure, it'd handle smaller bots, but let's say I use it for Dank Memer, and some bigger bots that get a lot of votes
and then more bots
not worth for me to support imo
Yea but DBL webhooks like to be funky sometimes
¯_(ツ)_/¯
@earnest phoenix do u have a website?
no
what do u need the webhook to say?
Thanks {the voted user} for voting!
the webhook only passes userid.. botid.. type.. and query
i can set you up, so the webhook sends just the userid to a private room, then your bot can get the message.content and send it to a user
i tried a few different ways, couldnt get it to work, so i just used the php method
My bot dead help me out.
tragic mainframe pileup?
tragic
yes careful traveling the interweb at highspeed, wouldnt want to crash the bus
nah jk.. what happened
ok so i cleared 49/50 open ports on my router
all were not valid
so how do i do the vote
thing
the dbl.webhook.on('vote'
@fluid basin
i putted in the http://****/dblwebhook
into my bot's edit
didnt do anythng
@mental solstice
I couldnt get it to work for me. So i used the php method, had the userid sent to a channel, and had my bot grab the id and message the user
but i cant get it to send a message on the vote event
;-;
dbl.webhook.on('vote', vote => {
this thing
doesnt
do
shit
i want it to send a hook like
wat u mean
"Thanks A guy named Jens#9759 (in id) for voting!"
i did
the one on ur bot page
const dbl = new DBL(key, { webhookPort: 5000, webhookAuth: **** }, bot);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
bot.channels.get('440847560190722058').send(`User with ID ${vote.user} just voted!`);
});```
i did this
as said on the site
do you have.... the link in ur bot page?
@earnest phoenix do you have the link here https://discordbots.org/bot/314105524226490375/edit
the webhook link
of the discord channel yes
discord channel?
i also tried that "webhook running at" link
not a discord webhook 🤦
No.. discord webhook is not used for this
Webhook goes directly to your bot server
0|jb | Webhook running at http://*****:500/dblwebhook
wierd
link glitches
but k
goes to whatever the webhook URL is
??
not necessarily the bot server
when you set up a webhook, it sends a POST request to the webhook URL
wherever that is
can you stop a for loop in js?
cause ik you can stop a setInterval
break
const dbl = new DBL(key, { webhookPort: 5000, webhookAuth: ******** }, bot);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
bot.channels.get('440847560190722058').send(`User with ID ${vote.user} just voted!`);
});```
Uh you'd have to set a condition for it to stop, you might be able to use break on it
ah ok
i want that to do the webhook to my channel
where is your bot hosted?
on my raspberry pi
in your house?
i just forwarded it to port 5000 as the code did
you can still break within a normal for loop
its just the foreach loops you cant break from
so what then @karmic parcel
Return won't exit the current method/function
I'm pretty sure I've used return to stop a for loop plenty times
which lang are you talking about
Unless I did use break 
You know what I have no idea
I should probably go look at my code again to be sure
return puts an end to the current function, and if it's in a loop, that loop would end right there [in JS]
yeah
I was right then
https://tweetcord.ratelimited.today/46d55a.png not about this
@karmic parcel ??
lol that out of context
nope
Totally don't confuse that
it says testing complete it could take a few seconds
ah, I didn't see @elder rapids
nothing goes to the channel
do you get a vote event at all?
idk
console.log the vote before you send it
do i need to get someone to vote my bot rn?
no
testing works fine
Jens dm me if u dont figure it out, ill host a php file that will send the users id to your discord webhook.
0.0.0.0:5000 is the url tho
that's interesting
thats what it logs..'
Wait are you using 0.0.0.0 on DBL?
ok just making sure 😂
does the lib not allow you to change? riperoni
idk?
0.0.0.0 is a bind all
yeah
Shouldn't really matter
soooo
but why not just use localhost?
what's your bot?
jensbot
nothing happend
tbh
no console.log
no sended message
dbl.webhook.on('vote', vote => {
console.log(vote)
bot.channels.get('440847560190722058').send(User with ID ${vote.user} just voted!);
}); nothing of these 2 did something
your pi is port forwarded for 5000, right?
your router allows it through?
.. lol i just helped you with all dat shit
Ye forward just like your mc server
but then your raspberry ip
yeah i did
so as long as you set it up through your router you should be fine, and the webhook URL on the bot page should link to your IP address of your home
o
lol u used local ip?
so the ip i set in port forward xD
no
..
your ip from whatismyipaddress.com
you need to literally google what is my IP addess
Your ipv4
OH OK
you need your household external IP address
Oh dear lord
internals won't work for external calls
I GOT THE IP
You didn't use your public ip
Or did k
yeah so the url on the DBL page should be http://<public-ip>:<forwarded-port>/<path>
gg ig xD

Rip lol
thx lmfao

tho it doesnt send as a webhook
?
wat

whatchu mean boi
Then code it to be that way
yeah
hmmm
you're just being dumb tbh
XD
... discord webhooks =/= webhooks in general
You need to send an embed boi
could i also get the user's name/tag from the id via bot.users.get
or what would happen if someone voted and that isnt in ANY server my bot is in too
less moving parts = better
not just a message
how can they vote and not be in here?
well discord webhooks =/= dbl webhooks
Yeah, but you just want it in an embed, I'm pretty sure is what you're trying to say
dbl should just allow discord webhooks to be called
^^
tru
not everyone wants one
¯_(ツ)_/¯
Give ppl a choise
= more work
So they can do both
not everyone, but make it so its like a switch xD
like
"Discord webhook? yes/no"
^
we get it..
unwarranted
mk
do it yourself
like you are now
nibba
look up the lib you're using
and look up how to do embeds
ez
gg wp
But like some ppl dont like to forward and shit (i know its ez, but for newbies its harder)
tbh someone could make a proxy to convert to discord webhooks
setting up a dbl -> discord webhook bridge isn't hard either

you could put it on heroku and be done with it
yuuuupp
well first i gotta get access to the dbl api before i can even do taht
no you don't
Pls its been 3 days accept my bot xD
well its easyer for testing things to have access
things rarely work the first time xD
I mean the format should be specified in the docs, you could implement it without the api
it is specified
meh first i want ppl to acutally wanna use it before i randomly make it
XD
where can I learn to code nodejs free? my bot is just coded from what I picked up while coding it..
nodejs is javascript, so you wanna learn js
ik its javascript, I just dont know where I can learn it free..
thanks, that looks great :D
how would i "fetch" the latest message from a channel
depends on your lib
discord.js
Is there some way to make your bot link to the website? Like so if someone upvotes it, the bot will give them some extra commands etc
you get me?
you can't set a redirect or anything like that, but you can make your bot DM the user who voted with a link
register a webhook
so making it clearer, i want to get the latest message in a channel, for a command. how would i do that? my lib is discord.js
Best is to ask in discord.js discord
.then(message => console.log(message));``` Something like dis
no
oof
it has some monadic operations tho (map, filter, flatMap, etc)
Ok anyone know how to fix this bs?
Yes.
also looks like you have a directory issue
are you pulling token from a json?
hmmm
Can send you a pic of my files if you want.
why do you choose an env?
The .env file.
If you really wanna use env vars then you picked the wrong lang
Me?
yes, you
ye
Ok.
use json
So how do I transfer it to a json??
Just make a configfile
config.json?
its in most bot tutorials
const config = require("../location/of/config.json");
then for the var use config.token
and write this in config.json
"token" : "xxxx"
}
This??
Ok.
create a .json file
{
"token":"fuck"
}
and you get it in your bot with
const config = require("path/to/config")
It is a file right?
yes
name it config.json
I did.
open the file
under that array put a token field
No
no, add this after the last ]
on a new line
"token":"urtoken"
and put an , after the ]
remove the { & } you put around
no
Ok.
??
type this
Where do I type that??
@modern garden rm -rf / doesn't work
you need --no-preserve-root
oh lel
...
NO
im leaving
what OS is your server running
Oh umm
i dont even know how defaq this boi got a linux box running
Lemme check.

Windows server?

Are you trolling us?
ok
Sorry this isn't really my thing.
windows
fucking
server
and here I thought you were running linux
that had to be a bash terminal
is he running cygwin?
unless you for some reason made a /root
neh he just googled some random server os
No.
but why would you then put it in /root
idk why you would sudo node
I haven't downloaded sudo.
installed*
some distros dont have sudo installed lol
FUCKING FUXK
wait are you serious
I think hes trolling xD
some distros don't have sudo?
you just have to apt-get install sudo
or first install apt so you can save 4 keypresses each time you install something xD
One sec something happened to Putty.
oof
Ok so what should I type??
cat /proc/version
In PuTTy?
yeh
YES
@shy verge nice caps
ok it's Ubuntu server heh
cd into bot directory
Ok.
wait no
cd app
ls
the fuck
WAT
ubuntu for windows?
this boi
Oh.
like
I thought you put 1

just copy next time
Sorry I haven't had sleep for 2 days.
Then sleep
markdown is weird
oke finally
echo "{"token":"YOUR TOKEN"}" >> config.json
replace your token part obv
And close that json file you were editing in winscp withouth saving it
So DO NOT save it
Ok now close the config.json without saving it?
Yes
Can I ask why your going though Ubuntu shit when the problem is about a token
I already fixed the token.
ok
did you run this command?
echo "{"token":"YOUR TOKEN"}" >> config.json
Yes.
cat config.json
You want me to type that in?
Or just paste it in?
do whatever
It sent what was in the config.json.
send us
screen pls
oh shit { is wrong xD
Erm.
dm it
Or if you dont trust him send it to me xD
I'm just gonna fix the config.json
Eh I got a backup so ok.
ok
in the meantime while @shy verge fixes your config, do this
edit your bot.js
Add this to the top of the file
const config = require("./config.json");
Just saying you should probs learn how to do json
I already have that in my bot.js
DELETE THAT LINK.
No
I hate w3schools for some reason.
No
we can see
They actually have good tuts
oke, now where you have something like bot.login('token env thing') replace that with config.token
does single quotes work in json
meh just do doubles
Ok.
Eslint prefers singles
singles should work fine
doubles is just more consistent xD
i wonder how Savitar has bot dev role tho
Honestly idk what to use double for if eslint tells me to use singles for strings
This?
^
Well i just assumed you didn't
if dat @shy verge boi is done try starting your bot
Or no?
Yes save
The JSON standard requires double quotes and will not accept single quotes```
oh lool
Not yet
Then php doesn't care
echo is being a bitch
just use nano
many parsers support non-standard features
such as comments, single quotes, missing quotes, etc
also
echo '{"token": "xyz", "k": "v", "array": ["v1", "v2", "v3"], "object": {"k": "v"}}' > file.json```
would work
If im talking to a mod anyways, do you happen to know the bot accepting queue lenght?
more than 2 less than 100000
that's all i know
done
oke now start dem bot
Why is it taking soo long to save??
@shy verge Where do I paste it???
if it's taking long to save anything would be affected
in a dm
Probs his winscp session timed out
nano into the config.json I made for you
But does he have nano if he doesn't even have ls xD
he does
He just gave me his token


Like, find other ways pls
Just use the nsfw cmds.
fuck I can't paste text into the ssh client
right click
Shift insert.
for putty atleast
Shift+insert.
Or send me login and ill do it
same
SAME?!
@shy verge What device are you on?
I think hes on a phone
Android, using juicessh
Ah nvm then.
termius >
just send me logins it will be faster...
Ok.
Ok.
@earnest phoenix Android is being a bitch, you'll have to paste token
How??
sorry about thay
I can put it in
Just also dm me the token
where is dat config.json?
kden
ill type it then
ah found it anyways
bot works now?
when sharding can a bot still access to every guild/user/emoji with d.js ?
Yes
Sharding only controls what guilds events are sent where
And then DM is always shard 0
thk
How do I start this process?
??
Does anyone's bot store per-guild config?
I'm trying to figure out an efficient way of doing so (not json which I currently have)
In my case, database wouldn't be the best option either
you could use a key-value store db
store guild configurations as guild ids mapped to json strings
assuming the guild configurations themselves aren't like huge or anything
that's perfectly scalable isn't it
Why are databases not working for you?
that's more or less just mongo's model, right
I've never use it
redis is a key-value store
I'm working on a library that acts as a wrapper for the discord client, since databases use specific libraries i'd have to make functions to connect to the user-provided functions and all that
so like for mysql the library user might use some library
Ah, depending on the language (I assume JS) you could just make abstractions.
the repository pattern with interfaces for example
would it be a good idea to stick a specific database library to the framework I'm building and make the user use that one?
no
No, hence the abstractions
hm
eg js get(id, key) { return query("select ? from x where id=?", key, id) }
the user could build his methods from just that get and set methods provided by my framework
and I could have the liberty of using a database
if the framework provides get and set it'd be tied to a specific db/whatever
yea
I know what you mean, but truly the best way to store data would be in a database
what other option would the user prefer, maybe json but that wouldn't scale
yea
unless user can provide get/set
what if I did both
that the user can provide his get and set
or he could use my framework's
can someone help me with fetching a message from a channel in js
current code
if(msg.author.id != "439373663905513473") {
msg.guild.channels.get("440160451829956609").fetchMessages({ limit: 1 })
.then(message => msg.channel.send(message));
}
if (msg.author.id = "439373663905513473" && args[0]) {
msg.channel.send("Sent update log!")
.then(msg => {
msg.guild.channels.get("440160451829956609").send({embed: {
color: 0x6E00DC,
description: `v${package.version}\n` +
`\`\`\`diff\n` +
`${args.join(" ")}` +
`\`\`\``
}})
})
} else {
msg.channel.send("What are the updates? 🤔")
}
no
it doesnt return the text
how do i get the text tho
are you on stable
yeah
message.content
or my dick

use go
You dont have the role so 
I am waiting for the submit to be processed

tAkEs FoReVeR
eh
it depends
my first bot got approved in 5 hours
and then I lost that account when I tried to set up 2fa on a school chromebook
it's been about 4 hours I believe
@round ravine, my current bot, took about a day
Some have taken a week or so
it depends on when you submit
If you submit before the weekly pile of shit floods the queue then it'll be quick
But if you miss that opportunity then it could take a day or longer
Great, I'll feel at home.
currently coding my bot, happy to have finished a basic setup
decent configuration commands and the such
let crown = msg.author.id === msg.guild.owner.user.id ? ' 👑' : '';
the aim of that code is to make crown have a crown if the msg author owns the server, and an empty string if they don't, but it doesn't work. all members of my server are getting it, why exactly is it not working?
cant you just use if statments?
isnt there an ownerID property on guilds? use that instead of owner.user.id
its a thing yeah, that doesn't effect the codes working ability though 🤔
telk, i want to do it that way and keep it one line :P
well i dont think u can rlly do it
const crown = msg.author.id === msg.guild.ownerID && '👑 ' || '';
You get that bc the test you do is if (var) which returns false only on some rare cases like undefined or null or empty type (like 0)
ternary operations should work just fine
@toxic oracle instead of cond && true || false, I'd suggest using builtin conditional ternaries (cond ? true : false)
Also cond == cond&&true == cond &&true || false
that's the first time I've seen cond && true || false
Can anyone explain what this error means??
Also nice pls_learn_linux right there 👌
Lmao
Also please don't let your token be shown
My token isn't in bot.js
If you see can you tell me?
Ok.
So you wanna see all of it?
Ok so maybe get rid of the dot
And the slashes?
/cmds/ only
...
Ok.
Maybe it is relative already
Still doesn't work.
Error?
put your code in a website such as hastebin.com, screenshotting is painful
Just do /root/Savitar.../cmds
?
I really don't think you need the slash at the end
Ok.
WherWhWhere??
Line 30
Where?*
Where the problem exists...
fs.readdir(' __dirname + '/cmds'', (err, files) => {
if (err) throw err;
Where?
Can you fix that?
No commas....
fs.readdir( __dirname + '/cmds', (err, files) => {
if (err) throw err;
You're welcome
😃
How would i get ram usage in js?
process.memoryUsage().heapUsed
Thanks senpai
Its in bytes btw





