#development
1 messages · Page 649 of 1
Yea, IDK why.
:/
It doesnt sort because your trying to sort letters
letters?
let array = [
"singular",
"double", "double",
"triple", "triple", "triple",
"quad", "quad", "quad", "quad"
];
let count = array.reduce((obj, value) => {
obj[value] = obj[value] + 1 || 1;
return obj;
}, {});
let sorted = Object.keys(count)
.filter(key => count[key] > 1)
.sort((a, z) => console.log(count[a], count[z]));
test code
No.
Oh ok
obj = { 'singular': 1, 'double':2, 'triple':3, 'quad':4 }
Im on a phone and I really dont feel like opening any console
What r u trying to do?
Wth is all this
@keen karma its code
I know it’s a code but for what ?

They say a code for discord bots ? Idk bye !

.\
yeet dotpost
]]dotpost
Please do not post random punctuation marks or letters to clear your messages and/or to get attention. This is considered spam as you are not contributing anything to the conversation. Should you need to get the attention of the chat, simply start by saying hello. Should you need to clear your messages, right click on the channel then click "Mark As Read"; this can be done from mobile by holding down on the channel. Further offences will result in the appropriate consequence.
is wiki command is nsfw?
@stray gazelle It depends on what it outputs
Some wiki commands from some bots only output a wiki link, whereas some may put a wiki image/content that is NSFW
mine don't send any nsfw image...only link or words @spare goblet
and it's gets rejected 😦
Can we take this to DMs as it's not really related to development 
sure...and sorry
Hello
What's up?
Anyone can help me
yeet ask2ask
By asking if you can ask a question, you have already asked a question so simply just ask the actual question. State exactly what the problem is so someone can help you as soon as possible.
How to change private bot to public bot
https://discordapp.com/developers/applications/ > Access the Bot tab > Enable Public Bot
^
I need to get all the messages in a certain guild in which there are invitations. How can I do this using discord.js?
you can only get 100 messages at a time
you can only grab 100 messages, so just grab messages and filter
@warm marsh i'm back I was sleeping
I need the array elements to be sent in turn every 2500 milliseconds, but they are sent after 2500 ms immediately. What am I doing wrong?
var array = ["1", "2", "3"];
array.forEach(function(number) {
var time = 2500;
setTimeout(function() {
message.reply(number);
}, time)
});
the forEach doesnt get stopped by the setTimeout
And how then can I do what I need?
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
array.forEach(async function(number) {
message.reply
await sleep(time)
})```
Thank you
that'll do exactly the same
> const sleep = (milliseconds) => {
... return new Promise(resolve => setTimeout(resolve, milliseconds))
... }
undefined
> const array = [1,2,3,4,5]
undefined
> array.forEach(async x => {
... console.log(new Date().getTime(), x)
... await sleep(2500)
... })
1562334664847 1
1562334664851 2
1562334664852 3
1562334664852 4
1562334664853 5```
the function you pass to forEach can take more than one argument
the second is the index
> const array = [1,2,3,4,5]
undefined
> array.forEach((x, index) => setTimeout(() => console.log(new Date().getTime(), x), 2500 * (index + 1)))
undefined
> 1562334728116 1
1562334730622 2
1562334733119 3
1562334735619 4
1562334738119 5```
Hi
My code :
if (!Dresseurs[sender.id]) return message.channel.send("Erreur : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
let arrayOfItems = Dresseur.Sac.concat(Dresseur.SSac.concat(Dresseur.LSSac.concat(Dresseur.LGSac))).reduce((obj, value) => {
obj[value] = obj[value] + 1 || 1;
return obj;
}, {});
let duplicated = Object.entries(arrayOfItems)
.filter(innerArray => arrayOfItems[innerArray[0]] > 1)
.map(innerArray => `**${innerArray[0]}** x` + "`" + innerArray[1] + "`\n");
if (duplicated.length == 0) return message.channel.send("Vous n'avez aucun Pokémon en plusieurs fois")
if (duplicated.length >= 30) {
nuber = 30
} else {
nuber = duplicated.length
}
message.channel.send(`__Voici les ${nuber} premier Pokémons que vous avez le plus en plusieurs fois :\n\n__` + duplicated.slice(1, 30).join().replace(/,/gi, ""))
break;```
I want sort by the innerArray how i can make this
innerArray[number, word]
Fuck I wanna make a web dashboard for my bot but don’t know where to start.
Anyone have any pointers or tips?
Hu ? @west spoke
@tulip solar get a webserver, make a website, figure out oauth2, connect to your bot's database, do things
i have a program that runs by doing npm start in the folder on cmd.exe
how do i do it from a file
If people can help me : https://discordapp.com/channels/264445053596991498/272764566411149314/596720663721541633
Example : i have this now :
But i want sort
put a sort before your .map()
something like this .sort((a,b) b[1] - a[1])
Ok i go test
.sort((a,b) b[1] - a[1])
@quartz kindle
.sort((a,b) b[1] - a[1])
^
SyntaxError: missing ) after argument list
Missing a )
Yes but where wtf
a[1]))
No :/
No
actually i missed a => lmao
(a,b) => b[1] - a[1]
Ok ok
@quartz kindle if i run a bat from a folder
does it automatically start up with the current dir selected
No
He work thx tim
mk
im trying to draw data from a url in java
and return it as a string
ive tried for so fking long
class onCreate {
//@org.jetbrains.annotations.NotNull
public static String main(String args[]) throws Exception {
final URL url = new URL("http://neko-bot.net");
final BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
final String inputLine = in.readLine();
//inputLine;
in.close();
return inputLine;
}
}
@quartz kindle
if i run it by double clicking
it loads firefox
its a .html
but idk what npm start loads
pretty sure main.js
but i just get win script host errors
lol wut
its a js file
they will have to install it
how can i just run a js file then?
you cant
you cant
the whole purpose of node.js is tu run js files without a browser
if you want to make a packaged software that people can just run, you need to use soemthing like electron or nw.js
electron and nw.js are like an embedded browser window with integrated node
so if i made a bat
and lets say we install node when people install it
how do i do npm start when they run it?
because it wont load on the right dir
@west spoke wut
"
Try calling the .exe with %~dp0, like this: %~dp0MyProgram.exe.
%0 contains the full path to the called .bat file.
~dp says to get the drive and path, including trailing .
"
wot
Im trying to get values from a url and return with a string, and use setText in the android SDK
what does it even mean @quartz kindle?
yeah i can make one
so, in the line where you write for example "node mybot.js"
just this?
you should add those before
pushd %~dp0
npm start```
yes that should work
if you wanted that all along you couldve just used pm2
uuh what
ok ill look
there is a way to hide the cmd window, but the cmd window is the bot itself
if you hide it, you cant shut it down easily
its not a bot but ok
well, your app
so basially if you hide the window it shuts down
if you really want to do it with a bat file, just do start /b node yourstuff.js
you can hide the window and keep it running, but then people wont know it is running
if you're working on a desktop app, i suggest using electron or nw.js
its using electron currently
then you should be able to run it from electron.exe
theres not an exe
you need a prebuild version of electron
yes, but it depends on how your files are structured
wdym how thet are structured?
for example you can run something minimized from a bat file using start /min file.exe
May have gotten it
a bat file can run something inside itself, like when you run commands from a cmd, or a bat file can launch something to run externally, and then close itself
it depends if your app needs to run in a command window or not
start /min file.exe didnt work
you didnt literally type file.exe, did you?
i did npm start /min main.js
that wont work because npm runs in the command window
/min only works if you're launching an external window
your project really sounds like something that should be done with electron or nw.js, but if you really wanna go that way, the simplest way would be to run cmd from your bat file
whats the easiest way without a cmd window?
something like start /min cmd.exe "yourdirectory/npm start main.js"
the easiest way without a cmd window is you build your project on top of a precompiled electron or nw.js and just run the exe lol
nope because the directories are wrong
cmd.exe exists in the windows folder, not in your project, but npm start must be run from your project
so what do i need to do instead?
you can try something like start /min cmd.exe "%~dp0npm start main.js" (untested)
start cmd.exe /k "%~dp0npm start main.js" try this
'C:\Users\\Downloads\\npm' is not recognized as an internal or external command,
operable program or batch file.
your main.js is in the downloads folder?
no
when why is it in the downloads folder?
so the folder is correct?
if you type npm normally it works?
the npm opens cmd
hmm?
running that just opens a different cmd window
and what happens in that window?
normal electron opening only
so its working?
i didnt want a cmd think open tho
ok, but its working right?
then just add the /min now
i wanted the window to be seen to see if it works
start /min
thanks
@wide ruin iirc for mac you need to write a shell script as you would for linux
or use electron precompiled binaries lol
no clue about either
so if i get this right, you are working on a node project and would like to have an easy way for all people to start it?
yes
since its electron, you can build/package it for public releases, and tell people to just run npm start to test it
exports.run = async (client, message, args) => {
const useruser = 'Command ran by: ' + message.author.username;
const userurl = message.author.avavtarURL;
const exampleEmbed = new Discord.RichEmbed()
.setColor("RED")
.setTitle('idk')
.setURL('https://discord.js.org/')
.setAuthor('Yuqii')
.setDescription('Test Command')
.setThumbnail()
.addField('test', 'test')
.addBlankField()
.addField('test', 'test')
.setTimestamp()
.setFooter('test', 'test');
}
module.exports.help = {
name: "test",
aliases: []
}```
dafaq it does not give me any Response
cause you arent sending anything
send the embed
oh well now i see it...
if you package an electron app with precompiled binaries, people will be able to install/run it simply by downloading a zip file, extracting it, and running the executable
someone know how to check if a user was kicked ?
no events about that in the docs
onMemberRemove or something similar, fetch audit logs
okay
@earnest phoenix there is not event for that
ik
How to display the Profile Picture of the User that Ran the Command?
@stray garnet msg.author.avatarURL
thx
https://img.jt3ch.net/d9f3d98d.png keep getting this error when installing?
What command r u running?
npm i discordjs/discord.js
@tulip canyon
How to send huge amount of files to vps via putty?
If u know easier way to do it, ping me
Or just just move a whole folder across. Might take a while depending on the network speed
the problem is you cant send multiple files at once via sftp, so if you have 100k files, they will go 1 by 1, which is orders of magnitude slower
you can certainly have simultaneous uploads
not over a single connection
correct, but that’s obvious
use an ftp client that supports that, i.e. filezilla or smth
i uploaded all xenforo files w/ filezilla without zipping them and it did so fine
just took a while
around 20-30 minutes
I’m not sure what the default # of simultaneous uploads are, but it can be tweaked to make the process faster depending on your connection
thatd likely only be a max of like 5-10 minutes if it was zipped first
How can I convert a value in seconds to smth like x days, x hours, and x minutes etc depending on how much time is there?
What lib?
you can use humanizer, if using js
Or moment.js
@opaque eagle ^
@opaque eagle adding onto browser ^.
use moment and a package i use is moment-duration-format on npm. its really nice and does literally exactly what you just said
I wrote my own function for my giveaway bot, works nicely and adds things like "second's'"
Don't hesitate to ask if you need it 😏
ty peeps
Debugger listening on ws://127.0.0.1:38190/20cf25a7-f74a-47ea-b211-f0351d601083
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Apex Legends ready for battle
index.js:10
Database {open: <accessor>, filename: "apexbotstats.db", mode: 65542}
index.js:44
Error: SQLITE_ERROR: no such table: accounts
index.js:53
Error: SQLITE_ERROR: near "TABLE": syntax error```
var db = new sqlite3.Database('apexbotstats.db')```
db.prepare('CREATE TABLE IF NOT EXISTS accounts (discname TEXT, apexname TEXT, platform TEXT)')
console.log(db)
db.each(`SELECT * FROM accounts WHERE discname = '${msg.author.id}' AND apexname = '${username}' AND platform = '${platform}'`, function(err) {
if(!err)
{
console.log(err);
db.prepare(`INSERT INTO TABLE accounts WHERE (discname, apexname, platform) VALUES (${msg.author.id}, ${username}, ${platform})`)
}
else{
console.log(err);
db.prepare(`INSERT INTO TABLE accounts WHERE (discname, apexname, platform) VALUES (${msg.author.id}, ${username}, ${platform})`)
}
})
})```
Can somebody help me?
Provide error and we may be able to help
^
Debugger listening on ws://127.0.0.1:38190/20cf25a7-f74a-47ea-b211-f0351d601083
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Apex Legends ready for battle
index.js:10
Database {open: <accessor>, filename: "apexbotstats.db", mode: 65542}
index.js:44
Error: SQLITE_ERROR: no such table: accounts
index.js:53
Error: SQLITE_ERROR: near "TABLE": syntax error```
it was the first one
Add db.sync()
Where?
After declaring the database
apexname = '${username}' AND platform = '${platform}' nice sql injection
Natan
never use ${}/string concatenation in sql queries
Lavaplayer doesn't need external nodes right?
ok , and what should i replace with?
prepared statements
google "node sqlite3 prepared statements"
apexname = username + ' AND platform = ' + platform
any kind of string concatenation with user input in sql queries allows for injection
you do it with prepared statements
Hmm... True
Eg ```php
$sql = $db=>prepare("INSERT INTO ? ('1','2') VALUES (?,?));
$sql=>execute(array($username, $platform));```
A PHP version that is safe?
@inner jewel??
idk php
but that looks like it's using prepared statements
so it should be safe
if you just concatenate, this happens https://i-was-scammed-by.dabbot.org/2GhU9z8.mp4
It's not directly inputting the variables into the query string
Just how bad is it if your site is vulnerable to an SQL Injection? Dr Mike Pound shows us how they work. Cookie Stealing: https://youtu.be/T1QEs3mdJoc Rob Mi...
Code: https://gist.github.com/SinistreCyborg/881ddbda2daefa72e00f8d77a402ad8f
Depending on whether you mention a user, a role (or its name), or nothing, the command must show info about that user, role, or if u didn't specify anything, info on the server itself. The getters for each type return an embed object, to which the embed's color and footer info are added on to, in lines 28-31. Only the color and the footer show up, meaning nothing from the getters are showing up.
Gist are personal we can't access them

the secret tag on gists means whether the gist will appear on the discover page or not
That code was a lot to take in so I added some comments explaining the yucky parts:
https://gist.github.com/SinistreCyborg/881ddbda2daefa72e00f8d77a402ad8f
At text: `Requested by ${message.author.username}#${message.author.discriminator}`, why not message.author.tag
But anyways who’s asking what I’m lost
I'm using Eris, not discord.js
Hmm I figured out the problem
typeof this.subject simply returns object, not the exact class it's an instance of
Yep it all works now... I replaced typeof this.subject with this.subject!.constructor.name
My code readability rating is gonna plummet after this commit lmao
Yep... my code complexity rating dropped down from a C to a D
This code it's ok ? ```db.serialize(function() {
db.prepare('CREATE TABLE IF NOT EXISTS accounts (discname TEXT, apexname TEXT, platform TEXT)')
var stmt = db.prepare("INSERT INTO TABLE accounts WHERE (discname, apexname, platform) VALUES (?,?,?)");
for (var i = 0; i < 20; i++) {
stmt.run("discname" + msg.author.id, "apexname" + i, "platform" + i);
}
stmt.finalize();
stmt = db.prepare("SELECT * FROM accounts WHERE discname=? AND apexname=? AND platform =?")
stmt.each(msg.author.id, args[1], args[2], function(err) {
console.log(row.discname, row.apexname, row.platform);
}, function (err, count) {
stmt.finalize();
});
});```
nvm i found something i did wrong
at insert it's not table
i deleted it
i want CREATE TABLE line
db.run('CREATE TABLE IF NOT EXISTS accounts (discname INT, apexname TEXT, platform TEXT)')
var stmt = db.prepare("INSERT INTO accounts VALUES (?,?,?)");
for (var i = 0; i < 20; i++) {
stmt.run("discname" + msg.author.id, "apexname" + i, "platform" + i);
}
stmt.finalize();
stmt = db.prepare("SELECT * FROM accounts WHERE discname=? AND apexname=? AND platform =?")
stmt.each(msg.author.id, args[1], args[2], function(err) {
console.log(row.discname, row.apexname, row.platform);
}, function (err, count) {
stmt.finalize();
});
});``` no errors but isn't insert anything
isn't creating
...
what should i do?
How to have more than one .setURL in an Embed?
Set url is for the title only 1 title
ok
You can have links like this tho [ABC](https://google.com)
@stray garnet
In embeds only
ok
HELLO DEVELOPERS
Hi
How may we be of service
yeet ask2ask
By asking if you can ask a question, you have already asked a question so simply just ask the actual question. State exactly what the problem is so someone can help you as soon as possible.
i need help
Just ask it
Ask
thx i donr need coffe mr coffe bot
ok
how wll i make a link of my web page
how wll i make a link of my web page
We need more information
Hmm
?
Tell us more.
In this tutorial, I'll show you how to index your website using Google Search Console (formerly known as Webmaster Tools). Links: https://support.google.com/...
This may help
You mean Website.
yup
ok
Refer to the video I sent you then
Links:
https://support.google.com/webmasters...
https://moz.com/blog/a-beginners-guid...
there r 2 links which 1 do i choose?????
Click https://search.google.com/search-console/about then get started
ok lamme mail this link to my laptop
alright
db.run('CREATE TABLE IF NOT EXISTS accounts (discname INT, apexname TEXT, platform TEXT)')
var stmt = db.prepare("INSERT INTO accounts VALUES (?,?,?)");
for (var i = 0; i < 20; i++) {
stmt.run("discname" + msg.author.id, "apexname" + i, "platform" + i);
}
stmt.finalize();
stmt = db.prepare("SELECT * FROM accounts WHERE discname=? AND apexname=? AND platform =?")
stmt.each(msg.author.id, args[1], args[2], function(err) {
console.log(row.discname, row.apexname, row.platform);
}, function (err, count) {
stmt.finalize();
});
});```
ah, the one thing i haven't done yet: this
=))))
what package are you using for it?
sqlite3
oh i hate it //j
have you considered dblite?
no
at me it's 10:30 p,
Or http://docs.sequelizejs.com/
Sequelize
Node.js ORM for PostgreSQL, MySQL, SQLite and MSSQL
ooo that's nice
i've heard of that but haven't touched it tbh
I use it and it works like a charm
it's more easy then sqlite
Yes
good luck with it
How can I sort all the guild channels? (using discord.js)
sort by what? sort in discord or sort in the bot? by name or by id?
I was sealed, not sort, iterate using loop foreach (sorry for my english, i don't know how can i say it)
I found I talked about it
message.guild.channels.forEach(channel => {
});
We can only help you if you give more detail, not spoon feed
Speedy
.replace('?', '')
Strings are like arrays of characters
@wide ruin
You can use it's length to be able to get the last character
or slice the begging
you could just use last array index
theres like 10 ways in js to do that with a string
that will remove any question mark in the string and you couldnt be able to tell where @earnest phoenix
string[:-1] if talking in py?
A npm module exist for hex color? Like check if a hex color exist
Thanks
Anyone have a rough guesstimate of how many servers a local machine can host with a small mongo based bot?
Like, 100-150 users prompting query commands
I wanted to test my game on a larger audience but not sure if a laptop or something would be cool with that
Could just use charAt();
I feel like js has an endless dictionary of string helpers
the .match codes are like reading brainf**k code though.
@earnest phoenix what do you mean by "hex color exist"
I would guess he means the range of hex that correlates to a color
maybe for bad user input?
yes
I'm not really an expert but Hex colors are 000000 through FFFFFF right?
correct
16 units x 6 ?
you could use d.js resolveColor function
so if the input is longer than 6, bzzt
static resolveColor(color) {
if (typeof color === 'string') {
if (color === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1));
if (color === 'DEFAULT') return 0;
color = Constants.Colors[color] || parseInt(color.replace('#', ''), 16);
} else if (color instanceof Array) {
color = (color[0] << 16) + (color[1] << 8) + color[2];
}
if (color < 0 || color > 0xFFFFFF) {
throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).');
} else if (color && isNaN(color)) {
throw new TypeError('Unable to convert color to a number.');
}
return color;
}```
just remove the color = Constants.Colors[color] part and you should be good to go
works with hex inputs, hex as string, rgb, random, and an array of rgb
scope question: My bot generates a list of players based off the documents in a Mongo db (Players->playerSchema)
As the project grows:
a) People in server 1 don't care about people in server 2,3,4...
b) The find {} query to build array of playerlist is going to continually expand and increase time to process
example of command
should the solution be in the organization of mongo, or filtered in the command?
Yeah, basically. But all encompassing
It lists people who are dead/afk, etc so you can know who your able to attack
Oh
Well you can limit the query
And you can also skip documents
So you could implement pages
Using that
@mossy vine wtf is that
so add a property to schema of the server id and just skip it?
its in what language ?
npm, mongoose, mongo
Then you can use .limit() on the query
and .skip()
So like
At first you could just limit by 10
Which would get the first 10 documents
the first 10 matching my find etc?
Then for the next page, you limit by 10 and skip 10
Which would give the next 10
yes
You can use .sort() to sort it if you want
ah that's a relevant way to handle a larger load
If you're not using sort it'll be based on document creation time afaik
I'm very proud of my sort command, im pretty new to the async world
players.find({}).sort({ level: -1}).exec(function(err,playerArray) { ...
I just revamped a json structure into mongo
but now I'm thinking bigger picture with multiple servers
Gambler.find().sort(sort).skip((this.page - 1) * this.display).limit(this.display).exists(this.stat.name);```
Taken from my leaderboard class
.display is a config of how many to show?
yeh
a number
I also use exists because some of the stats only apply to some users
Users that don't have the stat won't show on it that way
Yeah, that's the whole next level I suppose
I've seen many bots that have "prev" "next" buttons that seem to alter an embed
Do you think there’d be any reason why Array#flat isn’t working every since I moved to a new machine? It just says not s function
hey can someone help me? I made a custom event handler and it says that message is not defined i'm sending my code and err
Array#flat is like ~new ig
It says it was introduced in v10
well message is not defined
yeah theres no message on guildMemberAdd
on guildMemberAdd
why are you redefining a passed variable?
just pass bot, member
without message
since on guildMemberAdd no message is invoked
ohh ok
I check my node version by doing npm ls node right?
node -v
Mk
is there a way i can pass all the thing in 1 word?
then
guildMemberAdd doesnt pass a message
.run(bot, member)
so what do i do?
that editor looks like a christmas tree
oh wait node never updated ree
ye with a 🅱asic theme
@maiden mauve its atoms One Dark Pro theme
every noob's best coding buddy
how exactly do i update node? i tried rerunning the installer (and no n doesnt work cuz im on windows)
ah, I fell in love with sublime text default for js
yeah
but i like One dark more
I liek sublime
@slim heart uninstall old one via control panel, download new msi from https://nodejs.org
is my guess
if the rest no worky
like that?
If you're on windows
and you're gtg
uhh
Just the msi file with new update should replace the old version
have fun then
@late hill btw thanks I'll comment that off for future ref

did you use a Reaction based page Wes?
ah, so its a filtered leaderboard
top stat page
oh man I'm excited I just got the greatest idea
imagine there are 100 players in my find query
the players place in the sort determines the page loaded
nerdgasm
😂
How would I change the background color of my description?
in the website?
yes
use css
yes, but you need to be aware of the context
body is the body of the entire website, not the description field
the html and css you write is injected into an existing structure
so how would I go about doing it? im sorry im not familiar with html/css
use the element inspector / dev tools / f12
ah ok, got it thanks 
and how would i embed a gif?
i tried using <img src =... but it just shows a small icon
ah tyty
whats the easiest way to wait 1 second in js?
await a promise that resolves in a setTimeout
He just told you
i dont get what it means
Then you should probably learn a bit more js
read abuot promises and setTimeout, and then combine the 2
wouldn't those be different?
if you declare an async function and await the promise
versus just waiting 1 second
@lethal ridge what is the purpose of waiting 1 second
Not really development related
oh shit worng channel
i think so, yeah
hm
does the bot being a part of this server incur strange behavior
with people testing?
my bots only on 1 server and no input given
so if a command is triggered in one of those channels, you will get a discordapierror
exactly
@maiden mauve I'd recommend not sharing the info your bot collects about users in here
Or anywhere actually
oh
I see how that's a tad unbecoming
it stores name and flake for index purposes
It's set to save anyone who uses a command... ie ?help etc.
@pale marsh to reassure you 😉
🤦
I don't wanna know what data you collect. Just don't send screenshots of it here dude
👍
so I'm going trough https://medium.com/discord-bots/connecting-your-discord-bot-to-voice-channels-with-java-and-jda-403a9604e816 (I never did anything like that in java, only in node) and I'm wondering if the bot would send the message after he left the channel or at the same time?
// Disconnect from the channel.
event.getGuild().getAudioManager().closeAudioConnection();
// Notify the user.
channel.sendMessage("Disconnected from the voice channel!").queue();
depends on discord
like in js you would need to await the leave to send the message after he left
Yeah I'm talking about coding it so it will execute after he left
you can listen for a voice channel leave event and check if the user is the bot
halo bro
does anyone have autorole script and no auto nick ?? if there may I ask for it ???
what is no auto nick?
im having trouble importing the dbl library
what lang?
i keep getting "unresolved import 'dbl'"Python
i ran pip install dbl
and it installed
but it wont import?
||sry I don't know shit about python||
all good
hey please ignore where it says message ik it will be member but i have tried console logging and channel is undefined can someone help me
please read up on promises and js scopes
ok so how do i make it actually set it without the function that .then(msgs => )
by googling how to do it properly
please give me script auto role and auto nick brooo
because you clearly dont know what youre doing
@cedar nova no
async/await or put the stuff in the then function
yeah i kinda don't
so figure it out
@mossy vine ohhh no
we're not gonna walk you through it
yes np
😭
but can i get a quick fix for it
what youre doing tho is that youre defining somethin in a callback while looking for it outside of it
we're not gonna give you code no, thats spoonfeeding
@cedar nova ur job to do it, nodoby needs the bot doing the same shit just with another name
like i'm trying to make a welcome message
read up async/await to fix ur problem above
you need to do this
.then(etc=>{
etc2 = whatever;
stuff interacting with etc2
})
if you put it outside of it itll be undefined
hmm
I don't get his code anyway, doesnt make any sense to me
use async await or resolve promise by .then()
when i put the channel.send and if(!channel) inside the .then
then it also dosen't work
show how you did it
kk
google please. like i said i answered, if you dont understand you need to do more research yourself sorry
can you wrap your code or something? because you're not showing entire code in ur screenshot
but I don't even get what that code is supposed to do, fetchMessages for welcome messages????
that i do get but i'm asked for a quick fix for it
just, stop chy4e if hes doing it like that let him do it,
idk what hes doing either but let him go off
no fetch the channel from a discord channel i'm using a discord channel as db
i-
uh..
why star? am i missing out ?
okay guys, i think we reached peak dbl
using a channel as a db lmao
random js question, variable <= 0 -- can this result in a boolean or do i need to check if its a number?
i mean, you could just use sqlite or even json files
its a boolean if im understanding u correctly
json like to crupt
it means less than or equal too
I'll clarify
variable <= 0 will always return a boolean, if I got you right
and mysql take too much space
dude...
sqlite takes almost no space
i use free hosting
guys just stop let him go. clearly this is beyond us all lmao
that offers like 100MB storage
why not sqlite? or no fs?
i have tried all ways of a db
if ( variable >= 0 && variable <= 10 ) .... if the input is "" could this be read as false === 0
well, thats still enough space for several thousands of records, but anyways
well using a channel is the most retarded thing you can do, then better use jsons and write them atomic
its outside the promise scope
maybe ur great "db" is just bullshit and doesnt work
it does
put the console.log inside the scope
and see what it says
its empty ye
hmm
@onyx summit more straight forward, does js comparison operator use strict to differentiate string/boolean/integer share of 1/0 ?
or does it confuse a blank string with false and 0
that was returned by console.log(channel)?
try it
just open a browser windows lmao
I was writing a conditional and just got this random fear
how far can js go bonkers
you do realize that your "db" can't have over 100 entry's because you can only fetch 100 at a time?
@cursive gale looks like thats the output of console.log(welcomedb.messages)
One message removed from a suspended account.
put console.log(msgs) at the beginning of the .then()
@sage bobcat someone even made a package for it, but it was a joke and nobody should ever use that
that package is amazing
sqlite, no? jsons, no? any free db, no?
hmm
One message removed from a suspended account.
as I feared
i got a long message when i did console.log(msgs)
you have to check type ;D
@sage bobcat yes, but the author said nobody should ever use it, its a joke
type is text
You would need to cache all the messages in that channel
Not a good idea
Just use a real db
hmm
fetchmessages works, but limited to 100
when i get donations then i'll use sqlite
now console.log(channel) right after you define channel, and before you send the message
@cursive gale you don't need to pay to use a DB...
and how many guilds does your bot has?
cauz i'm broke
sqlite is free
it's in dev rn
You don't need to pay
ik
json is free
but
psql is free
And you probably won't get donations
sqlite took like 50MB last time i used it
you need to offer something for donations
Try cloud firestore
free up to a certain number of reads/writes iirc
yes i will have premium commands
then use jsons and stop crying, or elephant db, they give you 10MB, heck I will even give you my rethinkdb db
but its more than enough for a few thousands of operations/day
https://firebase.google.com/docs/firestore
Cloud Firestore | Firebase
Use our flexible, scalable NoSQL cloud database to store and sync data for client- and server-side development.
thanks
https://firebase.google.com/products/firestore
Cloud Firestore - Firebase - Google
i'll try it out
Yw
which by the way, google also offers google compute engine, which is a full vps completely free for 12 months
i'm not 18 yet..
with 20gb of storage
every "free" vps thing
And most devs arent 18 yet lol
yeah
you just need a credit card, you can borrow one from someone
just how big do you think your bot will be
unless your family/friends situation is really bad
the free servers/storage is pretty generous for projects
Firestore free plan
oh that kinda sucks ngl lmao
my bot on a single server uses 80kb/ 512 MB of free Mongo DB
hello
wow
@ashen kraken
Glitch should be fine until you get to like 4000 servers
but really, server costs are pretty minimal until you get to professional applications
theres no reason a teenager can't put $50 a month in a paypal/bank
50 a month??? you can get vps's for $3 a month
What did u type or whatever
I'm trying to setup a system whereby users can schedule things with my bot (node js), but i'm having trouble with timezones. The server runs on UTC, but obviously users will be from all different timezones. So if they try to schedule something for, say 10:00, 10:00 server-time is not going to be what they expect in their time. Is there a way to find out the user's timezone? I thought that new Date() would be client-based and show their time, but it seems to always show the server time, when different users call the command which displays that date/time.
Or does anyone know if there are any examples of other open source bots who do scheduling, so I can see how they do it?
ty
@pearl parcel its impossible to get user timezone/location
i got that when i clicked create project
@pearl parcel what you can do is to ask them to define their timezone and save it in your database
or ask them "what time it is for you right now" and edit the time accordingly
ok ty
why would you think new Date would be the time of the client
cos it is when you use it as a timestamp in an embedded msg
You can't run any code client side
i got it
The timestamp localizes cuz it's a discord feature
i'm banned form dev services on google

o
Tf
country restrictions?
@cursive gale https://www.npmjs.com/package/discord-storage 
o
Yikes.
This project was written as a joke
what you are doing is even worse
so don't do that
any of this
i'm gonna stick to my next lvl discord channel storing things way
you can only fetch 100 msges at a time
||if you really can't do shit about it dm me and I will let you host the bot on my server, I do this for 4 other ppl atm||
then reject
@onyx summityo i want free hosting too lol
yes, thats the downside, I could be an ass and steal ur token
If you are able to use GCP you get a free year with a afree $300 limit.
are able to u
for a reason that i must not tell
the only reason you'd ever give token to anyone?
to host your bot? (but then they'd have source code too?
Famously said by JaGeX Never give your password, not even to family or friends
Or some shit like that.
This is getting off topic, move to #memes-and-media please
I currently host for @molten slate @tepid stirrup @green swan
Yeah I wouldn't trust free hosting
^
Also if you can't use gcp azure gives a year free trial
do what you want
Last warning, move to #memes-and-media
Can someone plsss help... I've been having this problem for days now
Code: https://gist.github.com/SinistreCyborg/aa76f6291df70d4a11b0d51fa2cfcdff
There are 5 errors in total, all of them are the same, just for different parts of: case => case.guild
(Line 18 of Guild.ts)
I mean, I did it exactly how the docs said... but it still doesn't work
https://typeorm.io/#/many-to-one-one-to-many-relations
That doesn't fix anything, it just opens up yet another error
Again, these are all the errors:
If you want to use @OneToMany, @ManyToOne is required. Where you set @ManyToOne - its related entity will have "relation id" and foreign key.```
And we can see that the Guild is ManyToOne
I'm not familiar enough with this, sorry.
is there some regex thatll test for special characters
anything that isnt numbers and letters
Yeah you can specify not numbers or letters.
how exactly :p?
just use a character class for everything but alphanumeric
[a-zA-Z0-9] matches only alphanumeric
So you can do /^[a-zA-Z0-9!@#$...etc/g
add a ^ and it negates
^^^ Best girl has the right idea.
[^a-zA-Z0-9]
or you can test it's only alphanumeric
aka the whole input matches ^[<alphanumeric>]+$
Oh alright, what’s the ^?
Ah i see perfect thank you so much
^ inside a character class is "everything but these"
Oh I see ok
"4567 stuff is fun4you 67".match(/^\d+|\d+\b|\d+(?=\w)/g); //=> ["4567", "4", "67"]
I attempted to decipher the documents on js string filters
but it's a brain ache
One message removed from a suspended account.
check #265156361791209475
how do you get a string, and output each character 1 second apart?
js
like how do you use setTimeout and stuff
Split it into an array
or use Array.from(string)
and then loop with it with
for (const thechar in thearray)
or "stringhere".split("")
console.log('5 seconds later')
}, 5000)```
setInterval( () => {
...
}, 1000);


HMMMMMMMMMMMM