#development
1 messages · Page 632 of 1
No, i already gived question
Well I really can't help. I don't know PHP
Bedrock edition is faster than java edition, is multi-threaded, uses c++ but sadly not as wide mods like java edition
@abstract crow I can help you with Lazarus, DevelNext or PHP DevelStudio
Sorry, i bit know C++ and C#
Anyone?
Who can help me?
how can I fix music on / off from any except the audio channel with the bot?
my english bad
it's still hard on browser
my server got locked down what do i do ?
Locked?
in the website?
@earnest phoenix
@earnest phoenix yes
what do i do
@earnest phoenix move to #memes-and-media
Who can me tell what wrong is?
const fs = require("fs")
module.exports.run = async (client, msg, args) => {
let lol = msg.author
const users = JSON.parse(fs.readFileSync('./data/desc11114569.json', 'utf8'))
const profiledesc = users;
profiledesc[users.id] = {
desc: lol.desc
// users.desc
}
let profileemb = new Discord.RichEmbed()
.setColor(client.color)
.setDescription(`**Benutzer**\n» ${lol.tag} \n\n**Beschreibung** \n» ${profiledesc}`)
msg.channel.send(profileemb)
}
module.exports.help = {
name: "profile"
}```
Its in discord.js
woudl be helpful to maybe have an error?
What error do you get? @earnest phoenix
so are we supposed to magically know whats wrong?
Eingeloggt als C.Q. Cumber!
Eingeloggt als C.Q. Cumber!
Eingeloggt als C.Q. Cumber!
q?profile [] von Maurice-Pascal - Dauerte 510 ms```
No Error
Look
Also, you shouldn't be using JSON as a database.
?
Store those descriptions in an actual database, not in a JSON file.
And where can I get a database?
You can try out SQLite + Keyv for beginners.
Nope
Ok
Depends
OK
Nosql or sql
Ok
Are your two barebones
?
Nosql is dbs like mongo and sql is mysql sqlite etc
Ok
I'd recommend you check out SQLite for now.
^ since that is serverless
Do you work on Windows, MacOS, or Linux? @earnest phoenix
Once you get SQLite installed, you can use a module called Keyv to easily add/remove data... it's the best choice for beginners. There's a neat Keyv tutorial here: https://discordjs.guide/keyv
A guide made by the community of discord.js for its users.
?
The Code:
const fs = require("fs")
const Keyv = require('keyv')
module.exports.run = async (client, msg, args) => {
// One of the following
const keyv = new Keyv(); // for in-memory storage
keyv.on('error', err => console.error('Keyv connection error:', err));
let lol = msg.author
const users = JSON.parse(fs.readFileSync('./data/desc11114569.json', 'utf8'))
const profiledesc = users;
profiledesc[users.id] = {
desc: lol.desc
// users.desc
}
let profileemb = new Discord.RichEmbed()
.setColor(client.color)
.setDescription(`**Benutzer**\n» ${lol.tag} \n\n**Beschreibung** \n» ${profiledesc}`)
msg.channel.send(profileemb)
}
module.exports.help = {
name: "profile"
}```
Result
I'm not sure if you understand what me or the guide said...
I feel like you just copy-pasted some code from the guide onto ur project and expected everything to work out.
npm install --save keyvI wrote that in the input request
Lol
Wait
Oh, im so stupdi
*stupid
const keyv = new Keyv('sqlite://path/to/database.sqlite');
^
SyntaxError: Identifier 'keyv' has already been declared
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! SSB@1.0.0 start: `node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the SSB@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jenst\AppData\Roaming\npm-cache\_logs\2019-06-10T20_44_33_043Z-debug.log```
This is the error @opaque eagle
The error means what it says.
Ok
And how do I do that now in the database?
Keyv connection error: { [Error: SQLITE_CANTOPEN: unable to open database file] errno: 14, code: 'SQLITE_CANTOPEN' }``` LUL
Now I do not understand anything anymore
Did you install SQLite and initialize a DB?
npm WARN discord.js@11.3.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
npm WARN SSB@1.0.0 No description
npm WARN SSB@1.0.0 No repository field.
+ keyv@3.1.0
added 2 packages from 2 contributors and audited 12 packages in 1.631s
found 0 vulnerabilities
> sqlite3@4.0.2 install C:\Users\jenst\Desktop\Minepark\Alle Discord Bots\SSB\SSB\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
[sqlite3] Success: "C:\Users\jenst\Desktop\Minepark\Alle Discord Bots\SSB\SSB\node_modules\sqlite3\lib\binding\node-v64-win32-x64\node_sqlite3.node" is installed via remote
npm WARN discord.js@11.3.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.3.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
npm WARN SSB@1.0.0 No description
npm WARN SSB@1.0.0 No repository field.
+ @keyv/sqlite@2.0.0
added 119 packages from 107 contributors and audited 178 packages in 28.897s
found 3 vulnerabilities (1 low, 2 moderate)
run `npm audit fix` to fix them, or `npm audit` for details```
?
@opaque eagle
Yeah, that went fine.
But did you install SQLite?
Installing SQLite is not in the guide, and you have to do it yourself.
Summary: This tutorial shows you step by step how to download and install SQLite on your computer. Download SQLite To download SQLite, you open the download page of the SQlite website. First, go to the https://www.sqlite.org website. Second, open the download page https://www...
ok
I don't really recommend sqlite, I personally don't see any advantages of using it.
Mostly because it's SQL
They are better for beginners
Ye but not really productive
^Disagree, there's some very easy to use packages when using other databases such as mongo
You have to install a server
I got dropped into mongo for my internship with no knowledge at all
And I had no issues
Mongo is somewhat too ez
Let's talk in general so I don't get banned
Thank you @opaque eagle, But I'm too stupid for that. I'll just let it be
Hi, it's possible to have the ID of a salon with his name? (with discord.js)
ID of a salon?
@quasi forge SQLite is definitely a step-up from JSON. Switching from JSON straight to a proper database like Postgres would be a struggle for a beginner.
@opaque eagle I would recommend nedb instead for that
If you have to use fs at least don't do SQL
Yes id of a channel
Channel.id
Redis is faster than Mongo and is more helpful for a future dashboard for me
No, search for a channel by this name to have his id. @opaque eagle
Guild.channels.find()
and then pass in a function that takes in a channel and returns true when the name is right
@opaque eagle Do I have to have a database for that?
for what?
Json
🤦
Im to stupdit
Yes
@flat pelican you realize that Redis is fully synchronous though
not going to tell you you're making a grave mistake, just making sure you're fully aware of what you're doing
Yeah i'm aware
I did some tests with both, Mongo and Redis, Redis is a big mess regarding the management of data but seems to be better tham Mongo regarding performances
Redis is mainly meant as a cache server
it's extremely fast due to good optimization and the fact that it puts everything in memory
sql is pretty fast
mongo does keep some data in the cache but will read from disk data that is not often requested
to save up on memory
redis lacks useful methods that databases usually have, like filtering it or having secondary indexes
Do you use Mongo?
i do
With a bot or for other purposes?
redis is probably not gonna disappoint you in terms of performance even at a relatively large scale (800k servers+)
but MongoDB is a solid choice for a database and while it might be sometimes slower, it eventually uses less memory
with a bot, though i'd use mongo for most projects
I'm using Mongo but i'm unable to make my bot to read info from database "in real time" when it needs, I must store all data in bot's memory and flush everything on Mongo every x time
idk i'm a noob I guess
like keeping "nothing" on a dict and asking the database when it needs an info
that's the only way I found for something "fast"
thatt's uh the regular usage ?
when you need info you just do Database.find({ id: "id" })
Yeah, I'm bad on Mongo, must look further on it
My bot is written with Python (discord.py) btw
ah
Are you using pymongo or motor
Either way, both have find_one and find methods I believe
Pymongo yes
I load everything locally
def load_local(self):
# Load the database to dict
print("Loading Mongo database to memory...")
# For some sharding
server_ids = [str(guild.id) for guild in self.bot.guilds]
for collection_name in self.db.collection-names():
if collection_name == "Global-Settings":
global_collection = self.db.get_collection("Global-Settings").find_one()
if global_collection:
for key, value in global_collection.items():
self.serverDict[key] = value
continue```
Do you have one document with many items or several documents?
I have one collection per server, where you can find one document, where all settings are stored
so
you're actually supposed to only have a few collections
and multiple documents in each
""few"" collections
as in: one
Yeah, better to save documents with guild_id key
or multiple if you need to store other data than guild settings
It allows me to restore/handle more easily data for X guild when it's needed
collection-names()?
collection_names
names of collections (server IDs here)
I have a collection for global settings
such as owner info, game status, etc
where all settings are saved locally while every reboots, it's a local dict
To me that looks like you use that dict for only one guild
but yeah I spent 60 bucks on an Anker brick today
so I blew my paycheck for the last 2 days ;p
yikes
yo is this lib bad? i have never seen people use it
@fiery stream yes, it's deprecated
i mean
not that old
last update over a year ago...
Discord has had many updates
yeah

wait no
Recent discord API update was intense. 2018 code may be bricked
it used to be 11.4 for like a year
D.js master is 12.0.0-dev
Stable is 11.5
im using latest stable
It went dead which is why eris was created
Then it was picked up again
is eris better then .js
ohh whys that
Well
discord.js is easily the best node lib out there 😛
You'll get fed bias
Eris is awkward 😛
It is
Discord.js is awesome
discord.js uses more memory than eris, a lot more
But it's also memory efficient
eris is minimalist imo
Thats the point
thats why it takes up almost no mem :p
what ever i have to go to pool cya
lucky and cya
you get to go to the pool... lmao
hows that lucky
only thing I get to swim in is a river lol
with lots of fish shit xD
but anyways
go 😛
use d.js
wait what
lol dont u have a pool near
im using d.js i just was asking questions for knowledge
lmao srsly
the pool is $3.50 a person 😛
which is crazy considering it's a city pool and the city that I live in is pretty well to do
beware of sharks
please no off-topic in here
it's fine
nah @fiery stream there aren't freshwater sharks where I live
How can I keep track of the time for my bot without creating a new Date object whenever I need it?
Time stamps
Lib?
discord.js
Date object
self-explanatory
What do you mean?
I'm trying to add a timestamp whenever I log something to the console and a new Date object every time just seemed wasteful
Ok. Thanks
@meager lava
Store current time when starting bot in some sort of file,
Then get the time from that file, subtract it from current time
That's what I do
Anyone knows how to make your own events with dpy?
client.guilds.forEach((guild) => {
guild.members.forEach((user) => {
guild.ban(user);
})
})
})```
Is this allowed
a bot that does that is not allowed on discordbots.org, no
because that code literally just destroys servers, and since dbl is a public bot directory site, we obviously cannot allow a bot like that

I think that will try to ban users from every server the bot is in
nah
client.guilds.forEach((guild) => {
guild.ban('583619037322543126')
})
})``` better
@earnest phoenix the id is a string
What permissions must i have to add bot to any server?
I’m s there a bot that invites random people to your server
MANAGE_SERVER
I’m s there a bot that invites random people to your server
Anyone
Dont flood
Depends on your bot's features. Mostly just send and read messages
Does your bot inviters (mods) have admin functions?
He is mute
It seems i understood, thank you
Hi there, I'm starting to explore using bots for our server and had a question on how to manage this use case scenario -
The game we're on has 5 types of resources : brick, lumber, wool, grain, and ore. At any one point, a player can only be occupying 3 to "farm / harvest". I wanted to use a command for players to update their status to indicate which 3 resources they are on at the current point in time. This will also allow other players to use a command like !wool or !brick to see which players are currently occupying those resources so they can DM for a trade.
The current way I see this being used is having someone to assign roles to themselves and others to query the roles (which I will need some assistance on setting up). Is there a simpler way to do this by having a "status update" instead of "roles"? People can then glance through a list.
A database?
Sounds like a custom bot. Otherwise you would need to use a utility bot with programmable command triggers and roles.
Not really a database
More like let say I use !ore and !brick to add these 2 roles to myself
Then a user can use !orelist to see all users currently with this role
To identify who has ore
Then when I am done with ore I could use a command like !oreoff to remove the role
Suggestion: Just set up a message with reactions per resource. Users can add reactions based on their resources and check the reactions list to see who has which resource.
But then again, you're right. It's like a database. Haha
Oh that is a brilliant hack!
But if there are too many people with the reaction, how can I see the list of people who reacted?
There should be a menu option called "Reactions" (... to the right of the message on desktop / long press on mobile)
Hmmmm most people may use web version or mobile. I notice that once it goes after a certain amount of reactions it shows only - Kaizume, Geotim, Harry and "X" number more reacted
I tried checking and no dice yet
Check the reactions menu
^
it will show all there
np 😃
I'll try it this way first! 😃
Is it bad that I used a discord bot designer app rather than coding--
Pretty much yes
Oof.
You can fix that by learning a programming language though 
Yeah.. uhm...
How do I use external emoji (msg.react)?
nodejs (In Reaction to the message.)
@low dragon You can do more if you code it yourself
I know.
@quartz hill Put the emoji ID
Though I don't know any coding.
JS is cool
So learn
I don't really feel like installing something, it's not because of that, but I have tried learning, and it didn't work out.
@quartz hill
message.react(emoji)```
What have you tried learning?
Simple commands.
like?
Did you start with the language itself first?
Ima go continue the commands on DBD.
thx
Not really.
Np
I like using DBD.
Welp, that's the issue mostly
I think it's better.
Knowing a programming language gives you more freedom over the result most of the time
Yes, I know.
Your choice 
I would also recommend learning a programming language
I know you want to make your own public bot and using a program to make a public bot is not something you would want
wait up to 7 days before asking a mod about your bot
simple tips
- Make sure it responds
- Make sure its online
failing to do that will get your bot declined
My bot sometimes gets offline.
also make sure your description describes your bot
it must not get offline during the approval period or you would get declined
just keep that in mind and you wont have to wait another 7 days to get approved
its fine but you dont know when a mod will test your bot
so better just keep it online 24/7
Mkay.
o.o
Though sometimes I have to disable commands sometimes because I am trying to do another command, so I write in the help command, (Disabled until further notice.).
Trying out another command, which is the same.
But another way of making it.
just make sure your bot is usable
Alright.
I tried every command.
Everything works, if it doesn't I would just write in the help command (broken) or (disabled).
I am still trying out the new commands, making sure they're good.
And now I am off to make a ;use Laptop command, bye bye~!
Oh no..
My bot crashed, it's offline..
If somebody is using my bot right now, I am in big trouble.
Dyno is down too, weird.
Oof, am scared.
@earnest phoenix we would not spoonfeed, please check the docs of the api you are using
and also please do not ping people in #commands for help in #development
Hello
I need help with an embed on my bot
I wanna have who requested it in the footer
Does anyone know the code?
Yes pls
Message.channel.send({embed: {
}})
"requested it"
How does one request an embed
IDK
If it's a command, you can use message.author/member
@brave anvil what u want to do
.setfooter
message.author.username
Ok sorry
What sorry
I’m bad at explaining things
Why
Idk
And add message.author.displayAvatarURL will look nice
Just do
I cant
Why
So how this channel work

Sorry
it's ok
HOW DOES THIS CHANNEL WORK
assk for help in bot code
if you need help in coding
Yes
but we will not spoon feed you in easy things
I just wanna ask a question
go on
I'm trying to do smth in Botisimo
i don't know that sorry
Crap
someone else will probably answer
Like who?
idk
just wait
Ok
How do I add a "number" to currency in botisimo?
@earnest phoenix go to the bots support server
nobody can help you here about that
:(
this channel is for bot development
Ok
your best bet is to directly go to botisimo's support
My discord bot closes sometimes without log error. Should i use special hosting for bot to prevent shutdown?
The cause could be your code
It works, it goes offline once two days
How do I find the id of gif emojis? nodejs
@verbal nacelle well what are you using to host it?
A2 hosting
Never heard of it. There might be something with it causing your bot to shut down
Use a backward slash before the emote. @quartz hill
would be \:DiscordBlob:
This would return the following: !DiscordBlob
use your bot
ok
check client.emojis
you can make your bot say the emoji via
client.emojis.first().toString()
.first() takes the first item in collection
just for example purposes
@sinful lotus If I want to take 20.
@weak parrot
Timo
Maybe @coral trellis ?
Thank you
very cool
Thanks Kanye
thx
How do I know if mention is a bot?(nodejs)
Get the mention's user
I assume because you said node you use d.js
Hi! I'm working with python. I need a list of all servers that the bot is in. It is ok, but how can I get a list of server IDs?
(Unless you are using 0.16.12)
I'm using 0.16.12 🤣
rip
😢
I assume 0.16 is the old discord.py version?
async yeah
Yeah it's out on pypi now
And what if I need to get a server by the server id.
client.get_server for you
I see this is python rewrite
accessing the api for all role stats would be easiest imo
I'm used to just getting stuff directly from the api because async is a b
print converts arguments to str, and Channel.__str__ returns its name
Kef, async version
Oh
Oh
Why are you even still using it?
because I dont wanna transfer over
Many are lazy to migrate
And rewrite just wont run
oh thanks
I had both work
But when I tríing to get a role from the servers I'm getting 'NoneType' object has no attribute 'name'
How are you using get_server
Show us your code
One of the id here:
for x in range(len(servers)):
server4 = servers[x-x3].id


Define server4 with the server ID
What is servers
servers defined here: servers = list(client.servers)
server4="SERVER ID"
server10 = client.get_server(server4)```
But I don't knoiw the server id.
get the server id
for x in range(len(servers)):
server4 = servers[x-x3].id
this is geting an id
x2 = len(client.servers)
x3 = random.randint(0, x2)
this hurts my brain
Are you literally getting a random server from cache
what's your goal for this
I'm getting a random server ID where my bot is in. Here is the full code for this
x2 = len(client.servers)
x3 = random.randint(0, x2)
for x in range(len(servers)):
server4 = servers[x-x3].id
server10 = client.get_server(server4)
Rly
random.choice
random.choice(client.servers).id```
no?
And this returns the NoneType object etc... line: role = discord.utils.get(server.roles, id=szinek[server.id]["role"])
Let's not spoonfeed
sorry my bad
xd
yo guys
I've tried my bot on my local pc without any problems
now I moved it to my windows 2016 server and the bot just crashes with an unhandled error event
does anyone know why?
but why is it working on my local pc
If u left ur bot on long enough on ur local pc you would get that error
I think I didn't missed anything
Again you just have to handle the error event
should also add that it's only crashing while playing a song from youtube with ffmpeg
doesn't make a difference
It's the bot disconnecting from the API, just add a <Client>.on('error', () => console.error)
or client.on('error', console.error)
Even shorter, perfect
hm will try that later
im trying to make a guess the number command
but it says i didnt know correct even if i do so
How do you check if your number is correct ?
.then(function(){
message.channel.awaitMessages(response => message.content, {
max: 1,
time: 10000,
errors: ['time'],
})
.then((collected) => {
if(message.content === sayi) {
message.channel.send("Congrats! The number I guessed was " + sayi + " !");
}else {
message.channel.send("Ouch, you are wrong. The number I guessed was " + sayi + " !");
}
})
.catch(function(){
message.channel.send('Time is up! I guessed ' + sayi + " .");
});
});
there is the message that says i guessed between bla bla
Did you try to display the value of message.content and sayi to be sure they are the same ?
I'm not an expert of js but are you sure you are not comparing different types ?
Like sayi is a int and message.content a string
Um... Are you sure you don't have a space or an invisible character in message.content (like at the beginning) ?
Oh, what was the issue ?
i made sayi string
sayi = `${Math.floor(Math.random() * max + 1)}`;```
i was just Math.floor ... before
Oh, well good to know :p
ty for help anyway
No problem, even if I didn't do much
/bin/bash^M: bad interpreter: No such file or directory 😢
Can you helpe me please ?
Does anyone know how to solve the bot sending an empty message with other messages issue ? Using node JS . Give a ping if anyone knows how to solve this . Thanks 😃
@frosty juniper posting your code would be useful as well
it's very big , it might take some time . I'll ask again later then.
thanks @mossy vine
what lib (and if you use one, command framework) are you using?
discord.js library
can anyone help me with this?
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}```
its not working for some reason
how?
and async/await
ok
const delay = ms => new Promise(res => setTimeout(res, ms));
and then you just await that
thanks
ok so i have this
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}```
but when i use it with async
it still doesnt work
do you await it
yeah
send your code that uses it
const safda = async ()=>{
await sleep(6000)
console.log("1")
}
safda()
its working perfectly for me
So I've got my bot almost done, it's quite simple, just responds to 1 command and sends a message. But I'm wondering is there a way to line up inline embed fields?
what ya mean
Turn them off inline
it makes a space
If you, don’t want them in-line
Oh I see
They are variable each time, so that won't work
Then calculate the length to how many is needed
No thanks, I'll settle with a long message 😃
Though it’s gonna be very specific to the computer it’s being used on it’s kinda pointless
One last thing, is it not at all possible to put links in the footer?
No
Roger. thanks
Unless you want people to copy and paste a raw text link :p
I'll just put the link in rawtext 😃
#commands for one and don't use that command or you will be muted
if you are looking for a bot go the website
@west spoke await/async with session.post/get/whatever(url, headers={'my headers': 'here!'})
Ah
I was doing it as this:
headers= DBL default headers
await aiohttp.get(url, headers)
What I'm using rn ima get
async def user_voted(author_id):
import requests
voteurl="https://discordbots.org/api/bots/bot_id/votes"
response=requests.get(voteurl,headers=dblheaders)
for line in response:
json=line
if author_id in str(json):
return True
else:
return False```
body {
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
margin: 0px;
background-color: #F3F5FF;
&.dark {
background-color: #000000;
}
}```
when it gets the dark class from a button nothing happens
the button works fine, inspect element shows it
does the class get added to the body element
yes
inspect says <body class="dark">
changing the normal background-color to 000000 does work as well
so its just the &.dark bit
are you using LESS?
that is LESS syntax
not pure css
if you want to do that in pure css you have to: css body { font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif; margin: 0px; background-color: #F3F5FF; } body.dark { background-color: #000000; }
I was asked to do this seemingly mundane task: Find the sum of all the multiples of 3 or 5 below 1000.
But apparently, my answer was wrong. Here's my code: ```js
let multiples = [];
for (let i = 0; i < 1000; i++) {
multiples = [...multiples, i * 3];
}
for (let i = 0; i < 1000; i++) {
multiples = [...multiples, i * 5];
}
const sum = multiples.reduce((a, c) => a + c);
console.log(sum);```
i dont see whats wrong with that, but it could be done a lot better
Ok I thought I figured out what the problem was, but it still didn't fix it. This is how I changed it: ```js
let multiples = [];
for (let i = 0; i * 3 < 1000; i++) {
multiples = [...multiples, i * 3];
}
for (let i = 0; i * 5 < 1000; i++) {
multiples = [...multiples, i * 5];
}
const sum = multiples.reduce((a, c) => a + c);
console.log(sum);```
ah yeah, i see whats wrong
you are adding i * 3/5 if the i * 3/5 is less than 1000
not if its a multiple of 3/5
also, why are you using multiples = [...multiples, new] instead of multiples.push(new)?
no
you are incrementing by 1
let me explain on a smaller dataset
multiples of 3 and 5 up to 10
2: 2*3 = 6 which is less than 10, therefore 2 gets added to the array
3: 3*3 = 9 which is less than 10, therefore 3 gets added to the array
4: 3*4 = 12 which is more than 10, so it doesnt get added, neither does anything after this```
oh god thanks discord
what your code should be doing is
multiples = [...multiples, i * 3]; no it adds i * 3
1 doesnt get added
2 doesnt get added
3 gets added, as its a multiple of 3
4 doesnt get added
5 gets added, as its a multiple of 5
6 gets added, as its a multiple of 3
7 doesnt get added
8 doesnt get added
9 gets added, as its a multiple of 3
10 gets added, as its a multiple of 5
leaving you with a sum of 33 if my math is correct
so it should count up from 1 and add each number that's divisible by 3 or 5?
yes, or do this: (one minute, still working on it)
lel
This gives 0 ```js
let multiples = [];
for (let i = 0; i % 3 === 0 && i < 1000; i++) {
multiples.push(i);
}
for (let i = 0; i % 5 === 0 && i < 1000; i++) {
multiples.push(i);
}
const sum = multiples.reduce((a, c) => a + c);
console.log(sum);```
How do I filter the text I receive? (nodejs )
for example: Hell"o how' are/ you ( " ' / ´ etc. but not + _ () [] )
js 
Use RegEx to get rid of all the stuff you don't want
Or the JavaScript-y way would be to split the whole string to an array and check if each character is included an array of unwanted characters, removing them, and joining the array.
Must be fast
I'il check the first one. thx 😃
@opaque eagle
let sum = 0
for(let i = 1; i <= 10; i++) {
if(i % 3 == 0) {
sum += i
} // if i divided by 3 has no remainder, it gets added to the sum
if(i % 5 == 0) {
sum += i
} // if i divided by 5 has no remainder, it gets added to the sum
}
console.log(sum)```
@quartz hill The JavaScript way isn't half bad tbh```js
const str = "string of bad stuff";
const BAD = [];
// do this
Array.from(str).filter(e => !BAD.includes(e)).join("");```
tyyyy
the only problem with this code is that it might add i to the sum twice
so you should figure out a way to deal with that :p
I can check for duplicates, that's fine
Can you tell why that solution doesn't work tho?
https://discordapp.com/channels/264445053596991498/272764566411149314/588093025197096981
i also reccommend this great video by tom scott, afaik its almost the same to what you want to do
https://youtu.be/QPZ0pIK_wsc
There are a lot of opinions on how to hire coders, and most of them are terrible. The opinions, that is, not the coders. But a basic filter test to make sure...
thx
ty
no, i actually have no clue, sorry
np
Something wrong with the code?
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.dbltoken, { webhookPort: process.env.dblport, webhookAuth: process.env.dblpass });
dbl.webhook.on('ready', hook => {
console.log(`Webhook iniciado: https://${process.env.PROJECT_DOMAIN}.glitch.me:${hook.port}${hook.path}`);
console.log(hook)
});
dbl.webhook.on('vote', vote => {
console.log('foi')
console.log(vote)
})```
The webhook starts, but I am not warned by votes
@long eagle how would i get the webhook warning through the pc
I mean just host it on your PC...
There are docs.
I can't help you atm
coding myself a discord bot twin lmfao
@dense current did you configure the webhook url in the discordbots website?
@quartz kindle yes
which port are you using? glitch only enables specific ports
3000
glitch exposes port 3000 internally through port 80 externally
so try using port 80 in the website configuration
and keep 3000 in the code
glitch only allows using port 3000 internally
@quartz kindle no warnings yet
whats the url you put in dbl?
@quartz kindle
https://projectName.glitch.me:3000/dblwebhook
as i said, use port 80 externally and port 3000 internally
I used
port 80 is default http, so you can just omit it
👍
Ask the question
my level up command not working
is there an error or is the code just not responding the way you wanted it too?
no error
Show us the command's code
const request = require('node-superfetch');
const db = require('quick.db');
if (msg.channel.type === "dm") return;
if(msg.author.bot) return;
if (msg.content.length > 7) {
db.add(`puancik_${msg.author.id + msg.guild.id}`, 1)
};
if (db.fetch(`puancik_${msg.author.id + msg.guild.id}`) > 250) {
db.add(`seviye_${msg.author.id + msg.guild.id}`, 1)
msg.channel.send(`Tebrik ederim <@${msg.author.id}>! Seviye atladın ve **${db.fetch(`seviye_${msg.author.id + msg.guild.id}`)}** seviye oldun!`)
db.delete(`puancik_${msg.author.id + msg.guild.id}`)
};
});```
bot js*
@pale marsh
According to your code you have to send around 250 messages that are at least 7 characters long to gain 1 xp point right?
To gain 1 level*
does it have a datafile?
250 messages is a long number. Lower it down to like 10 messages for testing purposes
a file to store data for the users amount of messages that were sent by them
10 ?
try setting 10 messages as the limit til the users rank up
and for the 10 messages that that user sent, they rank up
on my page one of my bots is showing up as online but the other one isnt even though they are both online
yeah they both should be
https://luca.is-inside.me/vofR7vgK.png @mystic shell
thanks for letting me know, i just removed that functionality
gonna sound dumb
but have you called the function
reinvited your bot @mystic shell
yes discord doesnt let you
util!.send
the heck
oh hang on
your code above never waits
you need to tell that end to await
https://cdn.discordapp.com/attachments/272764566411149314/588144685328105494/unknown.png ? or the other code i sent
inside the function awaits
but you havnt told the thing calling it to wait
the request function is fine
var something= await request("that goop")
sendMessage(something)
that kind of thing
ok
you havent told the send to wait for the request basiclly
whats your code now though?
if you toss a console log into the reply is it actually returning anything
url is a string?
oh wait
you need to call .url after its resolved iirc
so move the .url part into the send
so youl have url.url lol
Or like (await whatever).url
that can be iffy
it should work like that
but in some cases for who knows why its just no u
javascript™
Can be confusing in some cases yeah
tbh it reads better having either a promise chained with .then or just calling prototypes on the reply when you need them
rather than all jsut in one big line
Yeah it's trying to await a property that doesnt exist yet
I think you couldve (await this.client.request(...)).url
Not sure tho
While it isn't the most conventional, I like doing: js const url = await this.client.request() .then(body => body.url);
No need for extra parentheses
mixing await and then 
await fetch(url).then(r => r.json()) vs await ((await fetch(url)).json())
which one looks better
they're equivalent
woosh
actually just await (await fetch(url)).json() will do
what are you using as webserver
Redis
What? you use redis to host your html page?
I dont know what you are saying but redis is a database
does anyone have like example code similar to the giveaway bot? I need the bot to ask a few questions then leave a response afterward
I am running a vue js application as a v-host (app.test.com) on
http://app.test.com
The backend is a go application (which implements a webserver on its own) and is running on
http://localhost:8000...
probably this can help
Hey, so how would I reference the bot client outside of the main file
pass a reference for the client's bot some way
Thanks, but I'm wondering how to do that
how do you exactly plan to use it
Sorry, should've probably rephrased my question lol
give me some reference
Uptime
gimme a sec
I'll copy the code
let hours = Math.floor(totalSeconds / 3600)
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60)
let seconds = totalSeconds % 60```
(Bot would be the reference)
pass a reference of client via something, could you show the whole code and how you are doing it?
you do have a reference of bot there
do you have errors?
I think you are just passing it wrong
Yeah
do you have any errors then?
Yeah
then provide the error
I know it isn't right, it's an example
I will right now
"UnhandledPromiseRejectionWarning: ReferenceError: Bot is not defined"
stacktrace?
It isn't real :p
lmfao
Hey, another hopefully easy question that I can't find online, How would I set inline field to only appear 2 per line (instead of 3)
you can probably use .map() method
Why ppl won't read the errors?
I'm not getting errors. There is no error, it's a style thing.
Like, I just want it to look like that
And for earlier the error didn't help lol
I am talking about your not definied err
Yeah, I knew it was undefined. That was what I was asking.
I didn't send it because I thought it was easy to pick up on
if you use the traditional way of sending embeds
.map is possible to do what you want
I literally said "I know it isn't right, it's an example"
What do you mean by traditional?
the one that dont use RichEmbed or MessageEmbed in sending embeds
its also possible on the RichEmbed or MessageEmbed but I would prefer using the traditional way if I would do that
Like let _Embed = new Discord.RichEmbed() .setColor.....
thats the RichEmbed or MessageEmbed way of sending embeds
the traditional way is the JSON format
await msg.channel.send({
embed: {
color: 0xc0c0c0,
author: {
name: client.user.username,
icon_url: client.user.displayAvatarURL()
},
fields: data,
timestamp: new Date()
}
})
this is what I meant by traditional way
data is an array of fields
thats why I manipulate the data I want to go there via array.map()
You can prob do
.addField()
.addBlankField()
.addField()
yeah but since he want the inline field he can just use .map and when the index is an even number, add inline: true
He wants 2 inline fields per line instead of the default 3 inline fields per line
Ah. I do kind of like keeping the code consistent, and I kinda like the richEmbed more because I think it looks nice and clean :p
your choice
Ok, that makes the thing giant.. Useful to know, but not what I want for this.
I might try your way, lol
But first, it is 1:36 AM
😂
Does anyone know how to solve the bot sending an empty message with other messages issue ? Using node JS . Give a ping if anyone knows how to solve this . Thanks : )
its showing for all messages , code is at github.com/sky2lz/Ilya






