#development
1 messages · Page 1212 of 1
.join(%20) something like this
you can use mongo atlas if your willing to learn mongo
Don't know if it will work
.join('%20')
i found this https://corona.lmao.ninja/v2/states/${country.replace(/\s/, '%20')}
urlEncode() is a thing btw
or that
or you could use encodeURI
Just use a npm package
wait, how to connect database to a remote database?
encodeURI is what i meant
hmm oke lemme test it thanks guys
@thick gull
@sweet kestrel get a database somewhere, use the ip as target, ezx
which is far more reliable
^^
ok
same way you had your database locally, just change target to their IP/domain
;(
theres literally no difference
you just changing ip
if you can’t understand that why make a bot?
oh
@misty sigil cool gamer :sunglas;
wha?
you need message.author.tag in d.js

and also — is that a message logger
looks like it
its a thing i made called quick emoji
No
its not like messageDelete event exists, right?
it doesn’t

shouldn't it be like (`pog pog ${pog}`) or ('pog' + pog)
:(((
it works for embed and it didnt give any errors so
@earnest phoenix we told you, join args[1] and args[2]
your only using args[1]
which is the first one
args is being split by spaces
how
.join
or replace content
yea
im replacing it
replace(prefix+command+space, '')
https://corona.lmao.ninja/v2/states/${country.replace(/\s/, '%20'
on message content
country is args[1]

😔
bruh im lost
You need args[1] and [2]
yeah
you trying to replace spaces on country, which is ONLY args[1]
and no spaces
args[1]%20args[2] something like this
but would suggest dynamically doing it
but its being SPLIT on spaces to make args
args[1]%20args[2} and where i put this

ok ok
args.shift().join(" ")?
tell me
look
args.shift().join(" ")?
@misty sigil not working
If you're trying to add user input in the URL, I recommend you use encodeURI
Did you include the ?
@earnest phoenix
i send
hello world hi
@opal plank hello?¿
@sudden geyser thats not the issue currently, he is trying to get info on args[1] and [2] when the target is only [1]
thats args[0]
if you did I’m honestly going away and out of this server never to be seen again
what is args ?
arguments
it’s an array
^^
where did you get the args code if you dont get it 😔
arrays have indexes
what is in that array @earnest phoenix ?
im diying
you lacking too many fundamentals of js
you shouldnt be doing a bot without knowing those things
those are the most basic things you need to code
what are objects? what are variables? what is an array?
it seems like you've been copying code thus far
which wont get you far
i didn´t copy, trust in me, i forget how args work

i get the args code from my old bot
@earnest phoenix awnser what are objects? what are variables? what is an array?
ok
mdn time
brrr mdn
i still have no clue on how to filter the countries by command
?
so if you use !sunnyweather, you get all the countries that have sunny weather atm
Sa
(not all, like 20)
i already have the code
Türküm
@fervent fable english only
A variable is an element that is used to store and refer to another value @misty sigil
just need to filter the objects
@opal plank why ? Nooo , ı am turkısh
A variable is an element that is used to store and refer to another value @misty sigil
@opal plank check if that’s taken from mdn

i still need a solution
to?
i cant find anything on this
@earnest phoenix a variable is a thing you declare, be it with a value or not
message.author.tag?
let me send it again
you arent combing the string and tag right
a variable is just a memory variable thats declared, assigning it comes after
but you technically right, you can reference stuff
what are objects? what are variables? what is an array?
@opal plank
- {foo:"bar", bar:"foo"} (a way of storing things)
- A defined thing (e.g. let a; they don’t have to have data)
- A list of things
or `test ${variable}`
@earnest phoenix in my example Hello world hi what are the args?
@white vapor do you have a solid understanding of JS
because it seems you dont know how to put variables in strings 😔
no not really, ive just been getting stuff from documentation and tutorials
boys
in my example
Hello world hiwhat are the args?
@opal plank I know the awnser and I have the urge to say it
please learn the base of JS before making a bot
how do i filter my info i scraped from weather-js.
so if i use !weather sunny, it returns countries with sunny weather
@misty sigil i know you know, let the fella answer for themselves, otherwise its pointless
kinda a bit too late because its literally finished
read the introduction here
I want to see what they say
i dont mind if they are googling it, as long as by the end they know what it is, its fine
they wont get far copying code
kinda tempted to make a bot just copying code and see how far i can get with it just to have fun kekw
my bots finished im just trying to fix things
wh
just +
since i dont know py too well, i might try that
no-code challenge
you cannot do anything other than change variable values
you observed what the code done
yea
ok @opal plank do you want to race, first to 20 servers owned by completely random people with copied code

hell yeah lmao
bet
@thick gull i mean... all my code is from stackoverflow with the variable names change
i guess there isnt much point in trying it if people done it unironically lmao
guess they just really didn’t have a fucking clue
can anyone point me in the best way of making your bot send a message upon joining a server
basically im not sure how to make it find a channel to send the message in
but how can i get a channel id if the bot has never joined the server
then you cant
exactly
you arent suppose to be getting your hands on servers that you dont have access to
wdum?
he said upon joining
so once the bot joins
oh
once the bot joins
iirc guild.send()?
send the help embed
then once it join it should cache the guild
No need to send a help embed
iirc guild.send()?
@thick gull meant this
i looked into it a while ago but never really used it
is that a thing?
if they’re interested, they will get the help themselves
bruh
guild.channel should exist
PLURAL, not singular
thats your opinion lol
no
@slender thistle yes indeed
@charred geyser https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584#file-discordjs-cheatsheet-js-L138
no need to shovel the embed down their throat
send() is a method from Channel>
they will use the help command themselves
guildCreate
for-loop over guild text channels, for each element check if bot has permissions to send a message. If yes, send and break the loop, otherwise, continue
yeah i have it inside the event guildCreate
!help
check @ everyone perm
incase your bot has high permissions
say your bot has admin perm(which it shouldnt), it may post on announcements channel or somewhere it shouldnt
this is what i was using
prob best to check for @ everyone permission to send
let joinChannel = "";
guild.channels.cache.forEach((channel) => {
if(channel.type == "text" && joinChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
joinChannel.send(BotJoinMessage)
oops
lol
BotJoinMessage is already defined
wait what
guys
where even is that nested on?
we told you
to do it free
you cant host a db on heroku
you dont have database in code
😦

😦
im not sure what hes doing
sql is stored locally, its not related to the code
the code is just what sends/reads from the db
hes trying to use it on a heroku host
how to do it again? lol
^^
where even is that nested on?
@opal plank i have ./events/ setup
or change to a proper vps
@charred geyser which language is that?
d.js
yea
I mean, I have an admin DM-only command that tells me something like this
<redacted>
** BOT-TO-USER IMBALANCE **
** BOT IS ADMIN **
Admins: <redacted>
Total Users: 168
Users to Bots ratio: 98.21 %
Real Users: 3
Bots: 165
cause its like
Useful for making my bot leave bot farms
that'll send message on every channel it has perm
Useful for making my bot leave bot farms
@faint prism wait what is a bot farm
@faint prism im using something similar
@faint prism wait what is a bot farm
@thick gull Looks like it
cause my bot got added to a server called "bot overtaken" within minutes of being added to a list
I will search host up
if guild has less than 10 members, and doesnt user 5 commands in the span of a week, nor have 20 messages in the span of a week, it auto leaves
okay boys be b ack in like an hour spanish clASS
gl
@charred geyser you could get a loop and get first one that matches
that isn't the best idea tbh, it stops those who actually want to test your bots before using it in their servers
also should check for @ everone rather than your own perms
@fluid basin a whole week to test the bot?
permissions isn't really a problem
is that it?
instead of doign localhost you do <ip>/<website>
ok
how would i make it find the first text channel regardless of permissions? @opal plank
I'm talking about the member min part
also heroku is not cpanel and does not have cpanel
bruh ok
bruh.
@charred geyser doesnt cllection have a first() method?
bruh.
@charred geyser What, you don't do that?
i do but i close it often
lol
and before you ask, no, im not running the bot on VSC
its running on a proper vpn
lemme check something
lol
.name?
as i thought, collection does have first()
yea
just needed something to output that isnt a big ass object to hit 2000 char limit
oh ok
then use that
cause message would be undefined in a guildCreate
oh
check for type
how do i embed msgs?
that'd work
ok neat so i want like
what's diffence in js of === and ==? is === less buggy
3 =
btw
equal type
not just equal
equal causes bugs sometimes
just like var
=== means its the same and the same type
you arent meant to multiply string vs number
correct, equal TYPE
by the same i mean equal
checks type too
yes
guild.channels.cache.first()
kk
so basically "1" == 1 returns true, "1" === 1 returns false?
@restive furnace correct
how would i put a if statement into that
i mean you could look for a channel called general first before
loop with for instead of first()
const channel = guild.channels.cache.first();
if(channel.type === "text") {
joinChannel.send(BotJoinMessage)
}
incorrect
how do i embed images?
discord py
Does anyone know any good Python formatter plugins for Sublime Text 3?
@charred geyser
let channel:<Discord.TextChannel|undefined>;
for(let c of guild.channels) {
if(c) return;
if(type === 'text') channel.push(c)
}```
you can do more logic below like checking for @ everyone permissions in that channel

<type:another_type> is a TS 4.0 feature?
😦
i downloaded ts 4.0 but i havent fully checked it yet
k
what happened to guild.channels.cache.first();
how do i embed an image?
nothing, i told you it will likely get category and its bad to use in this case
i provided that example so you'd learn from it, not copy it
specially cuz thats TypeScript, not Javascript

you can declare variables without assigned values
you probably should learn basic fundamentals of JS first? [seasnail]

^ only TS has types
^^
lol for some reason you are able to invite bots to listen along to your spotify
nice 😄
beuh
TypeError: Cannot read property 'cache' of undefined
i just shouldn't use that should i
check if whatever you trying to get is there
i litterally had it workiing
becuase i was using v11
and this worked
let defaultChannel = "";
guild.channels.forEach((channel) => {
if(channel.type == "text" && defaultChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
and then it would just defaultChannel.send
upgrade
i did
v11 is deprecated now
yeah i upgraded and started using a database
yeah now it is
and why assign defaultChannel as a string, and then assing it as Discord.Channel?
instead of just guild.channels, v12 implements managers, so you need to use guild.channels.cache
(ik this isnt TS, bt still)
yea
Any ideas on how to fix this?
npm rebuild?
try uninstalling and reinstalling the module
Tried npm install or npm rebuild, didn't work
try uninstalling and reinstalling the module
@sonic lodge Also tried, nothing
interesting
so i can use for(let c of guild.channels) { if(c) return; if(type === 'text'){ channel.send(BotJoinMessage) } }
but i need to define channel as something
i think
just get guild default
what
the system txt channel
and you literally assigned the channel as c.
guild.channels is a collection, right?
yea i guess so
when you iterate it using for of, c will be an array
Not Erwin wrote it 
for(let c of guild.channels) {
if(c) return;```
Won't that return if it isn't null..?
Did he forget the logical not ! ?
he just copied the pseudocode
if (!c) return; ?
Well think about it
what would that do?
If c is null, it would return
Is that what you want?
Well, you wouldnt want it to be null and try to do something with it, right?
yea
Lol, pretty much
I can't think of another scenario where it'd be null
Maybe in a DM
yea
wouldn't the collection just be empty
good point
It may never actually be null
anyway
its better safe then sorry
so for the next bit i want to check if the channel type is text
🤷♂️ wouldn't hurt
and if it is i want it to send the message
guild.channels will give all the channels right?
so i need to pick a channel
which would be guild.channels.cache.first()
right?
I believe so
so would i let channel = guild.channels.cache.first()
Mhmm
let channel = guild.channels.cache.first();
for(let c of guild.channels) {
if(!c) return;
if(channel.type === 'text'){
channel.send(BotJoinMessage)
}
but i dont think that will work
you aren't doing anything with c
oh
That for loop is unnecessary in that snippet lol
how else would i find the first channel
you aren't doing anything with
c
@sonic lodge Correct me if I'm wrong but isn'tfisrt()the same asguild.channels.cache[0]?
guild.channels.cache.first(); apparently returns a category
no
well, ig one would be nullable, the other throws an exception if the array is empty
guild.channels.cache[0] would be undefined
i do this
let link = client.generateInvite(["ADMINISTRATOR"]);
console.log(("INVITE: ")+(link));```
i think
something like that
it generates a invite with admin permissions
oh shit
it'd be a method
oh d.js has a bot invite generator? neat
I've always done:
discord.com/oauth2/authorize?client_id={clientId}&scope=bot&permissions=0
how do i add commands to cogs?
So i get this when trying to install color-thief, any ideas about what does this even mean?
weird lol
try going into node_modules/color-thief
and edit its package.json
to use canvas 2.6.1
it might be in node_modules still tho
use -s
ok
What does that flag do
i'll accept that as a solution because tim
-s / --save
tim how do i make the bot send a message upon joining a server @quartz kindle
it worked in v11 but now that ive upgraded it just doesn't
I wanna play a music stream 24/7 in my channel, but FFMPEG stops playing 1-12 hours later
I’m thinking of using auth with my discord bot to fetch global guild counts and other stuff, Except I don’t know what to do first, I’d assume I need to give my bot scopes etc, But what would I do then? I’d guess id make a “auth.json” and require it, And shove something like this in auth.json (On a phone and don’t have code blocks, sorry)
{
client_id: 'bot id',
client_secret: 'client secret',
grant_type: 'authorization_code',
redirect_uri: 'redirect url with permissions api calculator or smthin',
scope: 'the scopes',
}
but like json formation, could someone explain setting up auth to me please?
@quartz kindle Tried the save flag but it's not found in the node_modules folder
Does anyone mind walking me through css for my bot’s description?
on the discord server list?
you can't do it for servers iirc
embed=discord.Embed(colour=self.random_color, title='Have any ideas? Leave them in our discord!')
embed.set_image(submission.url)
await channel.send(f'{embed}')
this is wrong
but like whats wrong:
i want it to send the embed with the picture
set_image(url=submission.url)
@slender thistle can you help me make my bot send a message upon joining a server
Send code
1 sec
@charred geyser on memberjoin event, member.send
guildjoin
yeah but
Oh it was you from a few somewhat minutes ago
Tbh I'd suggest not doing it at all
it worked in v11
rip
in v11 i was able to do let defaultChannel = ""; guild.channels.forEach((channel) => { if(channel.type == "text" && defaultChannel == "") { if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) { defaultChannel = channel; } } }) defaultChannel.send(BotJoinMessage)
0Exe#9581
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
wait you can store multiple objects in the same JSON file
{
"lmao": "lmao"
}
{
"lmao":"lmao"
}
doesn't look valid JSON to me there are no commas between objects
||@quartz kindle is my crush||
If you need 2 separate JSONs in one file, you'd have to make keys for each one or make it an array

If you need 2 separate JSONs in one file, you'd have to make keys for each one or make it an array
@slender thistle discord markdown said it is correct syntax
lol wut
I wouldn't rely on Markdown highlighting
no i dont think you can
you can however
yeah it's big brain time
{
"1": {},
"2": {}
}```
or use an array
Hi

or that but thats no fun shibaco
that's not what i said
{} alone makes a new scope
k
seriously need to start reading MDN and be a real man rather than follow grasshopper app (BY GOOGLE) and still remain confused
why did i quote that message
{
"1": {"foo": "bar"},
"2": {"a": "b"}
}``` would work if my json knowledge is good enough
what about it?
yea what bout it
You can see that it was highlighted in the browser too but didn't work
It's a javascript console. It parses json.
[
{
"lmao": "lmao"
},
{
"lmao":"lmao"
}
]```
k
So can someone walk me through using css for my bot description?
I wanna customize the background of my bot
creating new client objects on each command usage
Again, bad practice
but I'll just ignore that from now on
So can someone walk me through using css for my bot description?
@steep shale uhhh https://w3schools.com/css
Are you sure the cog is being loaded
I can't remember if non-certified bots are allowed to use style tags (I don't think so though). I'm pretty sure you can use the style attribute though.
You can also use markdown.
<h1 style="asjkfsj">Bot name</h1>```
JS is restricted for certified bots, HTML and CSS are not
So html <style> style { style1: true; } </style> is allowed?
Oh. I thought both script and style tags were.
How can I get if the user is boosting and since when? (discord.js v12)
Which library
discord.js v12 (forgot that, sorry)
Sorry Im only discordpy
Okay, no problem
wrong url
How can I get if the user is boosting and since when? (discord.js v12)
@fringe axle <member>.premiumSince
Idk if its like py but use a bool
probably premiumSince will return 0 if they are not boosting
dont take my word for it though
just a guess
it will
how do i get my bot to say watching
What library
Okay
wait wrong server
{ type: "LISTENING", name: "Hi", url: null } for presence object iirc
Damn everyone does js
yeah
Am i the only one here who uses py
my bot is for music so im not sure how to do music bots in py
Using lavalink
oh
because it's probably more beginner friendly (and more error prone cough cough)
js more beginner friendly?
nah
It looks complicated when I saw some code from it
Im used to py
Is there a reliable way to get embeds from a message that your bot just sent?
It seems really unreliable
what do you mean by get
Ok
To give info to people
Im used to py
yeah cause, you're used to py, but for beginners, the syntax might look easier, or who knows ¯\_(ツ)_/¯
ohj
Because they're way too big
But we do want image embeds to show up if we linked an image
oof idk how to do that
I'm struggling to find a reliable way to do this
Like everything I do that works is a hack
Currently I get the embeds, filter for image embeds, suppress embeds if there's non-image embeds (embeds.length > imageEmbeds.length), and then edit the message to re-add each image embed
But sometimes it just returns an empty array for the embeds...
So some of the time it won't remove the embeds
yeah i dont know that deep into it i think you should ask in discord js server
😢
i cant post link but you should be able to ask there
just a warning some people there are EXTREMELY good at it and might seem a bit rude
but they will solve your issue 100%
i expect
const user = message.mentions.users.first() || message.author;
if (!user) return message.channel.send("Please specify a user!")
const avatarEmbed = new Discord.RichEmbed()
.setColor(0x333333)
.setAuthor(user.username)
.setImage(user.avatarURL);
message.channel.send(avatarEmbed);
TypeError: Cannot read property 'users' of undefined
what am i doing wrong
oh my bad lol
np
i guess its something to do with message.mentions.users.first()
is that not a thing in v12?
or should it be users.cache.first
no?
what is wrong then
user.cache.first() probably returns the clientuser iirc
TypeError: Cannot read property 'first' of undefined
i guess i will just thought it would easier to ask here
Then message.mentions is not defined.
const member = message.mentions.members.first()
@charred geyser ^^^
you need to get member from all mentions
so members not users
TypeError: Cannot read property 'members' of undefined @earnest phoenix
hmm show what did u typed
this is my code
const user = message.mentions.members.first() || message.author;
if (!user) return message.channel.send("Please specify a user!")
const avatarEmbed = new Discord.RichEmbed()
.setColor(0x333333)
.setAuthor(user.username)
.setImage(user.avatarURL);
message.channel.send(avatarEmbed);
THEN UPDATE
i can change that but thats not the issue
npm install discord.js@12.x.x
First then we will see what is the problem
i already updated
i made a bot that does absolutly nothing
@charred geyser did you mentioned a user when testing ?
now test it again
hmm
console.log(message.mentions) ?
@charred geyser and try without
|| message.author
ok
nope TypeError: Cannot read property 'members' of undefined
console didn't log
thats console
const Discord = require("discord.js");
module.exports = {
name: "avatar",
category: 'general',
description: "Displays the mentioned users profile picture in an embed.",
usage: "avatar \@username",
run: (message, args, users) => {
const user = message.mentions.members.first();
console.log(message.mentions)
if (!user) return message.channel.send("Please specify a user!")
const avatarEmbed = new Discord.MessageEmbed()
.setColor(0x333333)
.setAuthor(user.username)
.setImage(user.avatarURL);
message.channel.send(avatarEmbed);
}
}
thats the command file
the whole thing?
yes taht file
this is the main bit
message.js
const prefix = settings.prefix;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
if (!message.member) message.member = await message.guild.fetchMember (message);
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command = client.commands.get(cmd);
if (!command) command = client.commands.get(client.aliases.get(cmd));
if (command)
command.run(client, message, args);
the rest is just for mongodb
bruh
command.run(client, message, args)
so it will be
run : async(client, message,args) => {}
@charred geyser ^^^
._.
in the command?
in ur avatar command
ok
btw this is wrong
if (!message.member) message.member = await message.guild.fetchMember (message);
[20:29] seasnail: %avatar @pliant gorge
[20:29] BOT█▀█ █▄█ ▀█▀: Please specify a user!
const user = message.mentions.members.first();
console.log(message.mentions)
if (!user) return message.channel.send("Please specify a user!")
const avatarEmbed = new Discord.MessageEmbed()
.setColor(0x333333)
.setAuthor(user.username)
.setImage(user.avatarURL);
message.channel.send(avatarEmbed);
@charred geyser console.log(args[0])
uhmm
wut
why it is red ?
console.log(args[0])
@charred geyser
instead of console.log(message.mentions)?
yes
hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
hi
hi
hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
brb]
??
hi anyone know whats this
(node:180544) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
@green bison show code
Are you using “client.on” for all of your commands?
yes
To fix your issue use a command handler, or all in one client.on event
@charred geyser wut happned ?
finally i think i stabilized the cache enough

very little ram as well
take that d.js

happy time?
happy time
@opal plank bruh how ur bot is so big ?
This rn is just stress testing, my numbers a bit lower than that
yes
YOU LIER
no, theres 1000 streams rn with it
wut
yeah
so it is real 1000 stream
yes
nvm i will go sleep bye

@green bison
still need help?
its easier to just do
import random
message.channel.send(f'{random.choice(myquotes)}')
how do i embed images?
@earnest phoenix that isnt js is it
its python
legend's in js 
its python my g
im not
this is what Legend sent
did not scroll further than that, but i assume is their's, and this is js 100%

@opal plank what server is that from 😁
@charred geyser ?
:02pat:
@opal plank
heroku just shuts down after no actvity
well is there a way to keep it online even if there is no activity
v<@&751140053933228104>
without breaking Tos? No
that sucks
listening to bot messages requires a constant socket connection
actually
wait
i dont think heroku needs uptimers
only glitch
i already asked them, glitch and rep.l before to once and for all confirm wether discord bots are allowed on their platform
who is erwin
Not me for sure
.setAuthor(user.username)
.setImage(user.displayAvatarURL);
#HAxxd
lol
after displayavatarurl u need to put ()
and username?
uh
depeneds on who u want the name of
though i have a feeling i said that before and there was one instance in v11 where it had an avatarURL property in it
but user.username gives undefined
So to change my bot’s background pic is this how you do the html?
yeah
tha command is %avatar @granite pagoda
It goes ...url("url-link"; and then the }
show the full code
of the entire module or just what is run
Oh I forgot the )
<html>
<style>
body{
background-image: url("https://images.app.goo.gl/56jXM17CEnESWa927);
}
</style>```
Like that then?
oh sht forgot the "
<html>
<style>
body{
background-image: url("https://images.app.goo.gl/56jXM17CEnESWa927");
}
</style>``` still nothing












