#development
1 messages ยท Page 350 of 1
considers using an emoticon as the prefix
it would help a lot of it was easy to execute commands 
just started a web design / desktop app project yesterday
x,-Ddostuff
i just noticed today the similarities @languid dragon to discord
what simularities
oh gg

sexy
Hey, I am confused about client IDs. What do I put there?
omg and should see the load screen how i make that
all i do is halt up the program more
your client ID can be found on the discord developers page
so it can show
you create your application here
litterally deadass look at this
const {
app,
BrowserWindow
} = require('electron')
const path = require('path')
const url = require('url')
let win
function createWindow() {
/* main window stuff */
let win = new BrowserWindow({
frame: false,
backgroundColor: '#272727',
icon: '',
width: 1000,
height: 600,
show: false
})
win.setMenu(null)
win.setResizable(false)
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
win.on('closed', () => {
win = null
})
/* splash screen stuff */
let splash = new BrowserWindow({
frame: false,
backgroundColor: '#272727',
icon: '',
width: 300,
height: 300
})
splash.loadURL(url.format({
pathname: path.join(__dirname, 'splash.html'),
protocol: 'file:',
slashes: true
}))
splash.on('closed', () => {
splash = null
})
splash.setMenu(null)
splash.setResizable(false)
/* once main window is fully loaded close splashscreen and load main window */
win.once('ready-to-show', () => {
splash.close()
win.show()
//win.webContents.openDevTools();
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
im disgusted with myself
i littterally
halt the whole program
to load a window
that says loading with a gif
then load the other window
lol
wew
i made a windows 98 themed list of some sort
i assumed the meany beeny stack
why even
pls banne
rem is bad
cos i can 
inb4 i turn it into an electron app
actually thats a great idea 
THATS ACTUALLY A GREAT IDEA
no distribute win95 emulator
and since electron ALL PLATFORMS :I
u would be best person ever
converting to electron litterally takes 5 secs
ill think about it 
i know
but i would need to re-code a lot
i could actually make the mini windows appear outside of it
lol
i have 8 gigs of unused ram on my server ;/
i should probably downgrade
considering i use 300 megs

:/
lol
i only do it with friends for obv security reasons
and thats why its free
ye
make a game using electron ๐ค
Can anyone help me with this?
ok
npm ERR! file C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
npm ERR! path C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
npm ERR! shoppinglist@1.0.0 start: `electron .`
npm ERR! spawn C:\Windows\system32\cmd.exe;C:\ffmpeg\bin ENOENT
npm ERR!
npm ERR! Failed at the shoppinglist@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\Nathaniel\AppData\Roaming\npm-cache\_logs\2017-12-12T01_45_34_343Z-debug.log
I have FFMPEG Downloaded.
It's in my path.
Yep
is that the complete log? or can u open that log it output
1 second
let me find the complete log.
\bin;C:\Program Files\Java\jdk1.8.0_111\bin;C:\Program Files\CMake\bin;C:\ffmpeg\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Windows\system32\cmd.exe;C:\ffmpeg\bin;C:\Users\Nathaniel\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle shoppinglist@1.0.0~start: CWD: C:\Users\Nathaniel\Documents\electronProjects\shoppinglist
10 silly lifecycle shoppinglist@1.0.0~start: Args: [ '/d /s /c', 'electron .' ]
11 info lifecycle shoppinglist@1.0.0~start: Failed to exec start script
12 silly lifecycle shoppinglist@1.0.0~start: Returned: code: -4058 signal: null
13 info lifecycle shoppinglist@1.0.0~start: Failed to exec start script
14 verbose stack Error: shoppinglist@1.0.0 start: `electron .`
14 verbose stack spawn C:\Windows\system32\cmd.exe;C:\ffmpeg\bin ENOENT
14 verbose stack at _errnoException (util.js:1024:11)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
14 verbose stack at onErrorNT (internal/child_process.js:374:16)
14 verbose stack at _combinedTickCallback (internal/process/next_tick.js:138:11)
14 verbose stack at process._tickCallback (internal/process/next_tick.js:180:9)
15 verbose pkgid shoppinglist@1.0.0
16 verbose cwd C:\Users\Nathaniel\Documents\electronProjects\shoppinglist
17 verbose Windows_NT 6.3.9600
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Nathaniel\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 verbose node v8.8.1
20 verbose npm v5.6.0
21 error file C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
22 error path C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
23 error code ELIFECYCLE
24 error errno ENOENT
25 error syscall spawn C:\Windows\system32\cmd.exe;C:\ffmpeg\bin
26 error shoppinglist@1.0.0 start: `electron .`
26 error spawn C:\Windows\system32\cmd.exe;C:\ffmpeg\bin ENOENT
27 error Failed at the shoppinglist@1.0.0 start script.
27 error This is probably not a problem with npm. There is likely additional logging output above.
28 verbose exit [ 1, true ]
did u add it to the Env Variables?

Env Variables.
Please explain
Wait
Enviromental Variables?
What var do I need to add it too?
path
C:\Windows\system32\cmd.exe;C:\ffmpeg\bin;C:\Program Files\Java\jdk1.8.0_111\bin;C:\Program Files\CMake\bin;C:\ffmpeg\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Windows\system32\cmd.exe;C:\ffmpeg\bin;C:\Users\Nathaniel\AppData\Roaming\npm
thats the path value.
@fiery quail example: http://dev1nee-took-me-to.a-porn.store/images/21690.png
i have a dev question
suppose i need the bot to escalte perms
like adding perms to add reactions
is there a clean way of doing that?
im thinking the only clean clean way is to do a broadcast
Just wondering
For a Python bot, how do you guys update it while keeping the downtime minimal?
What I do is uplpad new script, stop python script and start the updated script
You make a beta bot
At least what's what I did
Another version of the same bot running on a different account on which you can test out the new code and stuff
^
I already test it on a different account
The issue is that updating the code on the main bot gives the bot downtime
As I said, the process I do is uploadong the files to the server, stop current python script and start updated python script
that is expected downtime
Well in that case down time should be minimal no? Like it'd only take a couple of minutes to update the code I don't see how that would be an issue
I would have to check every single user if they are still on the same server or left
While I plan to use lazyload for that, I prefer a diff solution to keep downtime as minimal as possible
save the current status in a json file and read it afterwards again ยฟยฟยฟ
or sql, i dont care
somewhere where you can save it
It's already using sqlite, as I said, the issue is if someone leaves while the bot is down
save the current status to somewhere
just check the servers on startup
read it when it is back up
^
Do you know what sqlite is?
no, i dont, is it food ยฟยฟ
The issue is if someone leaves, it won't knoe when it's down
oke, easy
why not just after startup check if user count is still the same
and read accordingly
when it starts up, compare it again with your database and what is online(or memory)
@stone kiln that's what it does currently, which takes time
Using lazyload, it takes longer
So having less downtime is the best solution for an accurate amount
why not make a timeout while it's doing that and say
bot is in startup mode please be patient
you are using py right?
Yes, but it checks on every server every single user
Thay's a bad way of doing
Discord already tells when they leave
But, as I said, I wont get that information when the bot is down
why not load the db first and then the commands
so while it's loading in the commands at the sametime it's reading all user count
for me i can easily do that with what i'm used to
first it loads the db then it loads the commands
and easier way
set it to invis while it's doing that
so people won't execute commands while it's reading the db
its simple
when your bot starts up there is a variable that tells the cmd handler (if you have any) to block any command and tells the user that is it starting up
while it is starting up, let it loop thou your db and check if the user exsist in the guild yes or no: (yes, do nothing | no, log it) if there guild user doesn't excist in db log it and add it in db
when the bot is done with that, toggle the variable that tells the cmd handler (if you have any) to allow every commands
if you don't get it, tell me what you don't understand
@north fog what you don't understand is that it already loops using lazyload
Using lazyload, it uses less server ressources, but is slower
For accurate information, less server time is the best method
import sqlite3
connection = sqlite3.connect("company.db")
cursor = connection.cursor()
cursor.execute("SELECT * FROM employee")
print("fetchall:")
result = cursor.fetchall()
for r in result:
print(r)
cursor.execute("SELECT * FROM employee")
print("\nfetch one:")
res = cursor.fetchone()
print(res)```
straight up sql XD
I already have a code that checks every user ๐ as I said multiple times
The question is how to update it with minimal downtime as possible
sorry, im not a py genius, so dont know much about lazyload
not using js either
then I can't help you, I gave a simple solution but if you can't agree with it, then I can't help
H E Y
do this <@Yourid>
instead of that use <@${msg.author.id}>
tag is like #xxxx
what works with both
ok
there is literally an example written in there for you
Hello guys! Can you explain me how to play PLS stream with LavaPlayer (JDA)?
and a link to help you set it up
google
@north fog battery died, as I said, your simple solution doesn't help at all because something similar is already done, which works fine. My question is how to keep it up with minimal downtime, not how to code
fast computer/server
Can the same token be used twice?
so far I know, yes
Perfect, might do a load balancer
Do you know why lavaplayer throws exception if I try to play music by youtube url?
It happens only if I use URL links
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is unavailable.
I don't know lavaplayer, but could it be because you don't link directly to the video file?
@unreal tusk
I open video in youtube, copy link from browser to this video and use it
What language are you using?
java
you should be able to do it by invoking ytdl
https://github.com/phantamanta44/Sonarous/blob/master/src/main/java/io/github/phantamanta44/sonarous/player/song/impl/YoutubeSongProvider.java something like that
@icy lynx you could run two shards
Well
Not two shards
More like the bot runs parallel
@icy lynx you can start a new instance (let's call it B) of the bot, wait for it to load, kill the bot (instance A), start new version, kill B
@inner jewel Do you know any app/lib for that?
just run it again
maybe add a flag so that it doesn't read from DB
starting it should be the same as before
you just start a temporary process with the old code while you update it
Yes, might do that
does my bot have to be online to be added in this server?
idk
omfg
why the fuck would you add an offline bot to the list
people invite it, it doesn't work
genius
btw
Is there a reason why this has many downvotes? ```import requests
dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken}
async def on_ready():
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)```
There's another one that uses requests and got a downvote

I used to use requests and since I moved to aiohttp I found huge decreases in CPU usage
And moving over is not that hard
Wish I knew it sooner ๐
windows.navigator.vibrate() if you know what i mean ๐
Most modern mobile devices include vibration hardware, which lets software code provide physical feedback to the user by causing the device to shake. The Vibration API offers Web apps the ability to access this hardware, if it exists, and does nothing if the device doesn't support it.
Just wondering regarding the discordbots API. Does it update instantly when I do the POST request?
Wanted to make sure it's working
i thought it used something sorta like rest?
POST /api/bots/:id/stats
ohohohohoh ok
@icy lynx just check #312614469819826177
@neon pasture What I used is similar to that
what lib are you using?
await aioclient.post('https://discordbots.org/api/bots/' + str(client.user.id) + '/stats/', data={"server_count": len(client.servers)}, headers={'Authorization': '-token-'})```
This is what I use. No idea if it works
i program in shakespeare, could i get a server count example for that?
it instantly updates, or atleast I think so
Is there a way to prevent sqlite from looping?
page instantly updates too
It does? That's weird. On the server, it reports unclosed connection/repsonse, which might be related to the cause, but I can't reproduce it on my end
here it updated instantly after posting count
It seems to mention something about a proxy, and I saw github issues mentioning it. Guess it will be a long night
Fixed unclosed issues by updating aiohttp dependencies, but it still doesn't insta update. hmm
How can I fix that .once isn't running multiple times?
what lang?
javascript/nodejs
It's for sqlite, right?
yes
Someone told me this: everytime someone goes to play a song, you add a new listener to the connection, so if someone queues like 10 songs and the first song ends, all of those .once's will fire at once.
so I want it only fire one .once.
Could you show the code?
Mhmm, can't help you on this one. I'm not familiar with once()
yeah, it's the same as with .on
@neon pasture change EventEmitter.once() to EventEmitter.on()
once() will only receive an event... once
:v
Which event?
Well, if your issue is with it, i assume you are using Eris?
yes
Hmm, second, lemme get abal's git to look at it
Are you sure end is a client event?
yes
is that a big problem?
I'm sorry, I can't read
Well end event should be triggered only once, as a SharedStream is not a singleton
Here for reference
Someone told me this: everytime someone goes to play a song, you add a new listener to the connection, so if someone queues like 10 songs and the first song ends, all of those .once's will fire at once.
that's the big problem.
Hmm, i have never dealt with music with Eris, personally i use djs, but why exactly use SharedStream?
I mean
yeah
its designed to be used for like a bot streaming from a single source
to multiple channels
It'll fire once for a bulk of voice connections
If you want per Voice connection, you should look for another method
playStream(); In discord.js you use this right?
So I need to find that, but then for Eris
there's a client function for joining a voice channel
why not use pipes?
I'm not that smart
take a look at client.joinVoiceChannel and client.voiceConnections
Jeff you are probably looking for this https://abal.moe/Eris/docs/VoiceConnection#function-play
ya thats what he is looking for
Ofc, when you get a VoiceConnection instance first
I use that.
Then how you ended up with SharedStream
I can use .volume.
But the stream ends for different reasons
lol
SharedStream end event is triggered when all VoiceConnections streams end
you mean in all guilds?
reading lib source code to understand how it works
Well, look at some example online, there are tons of repos you can base yourself off
Gotta follow the roots till you find your answer
google > stack overflow > read docs > read issues > read source code > understand source code > read nodejs > read v8 docs > read v8 source code > understand v8 source code > read C++ docs > read g++ source code > understand g++ source code > read Assembly docs > read Assembly source code > understand Assembly source code > read OS docs > read and understand OS source code if Linux > read hardware docs > understand hardware > build own hardware to re-produce error > ??? > profit
same
How to be good at css m8
Wha
Does anyone know how to use messagecollectors?
messageCollectors sound like Discord.js (Javascript)
A guide made by the community of discord.js for its users.
could be usefull
Yeah.
๐
oooh
@earnest phoenix Did you install ytdl-core ?
do you use windows?
@earnest phoenix Volume ?
Do you have your vol. up
hmmm
I dunno man I don't make Music Bots
this is some error i got
Well you probally need like a playlist
Hmmm
but doesnt matter
@gilded plank help

?
The errors are given to you, if err is undefined, define it
If ur getting a weird error from a module
Google it
Theres bound to have been someone else out there with the same error
^
How can I get Watching message on my bot? Using discord.js
rich presence
So I'll have to make a rich presence for my bot?
is it possible to set up "private bots" that are not publicly accessible? We already have a NodeJS bot for our Twitch IRC channel and want to add it to our Discord server, but it is not a pure Discord bot, so having it be public would not be realistic for it.
You can still have it public, you just don't share the link with anyone
And just invite it to your guild
okay cool, thanks for the info ๐
np
Can it still join servers?
If public bot is unticked, only the owner can add it to servers
ok
check line 1348
try removing ;
let him check it first.
Yeah
done
and can you send a screenshot of it please.
I know
just saw it
@earnest phoenix can you make screenshot of line 1348, sorry
or you already fixed it?
trying to help and he isn't responding anymore. noice
ok
Is it fixed or?
hm
I don't get that line of code str.toLowerCase().indexOf('youtube.com') > -1
Why do you want it to be lowercase in the first place?
The problem with the music code I'm sure this was not the case until the music code was added
Youtube uses 64 type lettering 0-9 a-f A-F
so if you make it lowercase
you will get a different video
I will give you a server link and edit it
Weird
yes
Still unexpected token?
yes
When you launched the bot?
?
Do you have a solution
My solution didn't work, so I guess no.
ok
Sorry
if (element.memberCount < 4) {
element.guild.leave();
}
});```
Is this going to work?
You have element.memberCount and element.guild.leave() 
element is a guild object so basically ur doing guild.guild.leave()
I'm sorry dad.

How do I replace spaces in a string with something else?
Like for instance how would I put all words from a message into seporate arrays
Like [ 'Hello', 'I', 'am', 'a', 'person' ]
I tried .split() but that returned a whole array
...have you tried 'Hello I am a person'.split(' ')
split(delim) takes an argument delim that defines what character to partition the string by
Hey guys
@earnest phoenix okay so I'm not entirely clear here
what are you trying to do and what have you already tried?
.split() splits on all white space not just spaces
Also, why would you need each word in a new list?
Okay er nvm
Theres a way bigger problem that I have
.>
How do you use message collectors in DM channels?
My code is
message.guild.fetchMember(message.author.id).then(e => e.send('What tag would you like to see? This will await will be cancelled in 30 seconds. It will finish when you provide a message that goes through the filter the first time.'))
.then(() => {
message.guild.fetchMember(message.author.id).then(e => e.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
}))
.then((collected) => {
message.channel.send(`The collected message was: ${collected.first().content}`);
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
});
I need to fix a few things
But how would I get it to awaitMessages in the DM channel
sorry, I assumed you were coding in py
this is clearly not py
Nope
d.js
Should have specified that, sorreh
Is anybody around?
Please mention me if you can help ;-;
can someone help me make this full screen: https://habchy.com/captures/99494.png
the snow just stops there
is it contained to a div?
and that div only goes there?
also i would have to see snow's script to see if it limits itself or has a die time
http://ub3r.xyz is the best site
best use of sockets 2018
anyone a pr0 with javascript?
http://lizardsuc.cf/717cโ450?!?!?!
this should work right? 
show the whole code you cropping monster
then we can't help
I'll judge u hard
xD
god damn it http://lizardsuc.cf/cd5fโ451?!?!?!
whats wrong
wait no that won't work lol
why
I tried
i get NaN ๐ฆ

they're undefined
the this takes the scope of the declaring scope
not the scope of the object
you'll have to reference them with rRollBot.a + rRollBot.b
yeah but i cant do this either http://lizardsuc.cf/8fafโ456?!?!?!
you can't declare them in one statement lol
and i dont wanna waste time declaring it again outside of itself
ill google it REEEEEEEEEEEE
hmm
you can do something incredibly stupid like
rRollBot.t = rRollBot.a+...
let x;
let o = {
a: x = expression,
b: x += expression,
t: x,
};
but what's the point
ew
alternatively,
let o = ((a, b) => ({
a, b, t: a + b,
}))(expr1, expr2);
?
javascript is a c r e a t i v e language
horrible
thats awesome lmao
just do the calculation later
i've been doing too many one liner challenges
wym 
let a = new Roll();
return a.t;
OH
WELL THEN
THAT MAKES IT SO MUCH EASIER
THANK YOU LOOL
i only just discovered JS classes the other day ๐
remember classes are just syntactical sugar for defining functions with properties
mm syntaxical sugar
it's really stupid actually
class A {
constructor() {
this.t = 1;
}
}
is more or less identical to
function A() {
return {
t: 1,
};
}
just add +1 to your randomizer
love javascript
good for code golf, prototyping, and not much else
and call it twice for bot and user
guaranteed java programmer
lol nice "animation"
ty OwO
classes are for scrubs anyways
ur a scrub
u are
class ken extends gay
๐ณ๏ธโ๐
class Ken(Gay, Weeb)
let ken = new Ken(true, true)
that's python you fool
๐ญ
who cares
programming jokes work anyway
lol
lol
Conjecture: Ken is gay
Observations: His profile pic
Conclusion: The proposition is necessarily true

heh
e x p o s e d
lol
if (!message.content.includes("--silent")) {
member.send(stripIndents `
__**You have been banned! - PERMANENT**__
__**Server:**__ ${message.guild.name}
__**Reason:**__ ${reason}
__**Moderator:**__ <@${message.author.id}>
**Oh, no! Seems like you have been banned! :frowning:**
_You have been banned. This could be unfortunate or fortunate to you, depends on what you wanted to happen :thinking:_
`)
}
can someone help me embed that
Just lookup your libarary docs for the embed object
what
https://weeb.hacked-your.webcam/968fc11.png i love logs 
ikr ๐น
why do they do this
Bots, prob
IE
Okay, does anybody know how to use await response in a DM channel?
like any other
But I tried and the whole thing breaks
Like it sends a message to the DM channel
It then just doesn't wait at all
show code
Okay hold on
message.guild.fetchMember(message.author.id).then(e => e.send('What tag would you like to see? This will await will be cancelled in 30 seconds. It will finish when you provide a message that goes through the filter the first time.'))
.then(() => {
message.guild.fetchMember(message.author.id).then(e => e.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
}))
.then((collected) => {
message.channel.send(`The collected message was: ${collected.first().content}`);
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
});
}
});
I know I need to change the message.channel stuff
But the awaitResponse code just doesnt work
It is indented, discord is just being weird
message.guild.fetchMember(message.author.id).then(e => e.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
}))
I got rid of max because it isnt rlly needed
But this just doesnt work
I have no idea why
Maybe its because e isnt the correct item?
Hello?
This isnt working
call it what you want, but it makes it easier to read when you call it something related to what it actually is
members don't have channels also
But then how would I use awaitMessages in a DM channel ._.
dmChannel.awaitMessages
Ohmygoshthankyousomuch
only users have a dm channel, not members
Im looking at it, trust me
well, it's either because you're typing DMchannel not dmChannel or you're still trying to get the dm channel of a member
Oh
It was DMchannel
My bad
;-;
It still says it isnt defined
.then(() => {
dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
Ah wait
Nope
Nothing I do is working ;-;
Nvm
Got it to work
How can I get the next value in a collection?
For instance
I do .first()
Then how do I reference the next value after that
@earnest phoenix language?
d.js
Is there any way to change color of the bots name on dbl?
I tried it for the html but that didn't do anything
To change the color
Wdym
Oh
Im using awaitMessages
So basically
It gets a message
Then gets the next one
Then the next, etc.
Like how would I make it keep getting the next one each .then() statement
I have collected.first().content
But then how would I get the next value after the first
uh i'm really confused
Okay
have any pseudocode to show?
Yes
.then((collected) => {
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question2} \n \`\`${collected.next().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question3))
})
})
Ik .next() isnt a function
But how would I keep going down a value in a collection
Okay, my entire code is this
client.fetchUser(message.author.id).then(user => user.send(Question1))
.then(() => {
message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.then((collected) => {
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question1} \n \`\`${collected.first().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question2))
})
.then(() => {
message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.then((collected) => {
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question2} \n \`\`${collected.first().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question3))
})
})
.catch(() => {
message.guild.fetchMember(message.author.id).then(e => e.send('There was no collected message that passed the filter within the time limit!'));
});
});
sorry i'm on mobile and i really can't read that
Rip
lemme get my laptop out
Okay
When I do collected.first() the second time
It returns the first statement
Which makes sense, but not what im trying to do
Okay, lemme try to explain this better
I have a collection of items
I referenced the first one
But how would I reference the one below that?
Aka the next one
Oh
But then-
How would I get the message the user sent
So
For example
I have this
you could use the spread operator to turn it into an array
okay looking at your code there are a few issues here
first of all, you're fetching the user every time you send a message
?
why not just store it to some variable before doing all your message sending and use that variable
Oh nononono its on an if (message.content ===) statement
That wouldnt work though, because I need to change the variables inside the calling user
I'm asking why you use client.fetchUser(message.author.id) every time
Oh
Because basically
This code sends a user a DM
Then it sends a question
They respond
It sends a user their response
Then it DMs them another question after the response
And that is why I asked how to get the next value in a collection
well your issue here is that your second then call is chained onto the first promise instead of the second one
Oh whoops
How would I change that
Wait no I need it that way
Because once the user from the first promise responds
It needs to send another question
Wait
right but you call then() twice on the first promise
Imma try something
what you're trying to do is call then() on the second promise within the then() of the first promise
you probably just misplaced some braces
Rip
Because I dont know how to use that ._.
learn
it's a much better paradigm than callback hell
if you can't help you, we can't help you
Oh I get how this works!
Its basically what I was doing but a lot easier
But I need to use functions for it
Wait how would
async function Questions() {
await message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question1} \n \`\`${collected.first().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question2))
}
Would this suffice?
i don't get why you use await and .then()
you should only use await
or only use .then()
not both at the same time at least
I would argue there are uses where mixing is okay
yes, here you are totally able to drop .then
.then()
Where
Oh
That is required for my user DM code
async function Questions() {
await message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question1} \n \`\`${collected.first().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question2))
}
async function Questions2() {
await message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
message.guild.fetchMember('376147022660632587').then(e => e.send(`${Question2} \n \`\`${collected.first().content}\`\``));
client.fetchUser(message.author.id).then(user => user.send(Question2))
}
Questions()
Questions2()
This is what I learned
From reading the document
It waits for the awaitMessages promise
Then sends messages
I don't think you understand it quite yet
Dang it
await waits for a promise to finish then returns the value it's resolved with
Why are you fetching the bot user twice?
?
I asked that too lol
Im fetching a user by ID
But dosent the library already have stuff like currentuser.sendmessage
And im doing it twice because Im creating a question and response system
or something like that
ok check this out
instead of doing something like
fetchUser(id).then(u => u.sendMessage('hi'));
fetchUser(id).then(u => u.sendMessage('hi again!'));
you can just
fetchUser(id).then(u => {
u.sendMessage('hi');
u.sendMessage('hi again!');
});
Okay
or, in the async/await pattern,
const u = await fetchUser(id);
u.sendMessage('hi!');
u.sendMessage('Hi again!');
sendMessage ๐ค
i'm just making stuff up
Im just deleting all my code I gotta start over
Okay wait
I prefer to use .then systems
why
I just understand it better ยฏ_(ใ)_/ยฏ
But the main problem is im not sure how to get the next value in a collection
So like .first() gets the first one
But then how would I get the one after that
I'm absolutely sure you're fundamentally misunderstanding many things but I honestly can't be bothered any more
use collection.first(n) to get an array of the first n elements
O
I'm sure you can infer how to get an array of all the elements

I mean if you want to get through all values you can do a for/foreach loop
It says you are missing a ) somewhere....
Maybe
@prime cliff end
No limit answers
why
@earnest phoenix
<@&304313580025544704>
help
Jeez
you got to be kidding me
Don't ping all mods
Why'd you fucking tag every moderator
please ping the people who are helping you in the moment, not all mods
why is that even a taggable role
^
apparently it needs to be taggable
Bc tonkku and oliy want it to be
I'm going back to sleep
Fuck @SnoW#4749 for waking me up
bluh
Force them to write emails to the moderation team
they left
woooooooooooooow
here we go
Lol
He only wanted help because of a missing ) lmao
Finally managed to add my bot server count. (more like finally was bothered to)
@glacial vale what lang?
Who pinged me
Did you use my code?
it works
yes and no
i used it but its slightly outdated atleast to the discord.py rewrite version
so I had to change a tiny bit to get it working
helped a lot tho
What's outdated? I can fix it
since I could just shove it in, saved me some effort
well idk, its probably still up to date with the async version of discord.py
but there is the rewrite version
which means it then becomes guild rather then server
Ahh
I need to check the rewrite version, will guild be used in the future?
also, i almost forgot to make sure i put the token in a file since i push to github and didnt want anyone getting it
yes
Will need to get ready for the rewrite ๐ค
Hey guys?
How do I make promises wait for other promises to complete first?
I tried an async function but I have no idea how to use it
I've been working literally the entire day on this
And im so close
Nvm I got it
๐ remember to share the solution when you find it, for the next user
Well
I have a bit of a problem
I wrote out these huge functions
But then when I try to call them with .then
It says its undefined
Questions1()
.then(Questions2);
Questions1() isnt a property
it's a function that returns nothing presumably
Yes
because your call resolves to undefined
It doesnt return anything
make it say like 2
Should it?
why would you try to call then if it returns nothing?
To create a promise chain
but it doesn't return a promise?
Ah
it returns nothing, as you said




it